|
rammer, Newbie
Posted: 22 August 2012 11:43 AM Total Posts: 6
Hi.
I’m a newbie in 3D so this might seem a dumb question but here it goes. I’m starting a little experimental project where I want to click on an object and I want to put a marker ( line segment or mesh ) right in where the object was clicked. I can accomplish this but I also want to orient the new object ( marker ) to be perpendicular with the face I just clicked. Can anyone help?
Thanks.
|
Richard Olsson, Administrator
Posted: 22 August 2012 01:32 PM Total Posts: 1192
[ # 1 ]
When you click a mesh, provided that you have configured the picking system to get the full details (which you probably have if you are able to find the position of the click) you will also get a property called sceneNormal, if I remember the name correctly. That is the normal vector of the face that was clicked. So set the beginning of your segment to the position of the click, and the end to the position plus the normal vector. If you need it to be longer than 1 unit (the normal is a unit vector) you can just scale the normal uniformly.
|
rammer, Newbie
Posted: 22 August 2012 02:10 PM Total Posts: 6
[ # 2 ]
Thanks for your quick reply.
The event has a property called localNormal that I bellieve it’s the face’s normal vector. I added it to the event’s localPosition property but the lines are not quite perpendicular to the face. They seem to be aligned to the origin (I did the same with the sceneNormal property. Had the same result). As if they started on the origin and intersected the face at the click point. It’s no the end of the world though. Don’t know if this counts has picking system but I just set the the object’s mouseEnabled to true.
|
rammer, Newbie
Posted: 22 August 2012 03:02 PM Total Posts: 6
[ # 3 ]
Hi the problem is with the segment set. If a new segment set is created per line segment ( marker ) and added to the event position the marker stays perpendicular to the clicked face. If only one segment set is created it stays at (0,0,0) and the segments are created as if they started there even if I specify start and end positions. Don’t know if it’s supposed to the this way or if it’s a bug.
Problem solved anyway.
|