Skip to main content
gamedev.net
🔒 Locked

inverted coordinates

Started by Dragon_Strike Jul 11, 2006 at 3:49 PM 6 replies 1k views
Original Post
Dragon_Strike
Dragon_Strike
its a real noob question but i just an figure it out... my x and z coordinates are inverted... +x becomes -x and +z, -z when i look at it in the viewport... i have to look at the geometry from "below" without backface culling to get it right... how do i fix this?
Daniel Protopopov
Daniel Protopopov
Thats an interesting question. I recommend that you read this about how to ask questions we can give an answer to.
Besides that, the only guess I can come with is... none.
"Don't try. Do it now."
Endar
Endar
Show some code.

Show us the code where you create, or load whatever it is that is inverted. Show us some rendering code.

We can't do something with no information. Give us some and we'll do what we can.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
Dragon_Strike
Dragon_Strike
sry bout that... i was in abit of a hurry and was hoping that somebody else might ahve ad the same prob... brb with teh code
Dragon_Strike
Dragon_Strike

heres the code

opengl init

int InitGL(GLvoid)									{	glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );	glDisable( GL_TEXTURE_2D );								//disable two dimensional texture mapping	glDisable( GL_LIGHTING );								//disable lighting	glDisable( GL_BLEND );									//disable blending	glEnable(GL_CULL_FACE);	glEnable( GL_DEPTH_TEST );								//enable depth testing	glShadeModel( GL_SMOOTH );								//enable smooth shading	glClearDepth( 1.0 );									//depth buffer setup	glDepthFunc( GL_LEQUAL );								//set the type of depth test	glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );		glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );	//LoadRawFile("Data/Terrain.raw", MAP_SIZE * MAP_SIZE, g_HeightMap);		return TRUE;										}


Projection
GLvoid ReSizeGLScene(GLsizei width, GLsizei height)		// Resize And Initialize The GL Window{	if (height==0)										// Prevent A Divide By Zero By		height=1;										// Making Height Equal One	glViewport(0,0,width,height);						// Reset The Current Viewport	glMatrixMode(GL_PROJECTION);						// Select The Projection Matrix	glLoadIdentity();									// Reset The Projection Matrix	// Calculate The Aspect Ratio Of The Window.  Farthest Distance Changed To 500.0f (NEW)	gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 5000.0f);	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix	glLoadIdentity();									// Reset The Modelview Matrix}


my camera class

#ifndef _CAMERA_H_#define _CAMERA_H_#include "Vector.h"class CCAMERA{	public:		CVECTOR Position;		CVECTOR LookAt;		CVECTOR Forward;		CVECTOR Up;		CVECTOR Side;		float Yaw;		float Pitch;		CCAMERA()		{			Up.Set( 0.0f, 1.0f, 0.0f );			Side.Set( 1.0f, 0.0f, 0.0f );		}		CCAMERA(float px, float py, float pz, float lx, float ly, float lz, float ux, float uy, float uz)		{			Position.Set( px, py, pz );			LookAt.Set( lx, ly, lz );			Up.Set( ux, uy, uz );						Side.Set( 1.0f, 0.0f, 0.0f );		}		void Update()		{			if( ( Yaw>=360.0f) || ( Yaw<=-360.0f ) )				Yaw= 0.0f;			if( Pitch>80.0f )				Pitch= 80.0f;			if( Pitch<-80.0f )				Pitch= -80.0f;		     			float cosYaw  = cosf( DEG_TO_RAD( Yaw ) );			float sinYaw  = sinf( DEG_TO_RAD( Yaw ) );			float sinPitch= sinf( DEG_TO_RAD( Pitch ) );			float cosPitch= cosf( DEG_TO_RAD( Pitch ) );			Forward.x= sinYaw * cosPitch;			Forward.y= sinPitch;			Forward.z= cosPitch * -cosYaw;			LookAt = Position + Forward;			Side= Forward.CrossVector( Up );			gluLookAt(Position.x, Position.y, Position.z,				  LookAt.x, LookAt.y, LookAt.z,				  Up.x, Up.y, Up.z);		}		void SetPosition(float x, float y, float z)		{			Position.x = x; Position.y = y; Position.z = z;		}		void SetLookAt(float x, float y, float z)		{			LookAt.x = x; LookAt.y = y; LookAt.z = z;		}		void SetForward(float x, float y, float z)		{			Forward.x = x; Forward.y = y; Forward.z = z;		}		private:};#endif


and finnaly the rendering function.. im basicly just rendering 2 lines for the x and z axis...

void CTERRAIN::Render(CCAMERA* cam){		glBegin(GL_LINES);			glColor3f(1.0f, 0.0f, 0.0f);			glVertex3f(0,0, 0);			glVertex3f(256, 0,0);				glEnd();	glBegin(GL_LINES);			glColor3f(0.0f, 0.0f, 1.0f);			glVertex3f(0,0, 0);			glVertex3f(0,0, 256);				glEnd();		glColor4f(1.0f, 1.0f, 1.0f, 1.0f);	//RenderMatrix();} 

here is waht i get... the blue lin sjhould points z+ and the red x+... which it doesnt...

http://www.imagehosting.us/index.php?action=show&ident=1439842
JohnBolton
JohnBolton
Do you call CCAMERA::Update()? You left out the code that sets the position and orientation of the camera, so we can't tell what the scene is supposed to look like.

Quote:
Original post by Anonymous Poster
...If you want it differently you could try scaling the projection matrix by -1 on the axis you dont like..

Probably not the best advice. It is simpler to rotate the camera (unless you want to change the handedness).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Dragon_Strike
Dragon_Strike
Quote:
Original post by JohnBolton
Do you call CCAMERA::Update()? You left out the code that sets the position and orientation of the camera, so we can't tell what the scene is supposed to look like.

Quote:
Original post by Anonymous Poster
...If you want it differently you could try scaling the projection matrix by -1 on the axis you dont like..

Probably not the best advice. It is simpler to rotate the camera (unless you want to change the handedness).


well its doesnt rly do much...

int DrawGLScene(GLvoid)									{	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		glLoadIdentity();										Camera.Update();	//glScalef(scaleValue, scaleValue * HEIGHT_RATIO, scaleValue);	Terrain.Render(&Camera);	return TRUE;									}


the camera constructor is called like this

CCAMERA Camera(212, 50, 194,  0, 0, 0,  0, 1, 0);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.