Just a quick question - randomly I get a crash on the smgr->drawAll() line. I presume this means I've messed up somewhere but can't work out how to trace it back to the source. Does anyone have any suggestions?
Also (while I'm here
Thanks,
Mark.
No.markanderson wrote: Just a quick question - randomly I get a crash on the smgr->drawAll() line. I presume this means I've messed up somewhere but can't work out how to trace it back to the source. Does anyone have any suggestions?
The best thing we could do for you would be to tell you to step into the source with the debugger. Most likely you are dropping something that you shouldn't be or you are removing something from a list while iterating over it.presume this means I've messed up somewhere but can't work out how to trace it back to the source. Does anyone have any suggestions?
This happens when you have a mesh that has to many triangles. Most likely you have a really big mesh or terrain. If you are using a terrain scene node, you should use a 129x129 heightmap image. Anything bigger than 256 might fail with this message.I occassionally get a message in the console window saying 'Can not draw triangles, too many primitives'
Code: Select all
class CSampleSceneNode : public scene::ISceneNode
{
core::aabbox3d<f32> Box;
video::S3DVertex Vertices[4];
video::SMaterial Material;
public:
CSampleSceneNode(scene::ISceneNode* parent, scene::ISceneManager* mgr, s32 id, core::vector3df pos_start, core::vector3df pos_end)
: scene::ISceneNode(parent, mgr, id)
{
Material.Wireframe = false;
Material.Lighting = false;
Vertices[0] = video::S3DVertex(pos_end.X,pos_end.Y,pos_end.Z, 1,0,0, video::SColor(255,255,255,255), 1, 1);
Vertices[1] = video::S3DVertex(pos_start.X,pos_start.Y+20,pos_start.Z, 0,1,1, video::SColor(255,255,255,255), 1, 0);
Vertices[2] = video::S3DVertex(pos_start.X+20,pos_start.Y-20,pos_start.Z+20, 0,0,1, video::SColor(255,255,255,255), 0, 0);
Vertices[3] = video::S3DVertex(pos_start.X-20,pos_start.Y-20,pos_start.Z-20, 1,1,0, video::SColor(255,255,255,255), 0, 1);
Box.reset(Vertices[0].Pos);
for (s32 i=1; i<4; ++i)
Box.addInternalPoint(Vertices[i].Pos);
}
virtual void OnRegisterSceneNode()
{
if (IsVisible)
SceneManager->registerNodeForRendering(this);
ISceneNode::OnRegisterSceneNode();
}
virtual void render()
{
u16 indices[] = { 0,2,3, 2,1,3, 1,0,3, 2,0,1 };
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setMaterial(Material);
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 4);
}
virtual const core::aabbox3d<f32>& getBoundingBox() const
{
return Box;
}
virtual u32 getMaterialCount()
{
return 1;
}
virtual video::SMaterial& getMaterial(u32 i)
{
return Material;
}
};
Code: Select all
CSampleSceneNode *beam = new CSampleSceneNode(device->getSceneManager()->getRootSceneNode(), device->getSceneManager(), 666, core::vector3df(nodelist[srcnodeid].posx, nodelist[srcnodeid].posy, nodelist[srcnodeid].posz), core::vector3df(nodelist[dstnodeid].posx, nodelist[dstnodeid].posy, nodelist[dstnodeid].posz));
beam->setMaterialTexture(0, device->getVideoDriver()->getTexture("Media/laserbeam.bmp"));
beam->setMaterialFlag(video::EMF_LIGHTING, false);
beam->setID(sessionlist.size()-1+2000);
sessionlist[sessionlist.size()-1].id = (sessionlist.size()-1)+2000;
ISceneManager_assignTriangleSelectors(device->getSceneManager(), device->getFileSystem());
scene::IMetaTriangleSelector* meta = device->getSceneManager()->createMetaTriangleSelector();
ISceneManager_gatherTriangleSelectors(device->getSceneManager(), meta);
scene::ISceneNodeAnimator *anim = device->getSceneManager()->createCollisionResponseAnimator(meta, beam, core::vector3df(3,3,3), core::vector3df(0,0,0), core::vector3df(0,6,0));
beam->addAnimator(anim);
anim->drop();
The specific line that causes the crash in CTriangleBBSelector::getTriangles() is:main()
CSceneManager::drawAll()
ISceneNode::OnAnimate()
CCameraFPSSceneNode::OnAnimate()
CSceneNodeAnimatorCollisionResponse::animateNode()
CSceneCollisionManager::getCollisionResultPosition()
CSceneCollisionManager::collideEllipsoidWithWorld()
CSceneCollisionManager::collideWithWorld()
CMetaTriangleSelector::getTriangles()
CTriangleSelector::getTriangles()
CTriangleBBSelector::getTriangles()
Code: Select all
core::aabbox3d<f32> box = SceneNode->getBoundingBox();
Code: Select all
meta->removeTriangleSelector( node->getTriangleSelector() );
node->remove();