Run time error? WTF

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.
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Run time error? WTF

Post by CuteAlien »

Well, first thing is to check if it actually loads. So check the pointer.
Then maybe load it in the editor just to check if the model works there.
And then start experimenting - scale it, place one every X steps, move it, move the camera nearer, further away, print a boundingbox around it, try what happens with another model, change the material settings .... whatever you can think off. Unless you start trying out what it's going on you can obviously not know it.

But don't ask 20 minutes after you solved one problem for people helping you with the next - you can't really have tried anything in that time. It is your code after all. We all work on our own.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
belva1234
Posts: 44
Joined: Sat Apr 07, 2012 2:00 pm

Re: Run time error? WTF

Post by belva1234 »

the mesch is created but i don't see it.. the function schootblock should create a block at the point of collision between the camera and the map but does not go and I do not think my mistake .. This is why I insist so much
THIS IS THE CODE

Code: Select all

scene::ISceneCollisionManager* collMan = smgr->getSceneCollisionManager();
 
        //da modificare la texture blocco in base all blocco che si e selezionato
     IAnimatedMesh *blocco=smgr->getMesh("../../media/blocco.3ds");
     IAnimatedMeshSceneNode *blocconode=smgr->addAnimatedMeshSceneNode(blocco);
    blocconode->setMaterialFlag(video::EMF_LIGHTING,false);
                core::line3d<f32> ray;
                ray.start = cam->getPosition();
                ray.end = ray.start + (cam->getTarget() - ray.start).normalize() * 1000.0f;
                core::vector3df intersection;
                core::triangle3df hitTriangle;
                scene::ISceneNode * selectedSceneNode =collMan->getSceneNodeAndCollisionPointFromRay(ray,intersection,hitTriangle ,-1, 0);
                        blocconode->setPosition(intersection);
Help me if you can pls and sorry for my insistence
Non funziona merda...
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Run time error? WTF

Post by CuteAlien »

Use a debugger to see which values you get, that's what the debugger is there for.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Run time error? WTF

Post by smso »

You should check whether collision has actually occur:

Code: Select all

scene::ISceneNode* selectedSceneNode =collMan->getSceneNodeAndCollisionPointFromRay(ray,intersection,hitTriangle ,-1, 0);
if (selectedSceneNode)
    blocconode->setPosition(intersection);
else
    printf("xxxxxx\n");
 
Secondly, have you set up the selector or meta?

Regards,
smso
belva1234
Posts: 44
Joined: Sat Apr 07, 2012 2:00 pm

Re: Run time error? WTF

Post by belva1234 »

i've use triange selector
Non funziona merda...
belva1234
Posts: 44
Joined: Sat Apr 07, 2012 2:00 pm

Re: Run time error? WTF

Post by belva1234 »

belva1234 wrote:i've use triange selector
If i use you metod appear xxxxxxxxxxxxx poop
Non funziona merda...
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Run time error? WTF

Post by smso »

By setting up selector, I mean:

Code: Select all

selector = smgr->create...
terrain->setTriangleSelector(selector); // do NOT forget this

You could also try this:

Code: Select all

camera->updateAbsolutePosition();
core::line3df ray;
ray.start = camera->getAbsolutePosition();
ray.end = ray.start + (camera->getTarget() - ray.start).normalize()*1000000.0f; // make this large
...

Regards,
smso
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Run time error? WTF

Post by CuteAlien »

I think getSceneNodeAndCollisionPointFromRay does not need a triangle-selector.
But experiment - if your ray does not collide makes sure you can print it. For example put the ray in some buffer which is then printed when you press space. Write yourself some debug functions.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
belva1234
Posts: 44
Joined: Sat Apr 07, 2012 2:00 pm

Re: Run time error? WTF

Post by belva1234 »

FIRST OF ALL THANK YOU, IF I TRY AS YOU SAY YOU DO NOT CHANGE ANYTHING AND APPEAR ALWAYS XXXXXXX THE SELECTOR WITH THE MAP IS THIS:

Code: Select all

scene::ITriangleSelector* selector= smgr->createTerrainTriangleSelector(terrain, 0);
        terrain->setTriangleSelector(selector);
Non funziona merda...
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Run time error? WTF

Post by CuteAlien »

Well, yes - it prints xxxx because you added the check to print that when it does not collide. Which means it does not collide. So now you have to figure out _why_ it does not collide. Most likely reason is that you put your ray is simply in the wrong position. Which is why I said you should write debug-functions to print out your ray so you can see where it really is.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
belva1234
Posts: 44
Joined: Sat Apr 07, 2012 2:00 pm

Re: Run time error? WTF

Post by belva1234 »

You say that I should show the coordinates of the block when it is created?
Non funziona merda...
CuteAlien
Admin
Posts: 9929
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Run time error? WTF

Post by CuteAlien »

Really up to you how to figure out what's going on. But when I debug such problems I always make sure I can see rays so I can see if they really collide or just point in the wrong direction or so. Check the functions in the videodriver for printing lines (you have to reset the world-transformation first when using them).

But you probably have to buffer the ray first (put it in some variable) as you don't see a ray that starts at the center of the camera and goes into the view direction (that's just 1 pixel in the center). So you put the ray in some buffer variable so you can still show it when you move around and see it from another angle.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: Run time error? WTF

Post by smso »

Try:

Code: Select all

scene::ISceneNode* selectedSceneNode =collMan->getSceneNodeAndCollisionPointFromRay(ray,intersection,hitTriangle);
instead of:

Code: Select all

scene::ISceneNode* selectedSceneNode =collMan->getSceneNodeAndCollisionPointFromRay(ray,intersection,hitTriangle ,-1, 0)
;

You may use drawWayPoint() function to visualize the hit point:
http://irrlicht.sourceforge.net/forum/v ... =9&t=45212

Debugging is many times more difficult than writing program:)

Regards,
smso
belva1234
Posts: 44
Joined: Sat Apr 07, 2012 2:00 pm

Re: Run time error? WTF

Post by belva1234 »

I have no funking idea I've tried everything.
Now i tray to display the cordinates who the cube is create
Non funziona merda...
Post Reply