horde3d / Horde3D

Horde3D is a small 3D rendering and animation engine. It is written in an effort to create an engine being as lightweight and conceptually clean as possible.
http://horde3d.org/
1.55k stars 308 forks source link

Set position of individual vertex? #121

Closed midn1 closed 6 years ago

midn1 commented 6 years ago

Planning on using soft bodies on Bullet, and I couldn't find any public function that would help me on this.

algts commented 6 years ago

Hello. You should probably take a look at this example, it shows how to tie bullet to Horde3D. https://github.com/algts/Horde3DPhysics

Basically, it is done somewhat like that:

geoResource = h3dGetNodeParamI(h3dGetNodeParent(m_hordeID), H3DModel::GeoResI);
numVertices = h3dGetNodeParamI(m_hordeID, H3DMesh::VertREndI) - h3dGetNodeParamI(m_hordeID, H3DMesh::VertRStartI) + 1;
numTriangleIndices = h3dGetNodeParamI(m_hordeID, H3DMesh::BatchCountI);     
vertRStart = h3dGetNodeParamI(m_hordeID, H3DMesh::VertRStartI);
vertexOffset = vertRStart * 3;
indexOffset = h3dGetNodeParamI(m_hordeID, H3DMesh::BatchStartI);

float* vertexBase = (float*) h3dMapResStream(geoResource, H3DGeoRes::GeometryElem, 0, H3DGeoRes::GeoVertPosStream, true, false);
midn1 commented 6 years ago

As I understand, the float array consists of all the vertices, so every 3 floats is a new vertex?

algts commented 6 years ago

Yes. Please note that geometry resource may contain vertex data for the whole scene. not just one mesh. That's exactly why vertRStart parameter is needed.

midn1 commented 6 years ago

Thank you very much, not sure if this is even a good place to ask questions like these, but my forum account hasn't been activated for around 2 months, so this seemed like the next best spot.

horde3d commented 6 years ago

Sorry, should be activated now

midn1 commented 6 years ago

Thanks!