DeltaYaw
BlitzMax Forums/MiniB3D Module/DeltaYaw
| ||
Hi there, I'm using MiniB3D for the first time and I have something I don't fully get about DeltaYaw(). According to the docs it returns the change in yaw necessary for the first entity to point at the second. What is seems to be doing is taking the two entities and finding the angle from one to another as though the first entity was pointing straight along the axes. To test it I looked at values returned and when I rotated the camera, DeltaYaw from the camera entity to the enemy entity didn't change - it only changed when I moved, which I'd still expect. So it seems not to take into account the angle of the camera? Any ideas why I'm going wrong here? Or is that how it's supposed to be and I need to write a function that adds DeltaYaw and the camera's Yaw or something similar? Any help would be much appreciated! Cheers, Jasper |
| ||
Not sure what you're trying to accomplish exactly. Perhaps pointentity() will save you some time? |
| ||
You're absolutely right Sonic. I hadn't noticed that before. After some investigation Blitz3D also works this way. It doesn't take into account the current rotation of the entity, it gives you the 'absolute' difference instead of 'relative'. That's why PointEntity() uses RotateEntity() instead of TurnEntity() (inside the miniB3D source, that is). Since both DeltaYaw() and Pitch() return global orientation values, you can probably just calculate the difference between these returned values with the current rotation the entity has (retrieved with EntityPitch(...,True) etc. so they're global). This way it becomes 'relative'. |
| ||
Yeah in the end I wrote a hacky function to do roughly that... It really had me stumped though! I actually wanted it for a 3d spacial sound system using Freesound. It is used to calculate where in the stereo field a monster is... Function DYaw:Double( pEntity1:TEntity, pEntity2:TEntity ) Local l_dx:Double Local l_dz:Double dx = EntityX(pEntity2 ) - EntityX(pEntity1 ) dz = EntityZ(pEntity2 ) - EntityZ(pEntity1 ) Local ang:Double=ATan2(l_dx,l_dz) Local yaw:Double=EntityYaw(pEntity1) // As minib3d's rotations don't seem to wrap, a hack to get back in the right range: ang:+yaw While (ang<-180) ang:+360 Wend While (ang>180) ang:-360 Wend Return ang End Function Last edited 2011 |