Rescale nxs NxOgre::Mesh [Answered]

deshan

23-12-2009 08:18:07

Hi
I have set of trees on terrain which i placing them with random scale value. I want to rescale tree.nxs accordingly.
Is that possible to use meshdata to rescale the NxOgre::Mesh?

NxOgre::Mesh* treeMeshNxs = NxOgre::MeshManager::getSingleton()->load("media:artilaryGun.nxs");
// scaling goes here // treeMeshNxs->getMeshData()->?
NxOgre::TriangleGeometry* treeGeometry = new NxOgre::TriangleGeometry(treeMeshNxs);
mScene->createSceneGeometry(treeGeometry , NxOgre::Matrix44(NxOgre::Vec3(*iterator)));


If scaling is not random or few number of trees I can use meshmagic and flour.

betajaen

23-12-2009 10:22:06

You'd have to turn the Mesh into a ManualMesh, then for each tree that is different you'd have to rescale it manually, then cook it, then load it in.

Silly, I know but PhysX is like that.

deshan

23-12-2009 11:30:28

Hi betajaen
Thank you for the answer. Does it like following?

treeMeshNxs->getMeshData()->mVertices
// compare and resize
for (int i=0; i < Ogre::mesh->getNumSubMeshes();i++)
{

Ogre::SubMesh* submesh = Ogre::mesh->getSubMesh(i);
Ogre::VertexData* vd = submesh->vertexData;

for(int j = 0; j < vd->vertexCount; ++j)
{
// compare and resize
}
}


if yes can this leads to performace reduction? I hope you won't recomend this method unless i really want. :D
And can't I use the libFlour for this with bloodymess. I have tried it but looks like really outdated.

Thank You again for your support

betajaen

23-12-2009 12:07:40

Basically, yes. In your first for loop would be the NxOgre::ManualMesh for each tree you want scaled, and then in the second loop you'd copy the scaled vertices over.

It's a pain and a massive performance hog, but PhysX convex meshes can't be changed during runtime. The only other way is to "decompile" it, change it what you want, then cook it again under a different mesh.

deshan

24-12-2009 03:18:33

It's a pain and a massive performance hog, but PhysX convex meshes can't be changed during runtime. The only other way is to "decompile" it, change it what you want, then cook it again under a different mesh

hmm I can understand. I would try that.
Thanx for your help betajaen.