PointEntity Done?

Blitz3D Forums/Blitz3D Programming/PointEntity Done?

-Rick-(Posted 2004) [#1]
I'm a bit embarrased to ask this as it seems like it should be a blatently obvious sollution, but how could I detect if my camera is already pointed at an object?


Damien Sturdy(Posted 2004) [#2]
Create a pivot at the camera positions
Point the pivot at the object
check the variance in pitch yaw and roll values between the pivot and camera..

That should do it well enough anyhoo!!! :)


WolRon(Posted 2004) [#3]
You could also use the CameraPick command.


Damien Sturdy(Posted 2004) [#4]
indeed, I never think of the Pick commands! such use! i do things the hard way

Oh, and dont forget to set EntityPickMode on all objects you will want to check :P


REDi(Posted 2004) [#5]
Or you could do it like this... (not tested)



Damien Sturdy(Posted 2004) [#6]
Papa, that was my first suggestion. :P


REDi(Posted 2004) [#7]
Cygnus its the same idea but without using any pivots ;)

BTW Using a camerapick doesn't tell you if the camera is pointing exactly at the entitys origin, it only tells you that any part of mesh is infront of the camera.

And what if another entity gets in the way? ;)


DJWoodgate(Posted 2004) [#8]
You could also perhaps make use of the DeltaPitch and DeltaYaw functions.


Jeppe Nielsen(Posted 2004) [#9]
You could use the CameraProject command, and then check if the projectedX() and projectedY() commands are in the center of the viewport.


Picklesworth(Posted 2004) [#10]
Or if you can you could just put a global variable containing what entity the camera is pointed at, and change it as that changes.


-Rick-(Posted 2004) [#11]
Thanks for all that help everyone! My problem is that I'm ignorant in the use of alot of these commands like DeltaPitch, DeltaYaw, or TformVector. The help files arent all that helpful and doing a search in the forums leads you to reading post after post of stuff that usually doesnt pertain to what you're interested in.

It's very frustrating to see comments like "You could also perhaps make use of the DeltaPitch and DeltaYaw functions." (not to pick on DJWoodgate of course!) because I havent the faintest idea how I'd go about using them or what they are for. I *THINK* that the term 'delta' might mean a change in something so I'd hazzard to guess that "DeltaPitch" would mean a change in pitch ..??

I've done search after search to try and figure out how to use TformVector stuff but I havent found much in the way of explaining what its for, how its used, etc for someone who is totaly ignorant of it. I've seen a few "now that i understand it i can't believe i've gone this long without it" posts, but so far no bulbs have gone off for me. I even tried looking up "Vector Math" on google. The doctor said my eyes will stop bleeding soon and the brain swelling will go down ...

I truly thank Papa Lazarou for his code bit. That is what I was trying to do but I wasnt quite getting it right. His code plugged in nicely. It sounds like Cygnus is suggesting a pick Command sollution. While I've got a faint understanding of the pick commands, I'm no whiz at it and don't quite see what clever bit of coding would be required to use it.

I know just enough to get me into trouble is what I'm guess I'm saying ;) Thanks again for the help everyone and sorry to keep asking questions that have probably been asked a billion times already.


Bot Builder(Posted 2004) [#12]
Well, DeltaYaw/DeltaPitch tell you the angle an object should rotate to to point at another object.

If, for instance, you wanted to know if the object was somewhere in front of you,doesn't matter if its a bit off then:

Function InFront(Entity,Object,Fuzz=10)
 If Abs(DeltaYaw(Entity,Object)-EntityYaw(Entity))<Fuzz Then
  If Abs(DeltaPitch(Entity,Object)-EntityPitch(Entity))<Fuzz Then
   Return 1
  EndIf
 EndIf
End Function


Coded it in the message box so who knows if it works. The fuziness is just the number of degrees pitch or yaw the entity can be pointed away from the object.


Rottbott(Posted 2004) [#13]
It won't work - you spelt Fuzziness wrong twice! Also I don't think you need to subtract the current pitch/yaw from the delta pitch/yaw.


martonic(Posted 2004) [#14]
I think you can just call

EntityInView(Camera, Object) and the return value (True/False) will give you the answer!

Good luck!


REDi(Posted 2004) [#15]
Why didn't I think of the delta commands... (not tested)
Function PointingAtEntity(SourceID,TargetID)
	If Abs(DeltaYaw(SourceID,TargetID))<0.00001
		If Abs(DeltaPitch(SourceID,TargetID))<0.00001 Then Return True
	EndIf
End Function

The delta commands don't seem to return 0, but this will do :)


Bot Builder(Posted 2004) [#16]
You do have to subtract the deltas from the actual angles - check out the example in the documentation:


Note that it is returning an absolute angle not a change in angle (which delta would imply).

Changed fuzziness to fuzz btw.


REDi(Posted 2004) [#17]
Oops, yep your right bot builder :)