Matriax

Importing .OBJ objects always with box collision

Recommended Posts

Any imported .OBJ have this box collisions.

image.png.e5c06816761106013203fb5468985b52.png

How i can set to the object the correct collisions or use the collision=mesh ? Maybe is there any function to force the correct collision in case are bad loaded or something ¿? .

 

I don't know if there is something wrong on my .OBJ, the plugin or simply babylon v2.6 not accept the collision and just draw a box?

 

Here is the .obj i'm using:

https://drive.google.com/file/d/0B8vm3FpJ3vqJT1RlNFIxTldLcU0/view?usp=sharing

 

 

Share this post


Link to post
Share on other sites

That looks like AABB collision detection (https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_collision_detection).  That is the default collision detection on meshA.intersectsMesh(meshB, precise?: boolean).  That second parameter 'precise' is OBB, which is more accurate.  Maybe easier if you have a PG.  What I do is create a physics impostor that closely matches the shape of my .OBJ, but maybe you are not using a physics engine?

Share this post


Link to post
Share on other sites

I can't provide a PG because i'm using Babylon via plugin for a game engine called Construct2 but i found a way to add direct babylon code. So if the plugin have some bug or missing features i can use babylon code adding it in the correct place from a solution provided.

So, he .OBJ loaded in Babylon only supports bounding boxes ? What happens if i have a complex object or mini-scene with multiple meshes? There is no way to set to that object a precise collision rather than a simple bounding box?

If i load a .Babylon scene to the game exported from blender i can do ramps,etc... and the collisions are precise. Why for .OBJ imports are only bounding box?. I will try to import .OBJ on blender and export as .babylon scene to see if i can load them into the same scene to get the correct collisions.

 

Edit: I added a Physics behaviour and i can set the impostor: Box, Sphere, Plane. Cylinder, Mesh, Heightmap. But always that run is the same box. Btw, for NeMesh objects if i change the box to sphere it really works. So maybe in the editor i select one or other but when load the .OBJ  applies the bounding box. So, i need the code to set the mesh physic impostor collide to a mesh manually with direct babylon code, mmm

Share this post


Link to post
Share on other sites

I tried to do a ramp in blender, export as ramp3.babylon and in the plugin code i do this:

BABYLON.SceneLoader.ImportMesh("Cube", "", "ramp3.babylon", scene, function (newMeshes, particleSystems) {
    });

The ramp is loaded at 0,0,0 position with the correct collision, that means i can go up to the ramp and slide down, instead of get the collision box.

So seems with this function i can load the entire scene(removing "Cube" at first) or select the mesh objects i want to import in the scene.

Before mark as solved i'm gonna test more complex stuff to see if works in all ways.

Any tips or things to consider using this method? What mesh collision is imported with this? Uses the "mesh" form collision?

Share this post


Link to post
Share on other sites

I'm importing .obj files and then creating my own physics impostors, so somebody else will need to let you know about how it's done from OBJ files directly - maybe it depends on export options for your 3D editor?  I would say you got it with adding physics behaviour (box/sphere/etc.).  Just make sure your physics engine supports the shape you use or they resort to a fallback shape.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.