3D Calculation help ...

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

3D Calculation help ...

Post by Baker »

From the classic r_mirroralpha, we have this ...

Code: Select all

d = DotProduct (r_refdef.vieworg, mirror_plane->normal) - mirror_plane->dist;
	VectorMA (r_refdef.vieworg, -2*d, mirror_plane->normal, r_refdef.vieworg);

	d = DotProduct (vpn, mirror_plane->normal);
	VectorMA (vpn, -2*d, mirror_plane->normal, vpn);

	r_refdef.viewangles[0] = -asin (vpn[2])/M_PI*180;
	r_refdef.viewangles[1] = atan2 (vpn[1], vpn[0])/M_PI*180;
	r_refdef.viewangles[2] = -r_refdef.viewangles[2];
1) I need the common point that both the mirror and the player are looking at.

One method that comes to mind is solving for the ray of player pov (v_forward) and mirror player pov (mirror v_forward) and getting intersection, but I worry about floating point precision foiling me) and this seems too complex, like I am missing something obvious. Like maybe something to do with VectorMA (vpn, -2*d, mirror_plane->normal, vpn); but I'm lacking the 3D math creativity at the moment ...
2) Then I need that point 1 unit out from the mirror plane. (Probably just a VectorMA on that point using mirror_plane->normal )

I'm trying to add server side vis for the point of the mirror and add it a given player's vis --- if he can see the mirror.

Thanks in advance for any help and outside chance I'll self-solve and post solution if that happens.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: 3D Calculation help ...

Post by Spike »

break it down more.

'I need the common point that both the mirror and the player are looking at.'
not sure what you mean by that. intersection point of the player's forward vector with the mirror plane? then projected outwards along the reflected plane?
is that not a bit... pointless?

surely if you can potentially see a mirror, then you can potentially see anything that mirror can see too - just merge the pvs bits. Remember that pvs does not include any sort of directional information, thus considering the direction the mirror actually faces is generally pointless in the spirit of pvs.
most of the overlap with pvs is just that - overlap. if your pvs contains info from multiple points that can already see each other, then your pvs isn't going to add much extra either.

If you're attempting to bounce rays off mirrors for culling entities to avoid wallhacks... I wouldn't bother. Your player will be traveling too fast anyway, and the mirror surface is probably going to be too small and at a distance giving too narrow a 'window' for it to actually all line up. Personally I'd just use the central point of the mirror (if only because this means you no longer have to trace from the player to some random point on the mirror on a per-ent basis).
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: 3D Calculation help ...

Post by Baker »

I was thinking of frustum culling it or using it as reference point for sv_cullentities. Moatly to tighten up entities included.
Spike wrote:Personally I'd just use the central point of the mirror (if only because this means you no longer have to trace from the player to some random point on the mirror on a per-ent basis).
This isn't a bad idea. Considering my options here ...

This has a few annoying "factors" in the equation, I need to pick one and go with it.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply