Primitives

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Primitives

Postby Firefly » Wed Aug 06, 2008 4:09 am

What is the best and simplest way to texture the newton convex primitives?

In my project we need to able to place simple objects such as crates and barrels. At the moment I'm simply creating them using NewtonCreateBox and NewtonCreateCylinder and that's working fine when drawing the debug lines. I need now to be able to texture these primitives.. is there nice way of doing this with Newton, like am I able to get the require information to apply textures correctly?
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am

Re: Primitives

Postby JernejL » Wed Aug 06, 2008 7:26 am

Usually the actually displayed models are stored and drawn separate from debug lines, where 3d modelers create and texture these models, then you just draw them at the matrices that you get in transform callback.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Primitives

Postby Firefly » Wed Aug 06, 2008 8:39 am

Well I thought of doing it that way, but if I use a model then it'd have to be scaled to fit the collision mesh bounding. So I thought I could probably reduce loading in a model and skip any scaling and just render a primitive shape using the info from the collision mesh.

Or is there a better way for simple models, such as maybe using NewtonCreateConvexHull?
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am

Re: Primitives

Postby Julio Jerez » Wed Aug 06, 2008 8:47 am

the best way will be useing a NetwonMesh.
you can say
NewtonMesh* mesh = NewtonMeshFormCollision(collisionMesh);
and them apply a texture mode

or you can just make do
NewtonMesh* mesh = NewtonMesh();
and add faces with textures and normals.

then you can add face with texture, ot you can use some o fteh texture modes.
check the SDK for some samples of ow irt is used.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Primitives

Postby Firefly » Wed Aug 06, 2008 9:39 am

Ahhh ok thanks. That seems to be what I'm looking for. While I'm on the topic of meshes, seeing as you're working with Cal3D and I'm using both Cal3D and Newton in my project, what do you suggest is the best way to do the collisions with complex player models? At the moment I have the model encapsulated in a cylinder mesh which appears to work fairly well for now. But if I wanted more accurate collisions with the limbs, etc, what should I be doing? Do I just wait until the 2.0 beta comes out with cal3d support?

Another question a bit unrelated but figured i could just put it here instead of making a new post...

Is it possible to allow bodies to collide but not react physically. Eg. I want a player to be able to walk through an object, but still report that it has collided with the object. I need this for things like "capture zones" and the bounding boxes around items you can pick up.

Also, is there a file that documents the current functions in 2.0? It'd be nice to know what some of the newer functions do and how to use them.

Thanks mate :)
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am

Re: Primitives

Postby agi_shi » Wed Aug 06, 2008 10:05 am

For notification of collisions, just override the contact callback (or the aabb overlap callback) to get notified of the collision, and then reject the contacts (make sure to NewtonWorldCriticalSectionLock/Unlock when deleting the contacts) in the contact callback or just return false on the aabb overlap callback.
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: Primitives

Postby Firefly » Sun Aug 10, 2008 1:33 am

Is there an easier way to get the mesh data into a form suitable for DirectX Vertex and Index buffers?

In the SDK example it's building segments which each have a set of indices and a texture ID for the material on this segment. The problem is that with directx index buffers you need to pass the indices as one array when setting up the buffer, and when rendering you need to specify the starting index, index count, and number of primitives.

So seeing as the indices are split up into each segment this isn't possible, and I'm not sure if I can just combine them all into one array.

I've thought about using dynamics buffers, but I still need to know how many vertices and primitives there are in a segment :/

Has anyone been able to achieve this sort of thing using directx VB and IB buffers?


EDIT: Nevermind I worked out a solution.

Cheers
Firefly
 
Posts: 32
Joined: Wed Jan 17, 2007 4:58 am

Re: Primitives

Postby Julio Jerez » Sun Aug 10, 2008 8:54 am

for each NewtonMesh you get one berte boufer. Then you get one index buffer per material.
you can concatenated all of all index buffers into a single D3D indexbuffer since they all point to the same vertex buffer,
Just keep track of the start and coint of each sub index buffer.

then for rendering in D3D it comes down to one call to RenderPrimitive per sub index buffer. ATR klest thei is how I remember D3d.
I do not see what teh major problem is?


if you one to parcking more than one NetwonMesh, you can easslly place many Newton Mesh into on single index buffee Vertex and vertex Buffer.
you will neet to kept track ot of the begginning and count of each vertex buffer and index buffer for each mesh.
so when you concatenate index buffer, you add to each index in teh index buffer the offset into the vertex buffer for that particular mesh. The is not problem either,
If you are using this method and you cannot see how to do it I can post code to show how.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 15 guests