Solved: Problem using getSceneNodeAndCollisonPointFromRay

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
stevebondy
Posts: 20
Joined: Thu Aug 13, 2009 5:47 pm
Location: British Columbia, Canada

Solved: Problem using getSceneNodeAndCollisonPointFromRay

Post by stevebondy »

Hi all.

Any ideas on this would be greatly appreciated. I am upgrading to irrlicht 1.6 from 1.5.1, and thought I'd change some of my code to use the new ISeneCollisionManager::getSceneNodeAndCollisionPointFromRay() function. Unfortunately my program dies when it calls this function. At the moment I'm stumped.

Here's a code snippet:

Code: Select all

                    core::line3d<f32> line;
                    line.start = mainCamera->getAbsolutePosition();
                    line.end = line.start + (mainCamera->getTarget() - line.start).normalize() * 1000.0f;

                    core::vector3df intersection;
                    core::triangle3df tri;

cout<<"Before collision check"<<endl;
printf("Line=(%4.2f,%4.2f,%4.2f)-(%4.2f,%4.2f,%4.2f)\n",line.start.X,line.start.Y,line.start.Z,line.end.X,line.end.Y,line.end.Z);
const core::list< ISceneNode * > children = CollidableNodes->getChildren();
printf("CollidableNodes contains %d children nodes\n",children.getSize());
pause();
                    if (irrScene->getSceneCollisionManager()->getSceneNodeAndCollisionPointFromRay(
                        line, intersection, tri, 0, CollidableNodes, false))
                    {
cout<<"5";
pause();
                        bill->setPosition(intersection);
                        irrDriver->setTransform(video::ETS_WORLD, core::matrix4());
                        irrDriver->setMaterial(material);
                        irrDriver->draw3DTriangle(tri, video::SColor(0,255,0,0));
                    }
cout<<"5";
pause();
I load my scene from a .irr file, then using code from the example programs I run through the nodes to create triangle selectors, and while I'm at it I set the parent of the nodes to either CollidableNodes or NonCollidableNodes, which are empty scene nodes added using addEmptySceneNode.

When I run the program it gets to the debug lines just before the if condition, pauses for me so I can read the output, then the program simply exits. No crash or anything, it just disappears. Nothing is rendered, and it never reaches the other pause() lines just inside, or just after the if block.

Here's a sample of the output:

Code: Select all

Initializing application...
Initializing irrlicht...
Irrlicht Engine version 1.6
Microsoft Windows XP Professional Service Pack 3 (Build 2600)
Using renderer: OpenGL 1.3.1030
FireMV 2400 PCI DDR x86/SSE2: ATI Technologies Inc.
OpenGL driver version is 1.2 or better.
GLSL not available.
Initializing Scene...
Loaded texture: C:\Projects\STEVE\Megaverse\media\tex\brick42.jpg
Loaded texture: C:\Projects\STEVE\Megaverse\media\img\stars1.bmp
Could not open file of texture: C:\Projects\STEVE\Megaverse\media\model/Con10.jpg
Could not open file of texture: C:\Projects\STEVE\Megaverse\media\model/CorrugatedMetal.jpg
Loaded mesh: media/model/hangar.obj
Loaded texture: C:\Projects\STEVE\Megaverse\media\tex\con10.jpg
Loaded texture: C:\Projects\STEVE\Megaverse\media\tex\corrugatedmetal.jpg
Could not open file of texture: C:\Projects\STEVE\Megaverse\media\model/ALUM_8L4.JPG
Could not open file of texture: C:\Projects\STEVE\Megaverse\media\model/SafetyChevron.jpg
Could not open file of texture: C:\Projects\STEVE\Megaverse\media\model/PlatNum29.jpg
Loaded mesh: media/model/ground.obj
Loaded texture: C:\Projects\STEVE\Megaverse\media\tex\alum_8l4.jpg
Loaded texture: C:\Projects\STEVE\Megaverse\media\tex\safetychevron.jpg
Loaded texture: C:\Projects\STEVE\Megaverse\media\tex\platnum29.jpg
Scenefile loaded
1b23 nodes found=11
a-root-fgi
a-testCube-bgh=0x7824760i
a-Skybox-fgi
a-Sun-fgi
a-Hangar-cgh=0x7920d58i
a-HangarLight-fgi
a-Platform-cgh=0x77e7098i
a-Platform30-cgh=0x7920b98i
a-CollidableNodes-fgi
a--fgi
a-NonCollidableNodes-fgi
4Preparing for main loop 1Loaded texture: C:\Projects\STEVE\Megaverse\media\tex\particle.bmp
2Time=803
123Before collision check
Line=(0.00,0.00,0.00)-(0.00,0.00,1000.00)
CollidableNodes contains 5 children nodes
Press return to continue:
Thanks in advance for any and all ideas on what I may be missing, or if perhaps this is a bug.


Steve
stevebondy
Posts: 20
Joined: Thu Aug 13, 2009 5:47 pm
Location: British Columbia, Canada

Solved

Post by stevebondy »

I finally figured out what was happening.

In setting my node parents I had accidentally created an infinite loop because the root node was made a child of one of my nodes. I had coded the checks properly in one spot but missed it in another.

Irrlicht faithfully ran through about 20000 iterations before disappearing into another D.

Steve
Post Reply