Animating hillplane/terrain .. mesh locked ? Strategy wrong?
Posted: Sun Mar 16, 2008 11:45 pm
addHillPlaneMesh creates a Node where I am not able to access/animate the underlying mesh.
My main aim is that I just want to generate a terrain/hillplane where i can randomly animate the hills heights using the vertex indices.
Obviously I progressed to get things right, but I have trouble to access the underlying mesh object.
When creating in main.cpp
and inside the animateNode() method of the animator class I am getting 0 values for the underlying mesh:
meshBufferCount = 0, Mesh[0] = 0
?? Does hillplane not generate a real Mesh ?
After some debugging, I also attached an animatedmeshscenenode to the animator and found that modification with
does not work.
Any help would be highly appreciated !
Thx,
Murat
My main aim is that I just want to generate a terrain/hillplane where i can randomly animate the hills heights using the vertex indices.
Obviously I progressed to get things right, but I have trouble to access the underlying mesh object.
When creating in main.cpp
Code: Select all
scene::IMesh *mesh = engine.scene->addHillPlaneMesh( (const irr::c8 *) "myHill_spikes",
a,
b,
0,
0,
c,
d
);
IMeshSceneNode *hill = engine.scene->addMeshSceneNode(mesh);
core::vector3df position( .0f, -30.0f, .0f );
hill->setPosition( position );
hill->setMaterialTexture( 0, engine.driver->getTexture( engine.medium( "sprite--bubble-shining_big.jpg" ) ) );
irrlicht_node_animator_meshplane_spikes *anim_meshplane_spikes = new irrlicht_node_animator_meshplane_spikes( engine, engine.device->getTimer()->getTime() );
hill->addAnimator( anim_meshplane_spikes );
meshBufferCount = 0, Mesh[0] = 0
?? Does hillplane not generate a real Mesh ?
Code: Select all
void
animateNode( scene::ISceneNode *node, u32 timeMs)
{
IMesh *mesh = ( ( irr::scene::IMeshSceneNode *) node)->getMesh();
u32 meshBufferCount = mesh->getMeshBufferCount();
for (u32 b=0; b<meshBufferCount; ++b)
{
const u32 vtxCnt = mesh->getMeshBuffer(b)->getVertexCount();
CERR
<< "ANIMATING MESH with vertexcount = "
<< vtxCnt
<< " and vertextype = "
<< mesh->getMeshBuffer(b)->getVertexType()
<< " [while video::EVT_STANDARD = "
<< video::EVT_STANDARD
<< " ] "
<< endl;
switch(mesh->getMeshBuffer(b)->getVertexType())
{
case video::EVT_STANDARD:
CERR << "EVT_STANDARD FOUND" << endl;
{
video::S3DVertex* v = (video::S3DVertex*) mesh->getMeshBuffer(b)->getVertices();
for (u32 i=0; i<vtxCnt; ++i)
{
if( i == 10 )
CERR
<< "spiking vertex["
<< i
<< "] = ( "
<< v[i].Pos.X
<< ", "
<< v[i].Pos.Y
<< ", "
<< v[i].Pos.Z
<< " )"
<< endl;
v[i].Pos.X += 1;
}
}
break;
case video::EVT_2TCOORDS:
CERR << "EVT_2TCOORDS FOUND" << endl;
{
...
engine.scene->getMeshManipulator()->recalculateNormals(mesh);
return;
}
After some debugging, I also attached an animatedmeshscenenode to the animator and found that modification with
Code: Select all
v[i].Pos.X += 1;
Any help would be highly appreciated !
Thx,
Murat