I don't know if this is a bug or if i just misunderstood the function. So here's my test code:
Code: Select all
#include <irrlicht.h>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
IrrlichtDevice* device;
IVideoDriver* driver;
ISceneManager* smgr;
IGUIEnvironment* guienv;
ISceneNode* node;
class MyEventReceiver:public IEventReceiver
{
public:
MyEventReceiver() { LastNode = 0; }
virtual bool OnEvent(const SEvent& event)
{
switch(event.EventType)
{
case EET_KEY_INPUT_EVENT:
{
switch(event.KeyInput.Key)
{
case KEY_ESCAPE:
{
device->closeDevice();
return true;
}
}
}
case EET_MOUSE_INPUT_EVENT:
{
case EMIE_MOUSE_MOVED:
{
s32 xPos, yPos;
ISceneNode* TestNode;
xPos = event.MouseInput.X;
yPos = event.MouseInput.Y;
TestNode = smgr->getSceneCollisionManager()->getSceneNodeFromScreenCoordinatesBB(position2d<s32>(xPos, yPos));
if( TestNode != 0 && LastNode == 0 )
{
LastNode = TestNode;
LastNode->setScale(vector3df(1.1f,1.1f,1.1f));
switch (LastNode->getID())
{
case 100:
{
smgr->getSceneNodeFromId(101)->setVisible(true);
}
break;
case 102:
{
smgr->getSceneNodeFromId(103)->setVisible(true);
}
break;
case 104:
{
smgr->getSceneNodeFromId(105)->setVisible(true);
}
break;
}
}
else if( TestNode != 0 && LastNode != 0 )
{
LastNode->setScale(vector3df(1.0f,1.0f,1.0f));
switch (LastNode->getID())
{
case 100:
{
smgr->getSceneNodeFromId(101)->setVisible(false);
}
break;
case 102:
{
smgr->getSceneNodeFromId(103)->setVisible(false);
}
break;
case 104:
{
smgr->getSceneNodeFromId(105)->setVisible(false);
}
break;
}
LastNode = TestNode;
LastNode->setScale(vector3df(1.1f,1.1f,1.1f));
switch (LastNode->getID())
{
case 100:
{
smgr->getSceneNodeFromId(101)->setVisible(true);
}
break;
case 102:
{
smgr->getSceneNodeFromId(103)->setVisible(true);
}
break;
case 104:
{
smgr->getSceneNodeFromId(105)->setVisible(true);
}
break;
}
}
return true;
}
}
}
return false;
}
private:
ISceneNode* LastNode;
};
int main(int argc, char** argv)
{
MyEventReceiver receiver;
device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32, false, false, false, &receiver);
device->setWindowCaption(L"Irrlicht Engine Test");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
guienv = device->getGUIEnvironment();
node = smgr->addSphereSceneNode(1.0f, 64, 0, 100, vector3df(0,5,0));
smgr->addTextSceneNode(guienv->getBuiltInFont(), L"Planet 1", SColor(255,255,255,255), node, vector3df(1.5f,1.5f,0.0f), 101);
node->setMaterialFlag(EMF_LIGHTING, false);
node = smgr->addSphereSceneNode(1.0f, 64, 0, 102, vector3df(5,0,0));
smgr->addTextSceneNode(guienv->getBuiltInFont(), L"Planet 2", SColor(255,255,255,255), node, vector3df(1.5f,1.5f,0.0f), 103);
node->setMaterialFlag(EMF_LIGHTING, false);
node = smgr->addSphereSceneNode(1.0f, 64, 0, 104, vector3df(-5,-5,0));
smgr->addTextSceneNode(guienv->getBuiltInFont(), L"Planet 3", SColor(255,255,255,255), node, vector3df(1.5f,1.5f,0.0f), 105);
node->setMaterialFlag(EMF_LIGHTING, false);
smgr->getSceneNodeFromId(101)->setVisible(false);
smgr->getSceneNodeFromId(103)->setVisible(false);
smgr->getSceneNodeFromId(105)->setVisible(false);
smgr->addCameraSceneNode(0, vector3df(0,0,-25), vector3df(0,0,0));
device->getCursorControl()->setVisible(true);
while(device->run())
{
driver->beginScene(true, true, SColor(0,0,0,0));
smgr->drawAll();
guienv->drawAll();
driver->draw3DLine(vector3df(0,5,0), vector3df(5,0,0), SColor(255,255,255,0));
driver->endScene();
}
device->drop();
return 0;
}
But within the Renderfunction i tried to draw a 2dline from Sphere 1 (0,5,0) to Sphere 2 (5,0,0). The result looks like this:
OpenGL: the line draws away from the desired location and "jumps" if i go over one sphere (if one sphere is hit by mouse it scales to 1.1f and shows the Textnode).
Direct3D: same as OpenGL beside the location, but if i hit one sphere the line completely disappears
Depends this on my code? I don't know.
greetings
radical
EDIT: Compiled with Code::Blocks @ XP and MSVC at Win7 RC - API v1.5.1