ISceneCollisionManager::getCollisionPoint Error

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Matix522
Posts: 15
Joined: Wed Jul 02, 2014 11:48 am
Location: Poland

ISceneCollisionManager::getCollisionPoint Error

Post by Matix522 »

I try to get 3d position from 2d coordinats on screen, but i get weird error from ISceneCollisionManager::getRayFromScreenCoordinates(). Debugger receives SIGSEGV signal but i dont know how to solve it. I was recompiled irrlicht two times and nothing new has happend. how can I check what variable is corrupted? Maybe i doing something wrong?
Code:

Code: Select all

 
ISceneCollisionManager* SCmgr;
 
ITriangleSelector* selector=smgr->createTriangleSelectorFromBoundingBox((ISceneNode*&)meshnode);
/*Other Code*/
if(receiver.MouseState.LeftButtonDown)
{
        core::vector3df outCollisionPoint;
        ISceneNode* outNode;
        core::triangle3df outTriangle;
        cout<<"position in 2D space is X: "<<receiver.MouseState.Position.X<<" Y: "<<receiver.MouseState.Position.Y<<endl;
        position2d<s32> pos2D = receiver.MouseState.Position; 
        line3d<f32>  line;
        line =SCmgr->getRayFromScreenCoordinates(pos2D,smgr->getActiveCamera());   /**  <----------- IN THIS LINE DEBUGGER GETS ERROR**/
        cout<<"DFDF";
        bool ggg = SCmgr->getCollisionPoint(line,selector, outCollisionPoint,outTriangle,  outNode);
        if(ggg)
            cout<<"position in 3D space is X: "<<outCollisionPoint.X<<" Y: "<<outCollisionPoint.Y<<" Z: "<<outCollisionPoint.Z<<endl;
}
 
 
Debugger:

Code: Select all

Starting debugger: F:\CodeBlocks\MINGW\bin\gdb.exe -nx -fullname  -quiet  -args F:/irrlicht-1.8.1/bin/Win32-gcc/CustomSceneNode.exe
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.5
Child process PID: 4304
Program received signal SIGSEGV, Segmentation fault.
At F:\irrlicht-1.8.1\examples\03.CustomSceneNode\main.cpp:322
Continuing...
Program received signal SIGSEGV, Segmentation fault.
At F:\irrlicht-1.8.1\examples\03.CustomSceneNode\main.cpp:322
Continuing...
[Inferior 1 (process 4304) exited with code 030000000005]
Debugger finished with status 0
 
Last edited by Matix522 on Wed Sep 03, 2014 4:02 pm, edited 1 time in total.
Seven
Posts: 1034
Joined: Mon Nov 14, 2005 2:03 pm

Re: ISceneCollisionManager::getRayFromScreenCoordinates Erro

Post by Seven »

ISceneCollisionManager* SCmgr;

where do you set this to a valid value?

also

ITriangleSelector* selector=smgr->createTriangleSelectorFromBoundingBox((ISceneNode*&)meshnode);

are you wanting to use SCmgr instead of smgr?
Matix522
Posts: 15
Joined: Wed Jul 02, 2014 11:48 am
Location: Poland

Re: ISceneCollisionManager::getCollisionPoint Error

Post by Matix522 »

ISceneCollisionManager* SCmgr;

where do you set this to a valid value?

Code: Select all

 
    ISceneCollisionManager* SCmgr = smgr->getSceneCollisionManager();
    /*rest of the code*/
 
    ITriangleSelector* selector=smgr->createTriangleSelector((IMesh*)meshnode->getMesh(),(ISceneNode*)meshnode);
    meshnode->setTriangleSelector(selector);
 
That was a problem, but now I'm getting valid coordinats only if I press mouse buton when cursor is on down part of mesh this is terrain using 32Bit meshbuffer and terrain size is 512(+32)x256 so this is probably a reason, but how fix this?
console text:

Code: Select all

 
position in 2D space is X: 421 Y: 303
position in 3D space is X: 67.6232 Y: 11.293 Z: 88.1021
 
position in 2D space is X: 413 Y: 69
collision don't detected
Post Reply