Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Free flying tutorial

This topic is 5718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been looking at the radar class in this game tutorial, and I just dunnot understand one part of this code.
bool RADAR::GetRadarCoord(ACTOR *actor, VECTOR3D pos3D, VECTOR2D *radarPos2D)
	float radarR, radarCOS, radarSIN, rT;
	VECTOR3D deltaPos, v;

	//Compute coords of object relative to the actor

	deltaPos = pos3D-actor->worldPos;
	//Normalize that

	//Distance of blip from center of radar is cosine of angle

	//between view direction and direction to object

	radarR = actor->directionVector.DotProduct(deltaPos);
	//Determine projection of object on plane perpendicular

	//to viewing plane

	v = deltaPos+actor->directionVector*(-radarR);
	//Handle special case of null v, meaning object is on

	//line of sight

		(*radarPos2D) = center;
		return true;
	//Else normalize v

	//v is now a vector from the actor''s viewpoint to projection

	//of object on the actors''s plane. Compute angle from actors''s

	//up vector to object

	radarSIN = actor->rightVector.DotProduct(v);
	radarCOS = actor->upVector.DotProduct(v);
	//Convert to cartesian

	rT = (1.0f-radarR)/2.0f;
	(*radarPos2D).x = center.x+radius*(-rT)*radarSIN;
	(*radarPos2D).y = center.y+radius*rT*radarCOS;
	return true;
Could someone please explain the code after the "//convert to cartesian" comment. What is rT = 1.0f-radarR/2.0f for? radarR is the dot product of the look at vector and a vector from the players position to the enemys position.. I understand that this code is to get the 2d cords on the radar, but still don''t follow those last 3 lines.. Thanks a bunch.

Share this post

Link to post
Share on other sites
take a few 3D points and a calulator(maybe even a graphing one) plug it in, and watch what happens, you might get some messy numbers, but at least you will understand what happens and be able to follow it. It works for me.

Out - The Prox
Remember: No shortcuts...
They may be faster, but someday you will be penalized.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!