visualizing and rescaling nxs files

NazguL86

06-04-2010 01:06:34

Is there a way to visualize the loaded .nxs file on OGRE ?
To explain briefly I created a model with blender and then exported into .mesh and .nxs. The problem is that the .nxs model seems not working properly - meaning that for example shooting objects on it, they don't bounce back or they bounce back in a wrong way. I suppose that this is due to a wrong position of the .nxs model with respect to the mesh model, the pivot of the mesh is centered, and so this should not be the problem - if I could visualize how it is positioned it would be very easy to understand the problem.

Another question is about rescaling a .nxs (convex or triangle) file - is it possible?
Meaning that for example loading a :

NxOgre::Mesh* triangleMesh = NxOgre::MeshManager::getSingleton()->load("media:Barrel.nxs");
OGRE3DBody* convexBody = mRenderSystem->createBody(triangle, NxOgre::Vec3(0, 0, 0), "Barrel.mesh");
convexBody->getSceneNode()->scale(0.15,0.15,0.15);

How could I resize the Barrel.nxs file directly from the code ?

Thrakbad

06-04-2010 15:50:00

For visualizing, use the visual debugger. It is explained in one of the tutorials.
I don't know if you can easily scale a mesh, but you could at least read the mesh data from the nxs file, manually multiply the vertex positions by the scale factors and create a new mesh from this new data.

betajaen

06-04-2010 16:08:05

If your in NxOgre, you can grab a copy of the MeshData (this is a fairly intensive function, so don't do lots of times in mid-frame).

Roughly (in Detritus):

// Grab a copy of the vertices/triangles/etc from the original.
MeshData* data = mesh->getMeshData();

// Do the scaling.
for (unsigned int i=0;i < data->mVertices.size();i+=3)
{
data->mVertices[i] *= factor
data->mVertices[i+1] *= factor
data->mVertices[i+2] *= factor
}

// Create a resource to cook to.
Resource* resource = ResourceSystem::getSingleton()->open("memory://", Enums::ResourceAccess_ReadAndWrite);

// Cook.
data->cook(resource);

// Rewind!
resource->seekBeginning();

// Load it in.
Mesh* modifiedMesh = MeshManager::getSingleton()->load(resource, "MyModifiedMesh");

// Done with the resource now.
ResourceSystem::getSingleton()->close(resource);

// Delete the data.
delete data;

betajaen

06-04-2010 16:25:47

I've just added a "feature" and a few functions to make it a bit easier.

ManualMesh m(myMesh->getMeshData());
for (unsigned int i=0;i < m.nbVertices();i++)
m.scaleVertex(i, Vec3(2,2,2) );
Mesh* myNewScaledMesh = m.end();


It's in the Detritus branch. The commit be up in a few days, but there are other "changes" that haven't been mass tested yet - your decision.

NazguL86

06-04-2010 18:19:28

Thank you, I'll try that. About the visual debugger - wasn't it disabled in the last NxOgre version ?

edit: ok found out the solution here ;) - https://www.ogre3d.org/addonforums/view ... 0&start=15