Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 07 April 2005 - 06:33 PM
Posted 07 April 2005 - 08:48 PM
Posted 08 April 2005 - 12:06 AM
Posted 08 April 2005 - 12:33 AM
Quote:
Original post by meo
Maybe something you already have thought of.
But you can calculate the bounding box of your mesh and
use the volume of bouding box to set your mass.
This won't be as accurate but is a lot more easy to do.
Posted 08 April 2005 - 12:41 AM
Quote:
Original post by Daerax
Yes, but it is not worthwhile to do so unless you really must. Also can you explain why you are using you ship's volume for its mass? That doesnt make much sense. Why not just give the ship a mass?
Posted 08 April 2005 - 04:57 AM
Quote:
Original post by johnnyBravo Quote:
Original post by Daerax
Yes, but it is not worthwhile to do so unless you really must. Also can you explain why you are using you ship's volume for its mass? That doesnt make much sense. Why not just give the ship a mass?
I thought it would be nice to give a ship a unique mass, depending on how big it is. I would just calculate the mass once for each ship type.
Posted 08 April 2005 - 10:31 AM
Quote:
Original post by johnnyBravo Quote:
Original post by Daerax
Yes, but it is not worthwhile to do so unless you really must. Also can you explain why you are using you ship's volume for its mass? That doesnt make much sense. Why not just give the ship a mass?
I thought it would be nice to give a ship a unique mass, depending on how big it is. I would just calculate the mass once for each ship type.
D3DXVECTOR3 dimension_vector, pMin, pMax;
D3DXComputeBoundingBox(.., &pMin, &pMax)
dimension_vector = pMax - pMin;
float volume = dimension_vector.x*dimension_vector.y*dimension_vector.z;
Posted 10 April 2005 - 02:39 PM
Quote:
if it's for a game, you'd be better of to make it up. Then you can tweak the gameplay as you wish (add more mass since the ship is more powerful than expected, ect...).
Posted 11 April 2005 - 10:41 AM
Posted 12 April 2005 - 09:20 AM
Posted 12 April 2005 - 01:42 PM
Posted 12 April 2005 - 03:53 PM
Quote:
Original post by johnnyBravo
Hi, say I've got a mesh, which is my spaceship constructed out of a trianglelist of triangles. ie 3 vertices for each triangle.
Is there someway I can calculate the volume inside my spaceship?
I want to do this so I can use the volume as the mass of the ship.
Thanks
float volume = 0;
int* index = I;
for (i = 0; i < T; i++)
{
Vector3 v0 = V[*index++];
Vector3 v1 = V[*index++];
Vector3 v2 = V[*index++];
volume += Dot(v0,Cross(v1,v2));
}
volume /= 6;
Posted 12 April 2005 - 06:10 PM
Quote:
Original post by Dave Eberly Quote:
Original post by johnnyBravo
Hi, say I've got a mesh, which is my spaceship constructed out of a trianglelist of triangles. ie 3 vertices for each triangle.
Is there someway I can calculate the volume inside my spaceship?
I want to do this so I can use the volume as the mass of the ship.
Thanks
Suppose you have a vertex array V[] of N vertices. The triangle list is an array I[] of 3*T indices into the vertex array and represents T triangles. Suppose the mesh is closed, each edge is shared by two triangles, and the mesh is not self-intersecting ("water tight" in the vernacular). Also assume that the triangles are counterclockwise oriented as viewed by an observer outside the mesh. Finally, assume that the mass density is constant (1). If nonconstant, the problem is much more difficult.
float volume = 0;
int* index = I;
for (i = 0; i < T; i++)
{
Vector3 v0 = V[*index++];
Vector3 v1 = V[*index++];
Vector3 v2 = V[*index++];
volume += Dot(v0,Cross(v1,v2));
}
volume /= 6;
Quote:
Have you considered using Gauss' Theorem?
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.