#### Archived

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

# 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.

## 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 on other sites
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/PIfloat absVal(float val){   if(val<0.0f){      return -val;}   return val;}//Rotation is passed in as degrees, Zoom is distance from viewervoid 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;   //NOW YOU HAVE YOUR 4 CORNERS}

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

typedef struct
{
float X;
float Y;
float Z;
}myVector;

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

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633665
• Total Posts
3013246
×