TreeCollision, for some reason evil!

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

TreeCollision, for some reason evil!

Postby Henry00 » Mon Aug 08, 2011 6:11 pm

Hello everyone, I guess you start liking me already.

So here I was, perfect debug display, perfect physics, perfect rotations and locations that I thought, hey let's make the map have some collision!
First, I create the TreeCollision, I call the beginTreeCollision procedure, start adding faces to it, and at ending I get a memory error ( oh I love those.. )

The source code for the maps is a little large, ( Unreal t3d map importer )

First, before file loading:

Code: Select all
  *map_collision = NewtonCreateTreeCollision( *NewtonWorld, 0 )
  NewtonTreeCollisionBeginBuild( *map_collision )


Then while the map is loading, from time to time add 3 vertexes:

Code: Select all
Dim vertexes.f(8)
vertexes(0) = next_t3d_surface\VertexPoints(1+i)\x
vertexes(1) = next_t3d_surface\VertexPoints(1+i)\y
vertexes(2) = next_t3d_surface\VertexPoints(1+i)\z
vertexes(3) = next_t3d_surface\VertexPoints(0)\x
vertexes(4) = next_t3d_surface\VertexPoints(0)\y
vertexes(5) = next_t3d_surface\VertexPoints(0)\z
vertexes(6) = next_t3d_surface\VertexPoints(2+i)\x
vertexes(7) = next_t3d_surface\VertexPoints(2+i)\y
vertexes(8) = next_t3d_surface\VertexPoints(2+i)\z
NewtonTreeCollisionAddFace( *map_collision, 9, @vertexes(), 12, 0 ) // I tried multiple 12, 24, 36 ( which hangs the application ) etc.


Then when the file was loaded, we close the file and want to finish up:

Code: Select all
NewtonTreeCollisionEndBuild( *map_collision, 0 ) // KABOOMM!!!!! Tried 0 and 1


It just fails hard with an exception here, any idea what I might be doing wrong?
Thanks!

FIXED IT!!

1 vertex = 3 floats, I told it I had 9 vertices but I only had 3 , with 3 values each and the array only contained enough info for 3 vertices, to think noone including me noticed..

Image
Last edited by Henry00 on Tue Aug 09, 2011 3:39 pm, edited 2 times in total.
00Laboratories
Solutions for Developers
http://00laboratories.com/
Henry00
 
Posts: 37
Joined: Mon Aug 01, 2011 7:29 pm
Location: Germany

Re: TreeCollision, for some reason evil!

Postby JernejL » Tue Aug 09, 2011 5:38 am

Show us the trimesh data so we can look at what happens.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: TreeCollision, for some reason evil!

Postby Henry00 » Tue Aug 09, 2011 7:06 am

I don't exactly know what you mean with TriMesh data, but if you would like to see the file I am importing, it's like this:

http://henry00.ftpaccess.cc/henry00/projects/demo2.txt

Everytime those Vertex declarations come, that is a triangle fan, the resulting map will look like this:

Image

The loop that imports the triangle fan each time "end polygon" occurs with commented newton code at the moment:

Code: Select all
        For i=0 To next_t3d_surface\VertexPointsTotal -3

   ;       Dim vertexes.f(8)
   ;       vertexes(0) = next_t3d_surface\VertexPoints(1+i)\x
   ;       vertexes(1) = next_t3d_surface\VertexPoints(1+i)\y
   ;       vertexes(2) = next_t3d_surface\VertexPoints(1+i)\z
   ;       vertexes(3) = next_t3d_surface\VertexPoints(0)\x
    ;;      vertexes(4) = next_t3d_surface\VertexPoints(0)\y
    ;      vertexes(5) = next_t3d_surface\VertexPoints(0)\z
    ;;      vertexes(6) = next_t3d_surface\VertexPoints(2+i)\x
     ;     vertexes(7) = next_t3d_surface\VertexPoints(2+i)\y
     ;;     vertexes(8) = next_t3d_surface\VertexPoints(2+i)\z
      ;    NewtonTreeCollisionAddFace( *map_collision, 9, @vertexes(), 36, 0 )
         
            GenUV(next_t3d_surface,1+i,uv)
            Mesh_AddVertexBad(*polymesh,   next_t3d_surface\VertexPoints(1+i)\x, next_t3d_surface\VertexPoints(1+i)\y, next_t3d_surface\VertexPoints(1+i)\z,  next_t3d_surface\normal\x, next_t3d_surface\normal\y, next_t3d_surface\normal\z,   1,1,1,vertex_alpha   ,uv\x, uv\y )
            GenUV(next_t3d_surface,0,uv)
            Mesh_AddVertexBad(*polymesh,   next_t3d_surface\VertexPoints(0)\x,   next_t3d_surface\VertexPoints(0)\y,   next_t3d_surface\VertexPoints(0)\z,    next_t3d_surface\normal\x, next_t3d_surface\normal\y, next_t3d_surface\normal\z,   1,1,1,vertex_alpha   ,uv\x, uv\y )
            GenUV(next_t3d_surface,2+i,uv)
            Mesh_AddVertexBad(*polymesh,   next_t3d_surface\VertexPoints(2+i)\x, next_t3d_surface\VertexPoints(2+i)\y, next_t3d_surface\VertexPoints(2+i)\z,  next_t3d_surface\normal\x, next_t3d_surface\normal\y, next_t3d_surface\normal\z,   1,1,1,vertex_alpha   ,uv\x, uv\y )
           
        Next


Then at ending of the TreeCollision it will error
00Laboratories
Solutions for Developers
http://00laboratories.com/
Henry00
 
Posts: 37
Joined: Mon Aug 01, 2011 7:29 pm
Location: Germany

Re: TreeCollision, for some reason evil!

Postby Henry00 » Tue Aug 09, 2011 12:12 pm

Problem is fixed!
1 vertex = 3 floats, I told it I had 9 vertices but I only had 3 , with 3 values each and the array only contained enough info for 3 vertices, to think noone including me noticed..
00Laboratories
Solutions for Developers
http://00laboratories.com/
Henry00
 
Posts: 37
Joined: Mon Aug 01, 2011 7:29 pm
Location: Germany


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests