PointEntity and TFormPoint

Blitz3D Forums/Blitz3D Programming/PointEntity and TFormPoint

DareDevil(Posted 2006) [#1]
Is possible simulate the function PointEntity and TFormPoint if yes what?

Thanks


jhocking(Posted 2006) [#2]
um, what do you mean by "simulate"? Or, more to the point, why don't you just use those commands?

I do have a bit of code that accomplishes basically the same thing as PointEntity, but using AlignToVector since that gives you more control over the movement.


Stevie G(Posted 2006) [#3]
Not directly as tformpoint gives you only a point, not a rotation.

You could use aligntovector to avoid gimbal lock as it uses quarternions. You could maybe make use of tformvector to get the alignment vector depending on what your doing.

Another option would be to use a combination of deltayaw and deltapitch to acheive similar results.

What exactly are you trying to do? Related to your shadow system I guess?
Stevie


mongia2(Posted 2006) [#4]
Function Point_Entity(entity,x#,y#,z#)
xdiff# = EntityX(entity)-x#
ydiff# = EntityY(entity)-y#
zdiff# = EntityZ(entity)-z#
dist#=Sqr#((xdiff#*xdiff#)+(zdiff#*zdiff#))
pitch# = ATan2(ydiff#,dist#)
yaw# = ATan2(xdiff#,-zdiff#)
RotateEntity entity,pitch#,yaw#,0
End Function

mongia


Sir Gak(Posted 2006) [#5]
Hey, while reading this thread, I saw the use of the term "gimbal lock". I have seen it referred to in these forums from time to time. What is that, anyway? (Like my sig says, "When in doubt, find out.")


Rroff(Posted 2006) [#6]
when in doubt turn to wiki...

http://en.wikipedia.org/wiki/Gimbal_lock


Stevie G(Posted 2006) [#7]
A simpler and quicker method ...

Global PIVOT = createpivot()

Function Point_Entity( entity, x#, y#, z# )
   positionentity Pivot , x, y, z
   turnentity entity, deltapitch( entity, pivot ) , deltayaw( entity, pivot ) , 0
end function


Stevie


Chroma(Posted 2006) [#8]
Not quicker...


DareDevil(Posted 2006) [#9]
thanks all


Stevie G(Posted 2006) [#10]
@ Chroma, of course it's quicker!

Speed is probably negligible until you use it hundreds of times per frame but there is no SQR, no ATAN2 or precalcs.

Stevie


Chroma(Posted 2006) [#11]
Yeah but you are positioning an object and using turnentity with deltapitch and deltayaw.

The pure math way is faster. Tests were done a couple years ago for verification. The Point_Entity Function I wrote for the archives is even faster than the built in PointEntity function in B3D.

But yeah, unless you're using it hundreds of time per frame, it doens't really matter which method is used.


Defoc8(Posted 2006) [#12]
to point one objects at another..

1] vec to target object - position of source object.
2] cross of this vector with the source objects look vector
gives you axis of rotation.
3] acos(dot) of those vectors gives you the angle of
rotation.

now you have an axis and and angle..shame blitz doesnt
support axis angle rotation..converting to euler is messy..

heh.. useless information.. im good at that ;)


YellBellzDotCom(Posted 2006) [#13]
Well Ive used all methods including the PointEntity() command from Blitz3d. They all work great, dont see any speed difference (yet). My main problem is my model is facing the opposite direction. I fixed that with RotateMesh, and it worked great, the new problem is if I use RotateMesh on any equipped items, they get all stretched and skewed. Any Idears on how to fix this without remodeling my center points for each model?

Thanks in advance.


Bobysait(Posted 2006) [#14]
Maybe create a pivot, parent all to this pivot, and turn it 180 on axe Y

Remeber Rotatemesh move the vertex, not the pivot of the mesh, so it's irreversible.

If your model point to the opposite direction, you can solve using a turnentity 0,180,0 after your pointEntity . But it's only available for FPS or RPG like movements => Turning 180° in 3D should not be for yaw... unless you turn locally and not globally.

Don't know if you understand what i mean, i'm not very clear...


YellBellzDotCom(Posted 2006) [#15]
Thanks for the response...

I found out that RotateMesh has adverse effects on Boned meshes.

I found the same answer you stated here...
http://www.blitzbasic.com/Community/posts.php?topic=35590#387649

from TRACI
"if your mesh is back to front, the only way I have found to do it is use rotateentity 180 degrees when loading it to get it pointing in the right direction, then parent it to a pivot and use the pivot for movement. Max does the same thing, what looks like the right way round in the front viewport isn't :S and this is what I've done with models in the past."

I rotated the model first, then created the pivot, parented the mesh to the pivot, and used PointEntity CharacterPivot, TargetPivot to get it. It worked great!!

Thanks for the help!


Ross C(Posted 2006) [#16]
I'd say Stevie's way is quickier. I'd like to say that dis-proven :o) SQR is a slow-ish function.