irrlicht mousepos

BlitzMax Forums/BlitzMax Beginners Area/irrlicht mousepos

kimgar(Posted 2007) [#1]
hi!

i've just discovered irrlicht and blitzmax - great stuff!
i am completely new to this and could really use a little help. i am trying to create a product viz kind of thing, and i need to be able to click meshes and display info.

currently i am stuck on picking nodes, i am not sure what is the best way to do it, but was thinking of using mousepos with collisiondetection.

i've had a look at the collision example, but as far as i can understand, that checks for node collision with a sprite, i need to change that sprite collision to a mouse pointer collision

i think i need getposition, but i am not sure how to call this function(from irrlicht docs) in bMax:

'virtual core::position2d<s32> irr::gui::ICursorControl::getPosition ( )


what would the blitzMax syntax be?

i'm using gman's latest mods and bMax1.24, does anyone have any ideas?


gman(Posted 2007) [#2]
greetings :) wish i wouldve finished those picking functions for iB3D :/ anyways, you are on the right track. in comination with the cursor control, you need the what your looking for is ICursorControl.getPosition() and ISceneCollisionManager.getSceneNodeFromScreenCoordinatesBB(). pass the result of getPosition() as the position paramter. something like:
Local device:IrrlichtDevice = IrrlichtDevice.create(EDT_OPENGL,_DIMENSION2DI(640,480),16,False,False,False,Null)
Local cursor:ICursorControl=device.getCursorControl()
Local smgr:ISceneManager = device.getSceneManager() 
smgr.getSceneCollisionManager().getSceneNodeFromScreenCoordinatesBB(cursor.getPosition())

there are several functions in ISceneCollisionManager that will allow you to do picking in different ways. for example, you can convert a 3D point to screen coords and then use the above to pick a node.


kimgar(Posted 2007) [#3]
aaah, thanks alot gman, that works!
i haven't had this much coding fun since the days of assembler!

i really need to get used to the syntax though, ie. is it possible to print the collision output?

selectedNode = smgr.getSceneCollisionManager().getSceneNodeFromScreenCoordinatesBB(cursor.getPosition())
print selectedNode?



...the bounding box collision is a bit crude though, i guess i'll need to look into some sort of raycheck or something for more accurate results, i read something about irrlicht collision being real slow, and that IPhysics and IrrNewt should be used instead - would that be speedier just for simple node picking? sounds a bit like overkill to me :)

anyways, gman, i would love to register at your gprogs.com forum, but i do not receive any confirmation mails...could you help me out?

i've registered as kimgar with kima@...


kimgar(Posted 2007) [#4]
ok, i figured out how to debug :)

Print selectedNode.getID()


...and now i see something weird - if i move the mouse around on the same object, the collision returns the correct id, but occasionally it also returns -1, this causes an annoying flicker.
i see the collision example suffers from the same thing.
has this got to do with irrlicht collisions in general, or would iPhysics or iNewt behave differently?


gman(Posted 2007) [#5]
sorry for the delayed response :( could you please post an example for the flicker? i have not witnessed this yet.

as for your earlier question, the BB check is meant to be a quick check. if you need to get more in depth you need to use the technique from the collisions sample where you check a ray against the triangles of the mesh.

i havent a large amount of collision experience in Irrlicht, but overall i dont know that there is a major problem with collision speed. how many objects are you drawing? not sure about iPhysics or iNewt as i have no experience with those :(

sorry about the registration problem also. lately ive had to tighten up my forum due to excessive spammer registrations. i have for the next day or so turned off the email validation so you can create an account.


kimgar(Posted 2007) [#6]
no worries! i am very glad you are back :)

great! an account has been set up, thanks alot gman!

you can pick up a flicker example here:
http://www.indok.no/filetransfer/temp/testCollision.zip

it is kind of weird though(at least to me), that it is only direct3d that suffers from this problem...

ah, ofcourse! i didn't even realise there was a raycheck in the example, i guess you are refering to the 'setLineFromVects' part...beautiful, i love the simpleness, gotta look into that, thanks!

regarding speed issues, i don't have any problems with that at the moment, as i am only drawing 3 teapots for testing purposes. but later on, if i can pull this off, there will be many highly detailed objects, which is why i was curious about speed issues :)