A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by TSX » Wed Jan 12, 2011 4:49 pm
Hi all! I'm writing an editor for my game physics, and I need to re-create convex hull collision from previously saved vertex cloud (custom de/serialization to own format).
So, I call NewtonCollisionGetInfo() to get vertex cloud and creation params (vertex count, face count, stride) from a convex.
But when I create new convex with these params, vertex cloud is simplificated, so I get incorrect result even if 'tolerance' parameter is zero.
Is there any way to create new convex without internal simplification? I'm using Newton 2.29.Thanks.
Last edited by
TSX on Thu Jan 13, 2011 11:31 am, edited 1 time in total.
-
TSX
-
- Posts: 5
- Joined: Wed Jan 12, 2011 2:15 pm
- Location: Moscow, Russia
by Julio Jerez » Wed Jan 12, 2011 5:38 pm
If Parameter tolerance is zero, the convex will use all point in convex surface and it will gerenate a absulte perfec hull.
When I say perfect I mean absolute exact hulls.
if it does not do that it is a bug, but I never see that before. can you post and image?
It may be possible that the conveHull shape made modifications to the exact hull to remove edges that are flat,
has you tryed the MeshCreateConvexHull.
MeshCreateConvexHull always generates exact hulls with no interrnal simplifications.
It is also faster if you are using it in and editor.
CollisionConvex Hull call Mesh CreateConvexHull and then conveted it to the collision format which is a double conected edge list.
Then it try to optimized for collision by removing as many edges that are complanar, by it does not touch vertex list.
can you show me the code you are using fo this?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by TSX » Thu Jan 13, 2011 5:13 am
Hi, Julio!
Тhis is a convex built from model (low-poly building).

I save convex data to TCFConvex class:
- Code: Select all
function TNewtonCollisionFile.AddConvexIndirect(
const pSrc: PNewtonCollision): TCFConvex;
var param: TNewtonCollisionInfoRecord;
i: integer;
begin
Result := nil;
NewtonCollisionGetInfo(pSrc, @param);
if param.m_collisionType = SERIALIZE_ID_CONVEXHULL then begin
Result := TCFConvex.Create(Self);
with Result do begin
m_Vertices := param.shapedataconvexhull.m_vertexCount;
m_Stride := param.shapedataconvexhull.m_vertexStrideInBytes;
m_Faces := param.shapedataconvexhull.m_faceCount;
setLength(pData, m_Vertices*(m_Stride div sizeOf(single)));
for i := 0 to pred(m_Vertices) do
pData[i] := TCFSingleStride(param.shapedataconvexhull.m_vertex)[i];
end;
end;
end;
where pData is TCFSingleStride (array of single), I'm using single-precision x86 Windows version of newton.dll.
Then I write this extracted data to a file.
When I load saved file from disk, I read m_Vertices, m_Stride, m_Faces and vertex cloud, then I create convex using
- Code: Select all
NewtonCreateConvexHull(pWorld, m_Vertices, @pData[0], m_Stride, 0, 0, @m[0][0]);
And I get this result:

Maybe I'm doing something wrong?
P.S. I've tried to create convex through temporary mesh:
- Code: Select all
pMesh := NewtonMeshConvexHull(pWorld, m_Vertices, @pData[0], m_Stride, 0);
Result := NewtonCreateConvexHullFromMesh(pWorld, pMesh, 0, 0);
NewtonMeshDestroy(pMesh);
but still got result shown in a second picture...

-
TSX
-
- Posts: 5
- Joined: Wed Jan 12, 2011 2:15 pm
- Location: Moscow, Russia
by Julio Jerez » Thu Jan 13, 2011 9:47 am
But in the secund image the convex is completly wrong.
that is not a simplication problem that is a big Bug.
you have to have a bug in the function that get the vertices count from get Info.
can you post here a test file with the mesh, or the mesh file so tah I can check that out?
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by TSX » Thu Jan 13, 2011 11:29 am
I've found an error, that was my mistake

I forgot to multiply vertexCount... So only first vertexCount of floats were written to dump.
Thanks for answers, Julio.

-
TSX
-
- Posts: 5
- Joined: Wed Jan 12, 2011 2:15 pm
- Location: Moscow, Russia
by Julio Jerez » Thu Jan 13, 2011 3:48 pm
Oh cool, I have a question, I saw the image and it look very cool.
My question is how do you make you Toobar buttons?
I am having a hard time trying to make cool looking one for the Official newton Editor.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by TSX » Thu Jan 13, 2011 4:00 pm
I draw some icons manually, some (move, rotate, scale) were taken from Unreal Editor.
-
TSX
-
- Posts: 5
- Joined: Wed Jan 12, 2011 2:15 pm
- Location: Moscow, Russia
by Julio Jerez » Wed Feb 16, 2011 2:28 pm
Hi TSX I just want to let you know that now that newton is Open source
you can in fact make the convex hulls directly using the Geometric Class that the engine uses and bypass all the simplications that the physics engine apply to the final result
here is the class:
- Code: Select all
class dgConvexHull3d: public dgList<dgConvexHull3DFace>
{
public:
dgConvexHull3d(dgMemoryAllocator* const allocator, const dgFloat32* const vertexCloud, dgInt32 strideInBytes, dgInt32 count, dgFloat32 distTol);
virtual ~dgConvexHull3d();
dgInt32 GetVertexCount() const;
const dgVector* GetVertexPool() const;
const dgVector& GetVertex(dgInt32 i) const;
}
basically it makes an absolutly perfect convex hull from the vertex cloud, it is by far more accurate and much faster than QHull,
and all of the utilities that are around, this is because Newton does not quantize the values like QHull does.
I hope this is what you wanted and I could not give you an answer before.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by TSX » Thu Feb 24, 2011 4:33 pm
Hi, Julio!
I think this is really cool that Newton is OpenSource now
And thanks for your answer about convex

-
TSX
-
- Posts: 5
- Joined: Wed Jan 12, 2011 2:15 pm
- Location: Moscow, Russia
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 2 guests