Check out pointat()
and if you need, anglebetween()
i'm trying to figure out the angle between a point in my sceane and the point at which the mouse has been clicked. i've been looking at 3dD world ([url]http://www.dmu.com/[/url]) but my maths skills arent strong enough to figure it out from the starting point that gives me. so i have something like: mousePlace = the mouseLoc - point(sprite(1).left, sprite(1).top) tRollOverModel = sprite(1).camera.modelUnderLoc(mousePlace) if tRollOverModel <> 0 and _mouse.mouseDown then targ = sprite(1).camera.spriteSpaceToWorldSpace(mousePlac e) put "mouseover " & targ end if this tells me if ive clicked on the model and gives me "a" reading on where the mouse is. ...
i'm trying to figure out the angle between a point in my sceane and the
point at which the mouse has been clicked. i've been looking at 3dD
world ([url]http://www.dmu.com/[/url]) but my maths skills arent strong enough to
figure it out from the starting point that gives me.
so i have something like:
mousePlace = the mouseLoc - point(sprite(1).left, sprite(1).top)
tRollOverModel = sprite(1).camera.modelUnderLoc(mousePlace)
if tRollOverModel <> 0 and _mouse.mouseDown then
targ = sprite(1).camera.spriteSpaceToWorldSpace(mousePlac e)
put "mouseover " & targ
end if
this tells me if ive clicked on the model and gives me "a" reading on
where the mouse is. i want to rotate a model to point at where the mouse
is.
any help would be much apreciated.
jon
Check out pointat()
and if you need, anglebetween()
so, time for a little math :)
A, B -> points
v = B-A ->vector from A to B
vx -> x axis
alpha -> angle between v and vx
v . vx
--------- = cos alpha
|v| . |vx|
thanks guys
i havent solved it yet though. i apologise for my ignorance.
heres whats going on. i have a pendulum hanging in my sceane, i want to
point the pendulum towards a mouse click (and then have it swing, the
swinging part works fine). pointing it at a mouse click is proving a lot
harder.
i want the pendulum to only move on one plane (it rotates on its x axis).
heres what i'm trying to do. i find the place where the user has clicked
(targ) i find the location of the fulcrum (fulcrumLoc) and i find the
location of the camera (cameraLoc). then i try to get the angle from the
fulcrumLoc to the point on the sightLine (targ - cameraLoc) on the yz
plane (where to turn the pendumlum to point at the mouse).
mousePlace = the mouseLoc - point(sprite(1).left, sprite(1).top)
cameraLoc = sprite(1).camera.worldPosition
fulcrumLoc = member("pendulum04").model("fulcrum01").worldPosit ion
targ = sprite(1).camera.spriteSpaceToWorldSpace(mousePlac e)
sightLine = targ - cameraLoc
pendulumAngle =
member("pendulum04").model("fulcrum01").transform. position.angleBetween(sightLine)
as you can see i dont know what i'm doing. for one thing i dont know how
to work on a point in the yz plane. for another
transform.position.angleBetween is throwing a "method not found" error.
So i still need help. I apreciate the efforts already made and would
really like it if somebody can explain what i'm doing wrong.
thanks
jon
Bookmarks