In my program I have a list of "GraphNodes" which contain the id and the coordinate of the nodes. I am successful in rendering the sphere nodes at the correct positions.
It is when I have to draw the 3D lines that is bugging me. I go through a file that contains 2 ids of the nodes to connect. I use those ids to find the nodes and connect their coordinates with draw3DLine.
I am sure that the nodes I get from the ids and coordinates I pass into draw3D line are correct. It is just that draw3Dline isn't doing what I expect it to do. All I see when I run the program is the sphere nodes.
Here is a portion of my code beginning where I create the scene:
Code: Select all
// Create nodes in scene editor
IrrlichtDevice *device =
createDevice(video::EDT_OPENGL, core::dimension2d<u32>(640, 480));
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
// Add nodes to graph
for(int i = 0; i < num; i++)
{
GraphNode gn = nodes.at(i);
smgr->addSphereSceneNode(1.0f, 16, 0, gn.getName(),
core::vector3df(gn.getX(), gn.getY(), gn.getZ()));
}
// Create relationships by searching through vector
while(!myfile.eof())
{
string p1, p2;
getline(myfile, p1, ' ');
getline(myfile, p2);
int id1, id2;
istringstream str2int1(p1);
istringstream str2int2(p2);
str2int1 >> id1;
str2int2 >> id2;
driver->draw3DLine(
smgr->getSceneNodeFromId(id1)->getPosition(),
smgr->getSceneNodeFromId(id2)->getPosition());
}
// Add camera
smgr->addCameraSceneNodeFPS();
device->getCursorControl()->setVisible(false);
int lastFPS = -1;
while(device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, video::SColor(255,200,200,200));
smgr->drawAll();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
lastFPS = fps;
}
}
else
{
device->yield();
}
}
myfile.close();
device->drop();