hi, im trying to make the basics of a mmorpg.
I have a 3d camera set up and im planning to make the player move around with mouse clicks, my only problem is: how do i get the 3D position on a map after a mouseclick?
3d position from mouse click
-
after-life
- Posts: 69
- Joined: Wed Mar 30, 2005 8:16 am
- Location: Keerbergen, Belgium
use getRayFromScreenCoordinate to get a ray coming from your mouse position in to the scene, then check for a collision with the floor.
first see the collision tutorial to set up your floor's triangle selector
first see the collision tutorial to set up your floor's triangle selector
Code: Select all
line3d<f32> raytrace = colmgr->getRayFromScreenCoordinates(device->getCursorControl()->getPosition(), camera);
colmgr->getCollisionPoint(raytrace, triangleselector, tracetarget, tracetriangle);
-
after-life
- Posts: 69
- Joined: Wed Mar 30, 2005 8:16 am
- Location: Keerbergen, Belgium
it returns a triangle as well as the vector, tracetarget is the vector
see
http://irrlicht.sourceforge.net/docu/cl ... nager.html
see
http://irrlicht.sourceforge.net/docu/cl ... nager.html
-
after-life
- Posts: 69
- Joined: Wed Mar 30, 2005 8:16 am
- Location: Keerbergen, Belgium
So i've implemented this into my current project as well. My only problem is - it can be very hard for my ray to collide sometimes. Sometimes i have to hover around the object until it registers my mouse there. But if i turn move the camera to a different angle its a lot easier to hover over and get the collision event to happen with the mouse cursor.
I guess my question is this - How can i make it more sensitive to detect the collision to make sure my mouse is over a node from no matter where the camera is?
I've tried changing the 'minpolycount' to various different numbers not seeing any change either. Can somebody point me in the right direction?
Thanks
I guess my question is this - How can i make it more sensitive to detect the collision to make sure my mouse is over a node from no matter where the camera is?
I've tried changing the 'minpolycount' to various different numbers not seeing any change either. Can somebody point me in the right direction?
Thanks
Irme, you can try to use a bounding box collision, "getCollisionSelectorFromBoundingBox" or someting like that, i might be a little of..
If you use this itll just use the box for collision and make it alot easier to select things from all angles, on the downside if you hav too many small objects side by side it may be a little inaccurate.
Cheers
If you use this itll just use the box for collision and make it alot easier to select things from all angles, on the downside if you hav too many small objects side by side it may be a little inaccurate.
Cheers
Well it did help, I'm now using "GetSceneNodeFromScreenCoordinatesBB" and passing it the mouse coords and its working much better, but there are a few models that don't work right, unless i move the camera around a bit. Any other sugestions?
I can post a video to explain what is happening if it will help.
I can post a video to explain what is happening if it will help.