Hello monkeys from all around the world !
I’m here today to ask you a design question for an application that I’m currently doing at my work. It’s something where I need your point of view as a monkey to tell me if what I’m thinking is feasible, and if of course, you have any other ideas not only related to jmonkey.
Context
Well I’ll try to explain it in simple terms ( and be concise too),
- In the client application (in the browser) I use AngularDart in addition to ThreeJS to display a 3D model and give the user an interface to manipulate the 3D model and do things with it.
- The client application is connected to a SpringBoot API that do things for him (connected to client using Swagger).
- The 3D content is only a part of a greater file that contains a lot of information so I use the API convert this file into 3D datga that can be displayed into the browser using ThreeJS.
- I also use the API to fetch the informations…
(Enough with this crappy things !)
Where do I need JMonkey ?
I need to implement an API endpoint that detect if there is any collisions (or intersection) between the objects of the file. The idea is that I only use JMonkey as a utility framework to parse an do things with my objects. But to detect a collision I need to create a BulletAppState to access the PhysicsSpace and trigger the BulletAppState loop as well as creating a physics listener…
It’s fine when you want to do real time rendering but in my case it doesnt really help that much.
So I decided to look into the CollisionShape witch I though had an intersect function to detect collisions between two collision shape which is then redirected to the physics listener of the objects et voilà ! … But In fact… JMonkey use bullet as a facade and put a native call to bullet only where it’s needed. I’m not experienced enough with bullet to know what’s happening behind the scene, I’m only guessing.
What I’m dreaming of :
{ "object_1" : ["object_3","object_4"],
"object_2" : ["object_4"],
"object_3" : ["object_1"],
...}
public Map<String, List<String>> detectCollisions(){
//Crazy process to convert the 3D object into a blend file
Node model = (Node) assetManager.loadModel("model.blend", inputStream);
for(Spatial s1 : model.getChildren()){
CollisionShape shape1 = CollisionShapeFactory.createMeshShape(s1);
for(Spatial s2 : model.getChildren()){
CollisionShape shape2 = CollisionShapeFactory.createMeshShape(s2);
if(s1 != s2){
//Where are you baby :(
bool result = shape1.intersect(shape2);
}
}
}
}
I’m stuck… And I don’t know how to proceed with JMonkey… Do you have any ideas on what to do ? What should I use ?
- Use a part of a java physics engine ?
- Create a native call to Bullet ?
- Create my own intersect function on top of JMonkey ?
- Use an other engine,framework specialized into physics processing ?
Thanks you for reading this post !