collision tree & Decals

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

collision tree & Decals

Postby mauro78 » Sun Mar 07, 2010 4:28 pm

Hi All!

Just a quick question: is it possible to access to collision tree data?

I mean, after a RayCast against the world I know a point of intersection P (eventually a normal) and a pickedbody B.

I need to access or perform a proximity query on a collision tree, couse I need to place "decal" on it ( based on the distance from the collision point P) .
I'm wondering If Newton 2.0 has some sort of helper function about that.

Thanks in advance

p.s.
I know that another solution is to keep a copy of triangles that compose the "collision tree" and do It by myself, but I really like the idea of using Newton API's if available.....
mauro78
 
Posts: 13
Joined: Mon Feb 16, 2009 5:40 pm

Re: collision tree & Decals

Postby JernejL » Sun Mar 07, 2010 5:27 pm

I believe NewtonTreeCollisionGetVertexListIndexListInAABB does that.

Julio can help explain what the parameters do, it's not yet documented on the wiki.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: collision tree & Decals

Postby mauro78 » Mon Mar 08, 2010 4:17 am

Delfi wrote:I believe NewtonTreeCollisionGetVertexListIndexListInAABB does that.

Julio can help explain what the parameters do, it's not yet documented on the wiki.

Thank you Delfi...sounds good...I hope Julio has more information about that...

Regards
mauro78
 
Posts: 13
Joined: Mon Feb 16, 2009 5:40 pm

Re: collision tree & Decals

Postby mauro78 » Mon Mar 08, 2010 4:57 am

Delfi wrote:I believe NewtonTreeCollisionGetVertexListIndexListInAABB does that.

Julio can help explain what the parameters do, it's not yet documented on the wiki.


Code: Select all
NewtonCollision* collision = NewtonBodyGetCollision(pickedBody);
dVector p0, p1;
dVector p(pickedPoint.x,pickedPoint.y,pickedPoint.z);
p1 = p + dVector(2,2,2);
p0 = p + dVector(-2,-2,-2);
            
const dFloat* vertexList; // Call sets this to point to the array
int vertexCount; // Returned number of vertices
int vertexStrideInBytes; // Returned
int indexList[256]; // Array of indices - this is set by the call
int attributeList[256/3]; // Array of face attributes - set by call
int numFaces;
numFaces = NewtonTreeCollisionGetVertexListIndexListInAABB (collision, &p0[0], &p1[0], &vertexList, &vertexCount, &vertexStrideInBytes, &indexList[0],    256,    attributeList);
Decal* pDecal = new Decal(this->m_d3d9Device,camera);
pDecal->Init((float*)vertexList,vertexCount,&indexList[0],numFaces);
g_DecalsList.push_back(pDecal);


It works fairly well; the only problem is that (correct me if I'm wrong) collision meshes are different from geometric meshes...so there's not a 1:1 corrispondence between mesh triangles and newton stored triangles right?
mauro78
 
Posts: 13
Joined: Mon Feb 16, 2009 5:40 pm

Re: collision tree & Decals

Postby kallaspriit » Mon Mar 08, 2010 5:41 pm

You can try disabling collision tree optimizations, then they should match exactly.
kallaspriit
 
Posts: 216
Joined: Sun Aug 14, 2005 6:31 pm

Re: collision tree & Decals

Postby mauro78 » Tue Mar 09, 2010 1:47 pm

kallaspriit wrote:You can try disabling collision tree optimizations, then they should match exactly.

Thank you for suggestion, It's a lot better.
regards
mauro78
 
Posts: 13
Joined: Mon Feb 16, 2009 5:40 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron