Well, it isn't so much a custom scene node as a class, but it's a mesh which is then put into a animated scene node, which is then fed into the triangle selector. The mesh is created as shown below (this is most likely the source of the problem):
Code: Select all
FastNoise tNoise; // Create a FastNoise object
tNoise.SetNoiseType(FastNoise::SimplexFractal); // Set the desired noise type
tNoise.SetFrequency(0.004);
tNoise.SetFractalOctaves(6);
tNoise.SetFractalLacunarity(2.0);
tNoise.SetFractalGain(0.5);
tNoise.SetFractalType(FastNoise::Billow);
SMesh* Mesh = new SMesh();
SMeshBuffer *buf = 0;
buf = new SMeshBuffer();
Mesh->addMeshBuffer(buf);
buf->drop();
int vCount = bSize*bSize*6;
buf->Vertices.reallocate(vCount);
buf->Vertices.set_used(vCount);
int i = 0;
for (int z=0; z<bSize; ++z)
{
for (int x=0; x<bSize; ++x)
{
buf->Vertices[i] = S3DVertex(nrX+x*scale*2,1000+tNoise.GetNoise(nrX/scale/2+x,nrZ/scale/2+z)*100,nrZ+z*scale*2, 0,90,0, SColor(255,255,0,255), 0, 0);
buf->Vertices[i+1] = S3DVertex(nrX+(x+1)*scale*2,1000+tNoise.GetNoise(nrX/scale/2+x+1,nrZ/scale/2+z)*100,nrZ+z*scale*2, 0,90,0, SColor(255,0,255,255), 0, 0);
buf->Vertices[i+2] = S3DVertex(nrX+x*scale*2,1000+tNoise.GetNoise(nrX/scale/2+x,nrZ/scale/2+z+1)*100,nrZ+(z+1)*scale*2, 0,90,0, SColor(255,255,0,255), 0, 0);
buf->Vertices[i+3] = S3DVertex(nrX+(x+1)*scale*2,1000+tNoise.GetNoise(nrX/scale/2+x+1,nrZ/scale/2+z+1)*100,nrZ+(z+1)*scale*2, 0,90,0, SColor(255,0,255,255), 0, 0);
buf->Vertices[i+4] = S3DVertex(nrX+x*scale*2,1000+tNoise.GetNoise(nrX/scale/2+x,nrZ/scale/2+z+1)*100,nrZ+(z+1)*scale*2, 0,90,0, SColor(255,0,255,255), 0, 0);
buf->Vertices[i+5] = S3DVertex(nrX+(x+1)*scale*2,1000+tNoise.GetNoise(nrX/scale/2+x+1,nrZ/scale/2+z)*100,nrZ+z*scale*2, 0,90,0, SColor(255,255,0,255), 0, 0);
i+=6;
}
}
buf->Indices.reallocate(vCount);
buf->Indices.set_used(vCount);
for (int j=0; j<vCount; ++j) {buf->Indices[j]=j;}
buf->recalculateBoundingBox();
Mesh->recalculateBoundingBox();
IMeshSceneNode* terrain = smgr->addMeshSceneNode(Mesh,0,IDFlag_IsPickable);
terrain->setMaterialFlag(EMF_BACK_FACE_CULLING, false);
terrain->setMaterialFlag(EMF_FRONT_FACE_CULLING, true);
terrain->setMaterialFlag(EMF_LIGHTING, false);
terrain->setMaterialFlag(EMF_NORMALIZE_NORMALS, true);
ITriangleSelector* selector2 = 0;
selector2 = smgr->createTriangleSelector(
terrain->getMesh(), terrain);
terrain->setTriangleSelector(selector2);
terrain->setDebugDataVisible(EDS_BBOX_BUFFERS);
//IMetaTriangleSelector* tSelector2 = smgr->createMetaTriangleSelector();
//tSelector2->addTriangleSelector(selector2);
ISceneNodeAnimator* anim = smgr->createCollisionResponseAnimator(
selector2, cam, vector3df(2.5,10,2.5),
vector3df(0,gStrength,0), vector3df(1,7.5,1));
//selector->drop();
cam->addAnimator(anim);
//anim->drop();