A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Colin » Wed Mar 18, 2015 9:38 pm
Hi,
I am continuing my work on drawing proper meshes in modernGL, but I am a little bit stumped as to how this function works:
NEWTON_API void NewtonMeshCalculateVertexNormals(const NewtonMesh* const mesh, dFloat angleInRadians);
When I pass my mesh and the cutoff angle into this function, where do I retrieve the list of normals? The mesh argument is marked const and there is no return value. Any tips?
Thanks,
Colin
-
Colin
-
- Posts: 12
- Joined: Tue Dec 16, 2014 3:26 am
by Julio Jerez » Wed Mar 18, 2015 9:48 pm
look at file
../newton-dynamics\packages\dScene\dSceneStdafx.cpp
void SerializeMesh (const NewtonMesh* const mesh, TiXmlElement* const rootNode);
it serializes a mean to an xml file, you can see how it read data from the mesh using
- Code: Select all
int pointCount = NewtonMeshGetPointCount (mesh);
int pointStride = NewtonMeshGetPointStrideInByte(mesh) / sizeof (dFloat64);
const dFloat64* const normals = NewtonMeshGetNormalArray(mesh);
int* const normalIndexList = new int [pointCount];
for (int i = 0; i < pointCount; i ++) {
packVertex[i * 3 + 0] = dFloat(normals[i * pointStride + 0]);
packVertex[i * 3 + 1] = dFloat(normals[i * pointStride + 1]);
packVertex[i * 3 + 2] = dFloat(normals[i * pointStride + 2]);
}
int count = dPackVertexArray (packVertex, 3, 3 * sizeof (dFloat), pointCount, normalIndexList);
the meshe has interface to get per vertex and per faces normal. the above code is per vertex.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Colin » Thu Mar 19, 2015 4:38 am
Thanks! This file is a goldmine.
-
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 1 guest