Jump to content
  • Advertisement


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

NeViL tHe dEVil

How much Grid to Render

This topic is 5443 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''m rendering a Grid in a 3rd person view and I need to know the extreme points I''m giong to render. the plane for the grid is reached with the follow code:
glTranslatef(0.0f, 0.0f, Zoom);
glRotatef(-45.0f, 1.0f, 0.0f, 0.0f);
glRotatef(Rotation, 0.0f, 1.0f, 0.0f);
------------------------------------------------------ Regret Nothing - Learn Everything

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
I think I know what you are TRYING to ask. I am assuming you want the grid to face you the viewer. I also assume that you want the grid to be a distance of "Zoom" away from the viewer. Also, if your "Rotation" variable in that second glRotatef() varies... than you are not drawing a plane at all. more like a funny curved surface. I am also going to assume that your "Rotation" variable is in degrees & it follows the right-hand-rule around the Y-axis. Some simple trig should give you the extreme points of your grid, I will assume you just want the corners, so here goes...

#include <math.h>
#define PI 3.1415926535897932384626433832795
#define DTORK PI/180.0f
#define RTODK 180.0f/PI

float absVal(float val){
return -val;}
return val;}

//Rotation is passed in as degrees, Zoom is distance from viewer

void MakeGrid(float Zoom, float Rotation)
//find corners, starting in top left, going counter clockwise

//top left corner of grid

float x1 = -absVal(float(tan(Rotation*DTORK))*Zoom);
float y1 = Zoom;
float z1 = -Zoom;
//top right corner of grid

float x2 = -x1;
float y2 = Zoom;
float z2 = -Zoom;
//bottom right corner of grid

float x3 = -x1;
float y3 = -Zoom;
float z3 = -Zoom;
//bottom left corner of grid

float x4 = x1;
float y4 = -Zoom;
float z4 = -Zoom;


NOTE: you should probably also typedef your own vector datatype, something like this:

typedef struct
float X;
float Y;
float Z;

to make things easier to keep track of than all those floats in the example above.

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!