Drawing collision primitives

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Drawing collision primitives

Postby Colin » Sat Mar 14, 2015 8:31 pm

Hi,

Does Newton have any function for drawing collision primitives? I have looked around the codebase and the wiki, but all I could find was code adding triangles to a user-defined mesh. I want to be able to populate a VAO and draw the primitives as accurately as possible.

It would be easy to simply load an external 3d model and draw it as such, but any difference between the loaded model and the actual collision shape would make things more difficult down the road, when trying to figure out why things aren't working properly. ;)

I know that with Bullet, the user simply overrides a drawLine() function, but I'd rather use Newton. If such a feature is not a core part of the library, could Julio pretty please implement it?

Thanks!
Colin
Colin
 
Posts: 12
Joined: Tue Dec 16, 2014 3:26 am

Re: Drawing collision primitives

Postby Julio Jerez » Sat Mar 14, 2015 11:47 pm

function
void NewtonCollisionForEachPolygonDo (const NewtonCollision* const collision, const dFloat* const matrix, NewtonCollisionIterator callback, void* const userData);

for an example look at function
void DebugShowBodyCollision (const NewtonBody* const body, DEBUG_DRAW_MODE mode)

in file ../dynamics\applications\demosSandbox\sdkDemos\toolBox\DebugDisplay.cpp
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Drawing collision primitives

Postby Colin » Sun Mar 15, 2015 12:23 am

Cool, thanks!

I have gone to my favourite bar and was poring over the API while waiting to chat up the attractive lady serving beer. We've caught each other'e eye and I need a girlfriend :P

As soon as the night was done, I came home and experimented with the mesh functions exposed via Newton.h.

Thus far, I can confirm that an end-user can create a primitive collision shape via the builtin functions (NewtonCreateSphere, in my case), and then use:

NewtonCreateMeshFromCollision()
NewtonMeshTriangulate()
NewtonMeshGetTotalFaceCount()
NewtonMeshGetTotalIndexCount()
NewtonMeshGetPointCount()
NewtonMeshGetPointStrideInByte()

to gather information about it. Pretty intense. :)

For reasons of maximum portability, I wish to reserve my programming to the Newton.h core API; I should have a working solution by tomorrow. Once done, it would be a pleasure to contribute a cookbook-style recipe for populating and drawing a VAO from a Newton mesh. We need more quality documentation in order to bring in new users and I am an excellent writer :D


Colin
Colin
 
Posts: 12
Joined: Tue Dec 16, 2014 3:26 am

Re: Drawing collision primitives

Postby Colin » Sun Mar 15, 2015 10:43 pm

UPDATE: I am diligently working on upgrading the debug drawing code to modern OpenGL. When finished, I will be showing you the results. It is my hope that someone may find it useful. Currently managed to create a vertex buffer and an index buffer in a general, reusable manner. Current task is to wrap in a proper C++ class and using nice & tidy RAII semantics.

QUESTION FOR JULIO: In the debug draw example, the face normals are calculated prior to rendering. I have no experience with immediate mode as I only started OpenGL recently; is there any good reason anymore to keep such information on-hand for a debug draw session or is that a relic of the immediate-mode era?

Thanks!
Colin
 
Posts: 12
Joined: Tue Dec 16, 2014 3:26 am

Re: Drawing collision primitives

Postby Julio Jerez » Sun Mar 15, 2015 10:46 pm

if you are using the Newton Mesh, there are function for calculating the normal.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Drawing collision primitives

Postby Colin » Sun Mar 15, 2015 10:56 pm

I thought it was the case, but wanted to confirm. Thanks!
Colin
 
Posts: 12
Joined: Tue Dec 16, 2014 3:26 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests