Advertisement

Determining View

Started by December 28, 2003 05:47 PM
2 comments, last by SkinnyM 21 years, 2 months ago
Hi again, I have 2 scenes, and i want to see if something is in my view or not, one scene is on terrain the other is in a wide opengl room. I want to be a able to determine if player 2 is in player 1(me) view. What would i do? I was thinking to take player 1''s look vector and player 2''s position and taking the dot product between them. Would that work? Is that what most people do? Also, say i am on terrain, and the last idea i proposed did work, and player 2 is in my view. How on earth could i determine whether a big chunk of terrain is blocking player 1 from player 2? What do most people do to overcome this problem? Thanks alot!
"What we do in life, echos in eternity" -- Gladiator
Trace a line from player1 to Player2 and return the first object that the line hits, if that object is player2, bingo you can see him. If it isn''t there is something in the road.
Advertisement
your right about the dot product.. it needs to have each vector of the dot product normalized though.
As for the terrain occlusion, as anykey said, you need to do a line of sight test (ray-polygon). which is not easy, especially with terrain, because you absolulty _MUST_ space partition your geometry (otherwise you might end up doing half a million ray-triangle tests for a line of sight test for two guys standing next to each other).. an oct-tree or quad-tree is ideal here..

| - My (new) little website - | - email me - |
Alright, thanks for the replys.

I have a question about what you said by tracing a line, you are casting a line from player 1 to player 2 and seeing if there is anything in the way, this isnt telling if they are in view correct? If there is nothing in the way, then you use the dot product and see if they are in your view. and with those two steps, you know if you can see them right? Am i missing anything? Also, can someone point me to a tutorial on how to trace a line? Or can someone explain it to me

Thanks tons for the help
"What we do in life, echos in eternity" -- Gladiator

This topic is closed to new replies.

Advertisement