Re: Vehicle configuration

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Vehicle configuration

Postby e3dalive » Thu Feb 05, 2015 5:34 am

I'm trying to instantiate roads in my application using newton.
I create shape with dNewtonCollisionMesh with baked scale and rotation
then i create another shape and set various scale for it(dNewtonCollision::SetScale)
then i create body with instance matrix, that only have position and rotatition
big static meshes work normal, but instantiated roads causes objects to fall and jump from them
video shows that all meshes are created and positioned correctly
maybe something wrong with my meshes, i'v tried that technique in havok, bullet and physx it worked.

newton version: latest from git

I've tried baking all position, rotation, and scale directly into shapes, the problem didn't go away

here is the video showing the problem http://www.youtube.com/watch?v=CJ7hCSEl ... e=youtu.be

i create geometry like this:
Code: Select all
geom.BeginFace();
   e3d_V3 points[3];
   for (int FaceID = 0; FaceID < msh9->GetNumFaces() * 3; FaceID += 3)
   {      
      for (int j = 0; j < 3; j++)
      {
         UINT face = ib[FaceID+j];
         e3d_V3 *vx = (e3d_V3*)((size_t)vb + stride*face);
         e3d_V3 tr = *vx;
         tr.Trfm(&BaseTRFM);
         points[j] = tr;
      }
      geom.AddFace(3, (dFloat*)&points, sizeof(float)* 3, 0);
   }
   geom.EndFace();

all collision masks are set to 1
e3dalive
 
Posts: 87
Joined: Thu Feb 05, 2015 5:20 am

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Thu Feb 05, 2015 11:35 am

I am confused, was this ever working? or you are just trying the first time.
I see some boxes and sphere bouncing bad, by it I not clear what the scale problem is.
but that code fragment does not seem to indicate any scaling, what is scaled?

What kind of application is this, do you have a test case I can try?
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby e3dalive » Thu Feb 05, 2015 5:23 pm

i have tried it with simple case
i have created simple meshcollision and created body for it
physics works for other meshes, but it fails on forward road meshes for some unknown reason
I've attached serialized scene for you to read(i created few boxes on curve road which works, and on forward road which doesn't work, i also attached mesh in 3ds max/opencollada format for you to analyze)
i think either i'v messed up with adding triangles into mesh, or maybe there is some sort of bug in BVH creation for that mesh
it worked in bullet/havok and physx, i was colliding boxes and spheres on that mesh with no problems.
i'm trying to port my car simulation software to newton
link http://s000.tinyupload.com/index.php?fi ... 8481175691
i've loaded serialised scene into demossandbox->basiccar and once the car wheel goes into that forward road it flew into space
e3dalive
 
Posts: 87
Joined: Thu Feb 05, 2015 5:20 am

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Thu Feb 05, 2015 6:43 pm

link http://s000.tinyupload.com/index.php?fi ... 8481175691
i've loaded serialised scene into demossandbox->basiccar and once the car wheel goes into that forward road it flew into space

I can not open external link form where I am now, is that data you sterilize don that link?

I am still confuse, you load data in the basic car? what I flow into pieces?
the data you loaded of the demo.
anyway I will look at that link tonight.

If you have this working with more than other libraries why are you trying to get it with Newton?
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Fri Feb 06, 2015 1:50 am

I download the file and I thing some is very very wrong with the .bin file.

I can see that the .bin file is about 100 time or more bigger that the ascii collide, and a the max file when the are usually smaller.
how did you generated that file?

I have Max 2012 I will see if I can save it to an .ngd
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby e3dalive » Fri Feb 06, 2015 4:01 am

the bin file is the whole map[it has roads, buildings, trees, e.t.c.]
in 3ds max i gave you the faulty mesh, other meshes on that map work fine(you can see it from the video)
in previous rar file i also gave you dae file, which you can open with openCollada plugin for 3ds max, or with collada viewer you can convert it to obj,3ds.
i serialized the file the same way you did in the demossandbox:

Code: Select all

void BodySerialization(NewtonBody* const body, NewtonSerializeCallback serializeCallback, void* const serializeHandle)
{
   // here the use can save information of this body, ex:
   // a string naming the body, 
   // serialize the visual mesh, or save a link to the visual mesh
   // save labels for looking up the body call backs

   // for the demos I will simple write three stream to identify what body it is, the application can do anything
   const char* const bodyIndentification = "gravityBody\0\0\0\0";
   int size = (strlen(bodyIndentification) + 3) & -4;
   serializeCallback(serializeHandle, &size, sizeof (size));
   serializeCallback(serializeHandle, bodyIndentification, size);
}


void SerializeFile(void* const serializeHandle, const void* const buffer, int size)
{
   // check that each chunk is a multiple of 4 bytes, this is useful for easy little to big Indian conversion
   dAssert((size & 0x03) == 0);
   fwrite(buffer, size, 1, (FILE*)serializeHandle);
}
      
...

FILE* const file = fopen("scene.bin", "wb");
      int bodyCount = NewtonWorldGetBodyCount(nworld);
      NewtonBody** array = new NewtonBody*[bodyCount];
      int index = 0;
      for (NewtonBody* body = NewtonWorldGetFirstBody(nworld); body; body = NewtonWorldGetNextBody(nworld, body)) {
         array[index] = body;
         index++;
         dAssert(index <= bodyCount);
      }
      NewtonSerializeBodyArray(nworld, array, bodyCount, BodySerialization, SerializeFile, file);

      delete[] array;
      fclose(file);


i also have another question, does newton have "collision tolerance" value similar to havok/bullet?
i figured the possible reason for the problem, it's clockwise polygons
on road they are inverted, so if i disable plane underneath the road the geometry falls right though road, is it possible to enable some CCW flag on newtonmesh, so it would enable polygons from both sides?
when i put boxes on the edges it work, between edges it fall through
i'm experimenting with newton for performance/stability testing, and to replace current raycast vehicles with newton joint based implementation.
e3dalive
 
Posts: 87
Joined: Thu Feb 05, 2015 5:20 am

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Fri Feb 06, 2015 11:15 am

Ok let us focus in the mesh wit the problem

you say that file
    main.DAE and straight street 2 lane 48m.MAX
is the file with the problem, is that right

I have Mas 2012, when I try to open it I got version error yor version is 1600. and mine is 1500
so you must be have Max2013 or higher, I can no open the original Max file

I try the Collada and I also Get a bunch of errors, that does no work either
If I say yes I get a file that I suppose is incorrect.

the are lot of solid boxes everywhere, this is what I see
Untitled.png
Untitled.png (140.95 KiB) Viewed 6319 times


Can you export the file as an FBX, collada file are not identical to what the source is, and it not well supported.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Fri Feb 06, 2015 11:40 am

I export the file as a FBX and I see that there are many meshes that are for other purpose

many of them have the prefix AI_, are you excluding those when you make the collision mesh.

I am try to get to the minimal mesh that is causing the bug.
when I remove all those pieces and the lamppost, this is what the street looks like
Untitled.png
Untitled.png (133.49 KiB) Viewed 6319 times

you say that the mesh will have collision problems?

if no can you in Max edit the mesh and remove the part that are no essential and export the part that cause the malfunction as an FPX format.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby e3dalive » Fri Feb 06, 2015 11:54 am

good opencollada importing plugins for all 3ds maxes are here https://github.com/KhronosGroup/OpenCOL ... LADA-Tools
all meshes that have AI_ in that file is ignored
i have attached fbx file for you
is it possible to enable some CCW flag on dnewtonmesh?, i think that would solve the problem(because collision works only if you hit the edges or if you collide under the ground, even in demossandbox you can only see the road if you are below the ground
Attachments
test.rar
fbx file
(39.88 KiB) Downloaded 204 times
e3dalive
 
Posts: 87
Joined: Thu Feb 05, 2015 5:20 am

Re: dNewtonCollisionMesh problem

Postby e3dalive » Fri Feb 06, 2015 12:05 pm

i also created serialised file of only that mesh for you
hopefully that will help
Attachments
scene.rar
(25.07 KiB) Downloaded 192 times
e3dalive
 
Posts: 87
Joined: Thu Feb 05, 2015 5:20 am

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Fri Feb 06, 2015 12:06 pm

On your secudn question
e3dalive wrote:i also have another question, does newton have "collision tolerance" value similar to havok/bullet?
i figured the possible reason for the problem, it's clockwise polygons
on road they are inverted, so if i disable plane underneath the road the geometry falls right though road, is it possible to enable some CCW flag on newtonmesh, so it would enable polygons from both sides?
when i put boxes on the edges it work, between edges it fall through


I suspect that that is the problem too, but I do not see the roads upside down when I remove the auxiliary AI meshes in Max.
Newton does not have any flag to make collision to make double side polygon,
a double side polygon will make the collision system yield unpredictable results.
Are you placing another polygon underneath Neath the road, facing up or facing down?
that will certainly cause the kind of Bug that I see in the video.

the last question, Newton does no have use controllable collision tolerances, there is a collision thickness by the is a values limited to 1/32 of a unit. and it is used for lithe gain in performance
no for correctness. Basically the collision system what you see is what you get.
I would no worry about collision tolerance I am more than 99% sure that's no the bug.
More like there are some double faces some where in that mesh.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby e3dalive » Fri Feb 06, 2015 12:17 pm

i've loaded last serialised scene of the faulty mesh into demos-sandbox, here is the video that clearly shows that mesh, exist from below the ground and doesn't exist from above, only the road part, the rest of the mesh is ok http://www.youtube.com/watch?v=tdO6CZvK ... e=youtu.be
e3dalive
 
Posts: 87
Joined: Thu Feb 05, 2015 5:20 am

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Fri Feb 06, 2015 12:17 pm

Yes it is confirmed 100%, the road is upside down.
when I open the scene.bin in the sand box, and I select show solid collision from the menu
this is what it looks like
Untitled.png
Untitled.png (782.04 KiB) Viewed 6318 times


but what see form underneath the ground I can see the solid faces that make the road.
what I do not know is why the rod is upside down it does not look that way in Max when I select show back face cooling, are you doing it explicitly for some gam reason?
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby Julio Jerez » Fri Feb 06, 2015 12:22 pm

yes we found the same thing, the question is how the road become upside down?
are you making upside down explicitly?

you will ne to invert the winding when you make the road in Max or you model editor, newton does no support double faces
In Newton collsion system all shapes including polygon are consider to be convex hulls,
a polygon is one with zero volume, by adding a double face cause lot of extra complexity.
Julio Jerez
Moderator
Moderator
 
Posts: 11039
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: dNewtonCollisionMesh problem

Postby e3dalive » Fri Feb 06, 2015 12:28 pm

i'm getting data from assimp loader, then i transform it with editor matrix(pos,rot,scale) from level editor, then i feed it to newton
i will try the winding, thank you, is it possible to feed dNewtonmesh normals directly?
but it's still very strange that when i send box from above the ground it lags and road sends it into space :D
e3dalive
 
Posts: 87
Joined: Thu Feb 05, 2015 5:20 am

Next

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 1 guest

cron