PDA

View Full Version : GUI implementation for transform tool


pekko
11-12-2005, 11:13 AM
I am trying to create move tool like in Maya and Max for my 3d program. I am using directX. My problem is picking the icon with mouse. One possible solution is to project ray and test the collision for the mesh of move icon. Is it too clumsy?. Is there some handy way to do it in screen space with just some 2d algorithm?

Another problem is that how i can draw then icon top of everything even though the icon is inside of objects?

:mk:
11-13-2005, 05:18 PM
Best thing you could do is to check for opensource projects or examples which uses DirectX. I've done something similar with opengl which Maya uses but I'm not sure about DirectX.

Tried a simple search for "picking" algorithms on google and found;
http://www.mvps.org/directx/articles/improved_ray_picking.htm

Could be a place to start!

Mikael

ace4016
11-14-2005, 02:01 AM
I haven't done this yet, but sooner or later I will have to for my own app. I think getting the gizmo to appear above all objects, you just draw it last and/or without depth testing. And from there, a picking algorithm that maybe ignores you clicking on the mesh already selected but test whether you selected the gizmo or empty space (space thats not the mesh selected or the gizmo), where if you clicked on empty space it de-selects. Probably didn't help much, but yea. The gizmo object could be 3d too I would think.

pekko
11-14-2005, 01:59 PM
i was thinking that instead of doing this ray mesh intersection test for icon one could project the shape of the icon in screen space and do some point in shape test. Would this be more efficient? Is there such efficient 2d algorithm?

jamacsween
11-16-2005, 02:02 PM
Dont know about DirectX but there gluunproject in opengl.

Check the source for mesa in case this helps.

JA

pekko
11-19-2005, 08:46 AM
Silly of me!:blush:...Those tools exspecially (move and scaling) are just three lines in screen space, so in this case, i think, i just project end points of those lines and then do some point and line intersect test in 2D space with offset (to allow user some mistake).

Much nicer to code.....phew

But in the end i have to make conversion from 2D screen point to 3D ray in order to pick objects....but the intersection will do just with bounding boxes..blaah...blaah

Thanks for replys!:buttrock:

Per-Anders
11-19-2005, 08:59 AM
what you need to use is point line/ray distance. it's a pretty simple algorithm (you'll easily find it on the web). for things like rotation bands you'll want to use ray/plane intersection and just measure the distance from the center to get if your'e within hitrange of your cicle. with each you will want to evaluate each handle and if more than two are within range do a quick z-sort on the hit locations at some point in the algorithm, as it's only four in this case (three axis and a central "free" handle) you would do best to do this afterwards and only if you have more than one hit (your maximum hitcount being 2 with the pld handles and 3 with the rp loop handles), in fact really you only need z-sort with the loops, with the normal handles you can simply calculate which way around the axis is relative to you and thus avoid a few sqrts.

pekko
11-19-2005, 02:24 PM
what you need to use is point line/ray distance.
Very good point. Now into coding, thanks. I'll come back for more....

CGTalk Moderation
11-19-2005, 02:24 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.