Advertisement

nooby programmer posting results

Started by January 09, 2004 07:52 AM
19 comments, last by TykeiL 21 years, 1 month ago
nup no textures yet there kind of trivial at the moment :O), im workin on my camera algorithms(if thats the right word)

cause even tho there are tutorials out there they dont explain things for a noob so im having to study spheres and such to work out the way to make my camera work the way i want it to, which is perfectly with complete freedom fo movement and its not easy,

because, firstly i''m using gluLookAt()
and so to get my camera to work the way i want it to, i want my camera target to track sperically around the outside of my camera,

then useing the vector from my camera to its target, translate my camera

and have the up vector based on the target vector, so i can move it around the world with no holds bar

but getting my target to track sperically around my camera is annoyingly difficult to understand and i dont want to cut and paste and hope it works, the current people making there camera class''s and using quaternions arent making things easy to understand(what teh bleep are quaternions?) i have alot of reading to do, and i quit school when i was in year 11 having not learnt my maths(stoopid me) i was good at maths too, just didnt learn any of the good stuff
!!My bRaiN is FiLLEd With HappY Juice!!
I was lucky enough to choose 4U maths in Yr 12 (not sure if you have the same units in SA) which included Complex Numbers - so most of the theory behind Quaternions wasn''t new to me. They''re hard though.
The Love Of Trees
Advertisement
:O) yeah, i wish there was a place i could go to learn just math, nothing else. i will inquire about such things

!!My bRaiN is FiLLEd With HappY Juice!!
!!My bRaiN is FiLLEd With HappY Juice!!
Here is a link for some online math references. Hope it helps.

Link

"If you are not willing to try, you will never succeed! If you never succeed, are you really trying?"

Grellin
~Global Developers Union~
"If you are not willing to try, you will never succeed!"GrellinC++ Game Programming
thanks a bundle :O) im sure that will help alot

!!My bRaiN is FiLLEd With HappY Juice!!
!!My bRaiN is FiLLEd With HappY Juice!!
heres what i have so far,
which resides in my drawglscene() function
if(camrotz< -1.5)// this is for limiting my camera to either straight up or straight down{    camrotz = -1.5;}if(camrotz>1.5)// etc{    camrotz = 1.5;}tarposx = camposx+(float)sin(camrotx)*(float)cos(camrotz);// the guts of my target positioning around my camera in relation to its positiontarposy = camposy+(float)cos(camrotx)*(float)cos(camrotz);tarposz = camposz+(float)sin(camrotz);tavectx = tarposx-camposx;// the target vector i want to use to find the upvector but have had no luck so far in finding the relationship between the twotavecty = tarposy-camposy;tavectz = tarposz-camposz;upvectx = 0.0f;// temporary up vector untill i find the wayupvecty = 0.0f;upvectz = 1.0f;gluLookAt(camposx,camposz,camposy,// glu look at, the z ad y coordinates i have swapped because i am used to a different coordinate system    tarposx,tarposz,tarposy,    upvectx,upvectz,upvecty);


now all the keypresses are related to campos and camrot, the thing im pissed off about is that i believe i will have to use another bunch of sine a cosine for finding the actual upvector, and then for strafing i will have to make another vector for the xvector , so i will have all 3 spacial axis taken care of using sine and cosine, but i see that as too much processor work, i want to find an easier way, although it seems as though i may be out of luck and this is usefull so far, but i would love it to be perfect.

!!My bRaiN is FiLLEd With HappY Juice!!
!!My bRaiN is FiLLEd With HappY Juice!!
Advertisement
The best way is to make a Camera class - include functions that automatically do all the calcs to move forward and backward etc. A good one is at Gametutorials.com
The Love Of Trees
yeah although i realise this because then you can have several camera''s situated throughout the scene and toggle between them, i want to get the maths of the camera out of the way first before i make a class(something i havent done yet) as i saod earlier im a noob ;o)

classes are still very new to me, so i try to avoid them for the time being, only when they become needed shall i use them and thats when i have multiple instances of an object

!!My bRaiN is FiLLEd With HappY Juice!!
!!My bRaiN is FiLLEd With HappY Juice!!
my advice is not to ignore them - they really make things alot neater - they must, otherwise people wouldn''t use them! The best thing about it is that you can just go Camera. and the list of functions you''ve created for your camera comes up automatically. Creating a camera class isn''t about having two or more cameras (that''s more of a perk) - it''s about having a neat system that is easy to use. Usually you only call CCAMERA Camera (assuming that''s the class name ) once, and it''s only there cause you have to do it. It''s just a way of organization.
The Love Of Trees
ok, ive gone and rewritten my program because i can, and im still not using classes because they are not necessary at this time,

my question today is about dynamic memory allocation, i have been reading this book which describes a little about it but since im using pointers to pointers to pionters and need to delete the memory i dont know whats going on with it. heres my code,
char Buffer[MAX_PATH]float ***geometry;float ***Ngeometry;float ***Cgeometry;float ***Tgeometry;int numfaces;void LoadModel(){		fstream scenefile;	scenefile.open(Scene,ios::in | ios::out);	scenefile >> Buffer;	numfaces = atoi(Buffer);	geometry = new GLfloat**[numfaces];	Ngeometry = new GLfloat**[numfaces];	Cgeometry = new GLfloat**[numfaces];	Tgeometry = new GLfloat**[numfaces];		for(int x = 0; x < numfaces; x++)	{		geometry[x] = new GLfloat*[3];		Cgeometry[x] = new GLfloat*[3];				Ngeometry[x] = new GLfloat*[3];		Tgeometry[x] = new GLfloat*[3];				for(int y = 0; y < 3; y++)		{			geometry[x][y] = new GLfloat[3];			Ngeometry[x][y] = new GLfloat[3];						Cgeometry[x][y] = new GLfloat[3];			Tgeometry[x][y] = new GLfloat[3];						scenefile >> Buffer;			geometry[x][y][0] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			geometry[x][y][1] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			geometry[x][y][2] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Ngeometry[x][y][0] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Ngeometry[x][y][1] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Ngeometry[x][y][2] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Cgeometry[x][y][0] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Cgeometry[x][y][1] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Cgeometry[x][y][2] = (GLfloat)atof(Buffer);						scenefile >> Buffer;			Tgeometry[x][y][0] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Tgeometry[x][y][1] = (GLfloat)atof(Buffer);			scenefile >> Buffer;			Tgeometry[x][y][2] = (GLfloat)atof(Buffer);		}	}}void UnLoadModel(){// this is where i need my deletion code but i have no clue// ive tried stuff like//delete [] **geometry; in nested for statements to delete each//tier of memory allocation but i get errors}


and my friend calls me crazy, wants me to make a class for my
vertex information,, i want to know how to make it without a
class thankyou.

thanks if anyone can help me with this, the book i have doesnt
go into much detail about deleting memory from pointers to pointers[/source]

!!My bRaiN is FiLLEd With HappY Juice!!

[edited by - TyKeiL on January 14, 2004 8:26:11 AM]

[edited by - TyKeiL on January 14, 2004 8:27:02 AM]
!!My bRaiN is FiLLEd With HappY Juice!!

This topic is closed to new replies.

Advertisement