Original Post
Hi, I know that the code below is v messy, and that is most likely the reason I am not getting the items showing up on screen :-( Please can someboby check through the code below and see if I have ommitted anything, I have looked at this for ages, and can't seem to find any problems? I have tried many other ways to draw and none seem to work, although glPrint does?? Everything else renders to screen, but the ships are nowhere to be seen. Could somebody help me on this. The models used are Milkshape models. I hope that I have included everything nescessary (possible overload??) TIA: //Firstly data in entity.h.. //Code to create ship entity //The main rendering loop //AstField_Render //loop to draw all actice ships //The following routine does not draw anything to screen, and this is my problem.; //Code to draw 2d menus etc.
typedef struct Ship_
{
bool alive;
int ast; //Location
int team; //Team id
int infleet; //id of fleet (0=not in fleet)
float ra,rx,ry,rz; //Rotation
float vx,vy,vz; //velocity
float sx,sy,sz; //Location In Sector
float ax,ay,az; //Location on Asteroid
int armour; //
int HullType; //
int power; //
int HardPoints[4]; //
int UniqueID; //Ship
int corder; //Current Order
ShipOrders Orders; //Order Queue
}Ship;
int Fleet_NewShip(Ship &ship,int a,int arm,
float ax,float ay,float az,
float sx,float sy,float sz,
float ra,float rx,float ry,float rz,
float vx,float vy,float vz,
int team,int ht,
int h0,int h1,int h2,int h3,
int fid,int pw)
{
ship.ast = a;
ship.armour = arm;
ship.ax = ax; ship.ay = ay; ship.az = az;
ship.HardPoints[0] = h0; ship.HardPoints[1] = h1;
ship.HardPoints[2] = h2; ship.HardPoints[3] = h3;
ship.HullType = ht;
ship.infleet = fid;
ship.power = pw;
ship.ra = ra; ship.rx = rx; ship.ry = ry; ship.rz = rz;
ship.sx = sx; ship.sy = sy; ship.sz = sz;
ship.team = team;
ship.vx = vx; ship.vy = vy; ship.vz = vz;
ship.UniqueID = Fleet_UtilGenUniqueID();
ship.alive = true;
return 1;
}
void Fleet_CreateNewShip(){
Fleet_NewShip(ships[0],a,10,1.0f,1.0f,0.0f,
1.0f,1.0f,1.0f,
1.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,
0,1,1,2,3,4,0,100);
}
void RenderScene() {
gcvt(playercash,3,cash);
glColor3f(1.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
if(!menu) {
DisplayGameBackGround(TEX_GBKGD4);
gluLookAt(g_Camera.mPos.x, g_Camera.mPos.y, g_Camera.mPos.z,
g_Camera.mView.x, g_Camera.mView.y, g_Camera.mView.z,
g_Camera.mUp.x, g_Camera.mUp.y, g_Camera.mUp.z);
camerax=g_Camera.mPos.x;
cameraz=g_Camera.mPos.z;
switch (MENU_ACTIVE_SCREEN)
{
case MENU_SCREEN_AST_FIELD:
{
AstField_Render();
Fleets_DrawSectorShips();
if( keys[VK_LBUTTON] == TRUE
&& MouseLook == 0
/*&& InMenus == 0 */)
AstField_DoMouseDown();
OrthoProject();
}
break;
}
}
SwapBuffers(g_hDC);
timer+=inc;
}
//End of Main Render Loop
void AstField_Render() {
glLoadIdentity();
int a;
float bx,by,bz;
float sx,sy,sz;
glColor3f(0.0f,1,1);
// Shoulod be using Update Angle Based On The Clock..
if( angle += 1.0f == 360) angle = 0;
glEnable( GL_TEXTURE_2D );
for( a=0;a<MAX_ASTEROIDS;a++)
{
if( Asts[a].known[PlayerID] )
{
glPushMatrix();
bx = Asts[a].px; by = Asts[a].py; bz = Asts[a].pz;
glTranslated(bx,by,bz);
sx = Asts[a].sx; sy = Asts[a].sy; sz = Asts[a].sz;
glRotatef (angle, sx, sy, sz);
Ast_Draw_FieldModel(Asts[a].ModelID);
glPopMatrix();
}
}
}
void Ast_Draw_FieldModel(int a){
pModel[a]->draw();
}
void Fleets_DrawSectorShips() {
int s;
for( s=0;s<MaxShips;s++)
{
if( ships[s].alive )
{
DrawSecShip(ships[s].sx,ships[s].sy,ships[s].sz,
ships[s].ra,ships[s].rx,ships[s].ry,ships[s].rz);
}
}
}
void DrawSecShip(float sx,float sy,float sz,
float ra,float rx,float ry,float rz) {
glPushMatrix();
glTranslatef(sx,sy,sz);
glRotatef (ra,rx, ry, rz);
pModel[5]->draw();
glPopMatrix();
/*
This glPrintFast routine works, and it has no change to the modelmatrix..
glPrintFast(10,10,"Ship Drawing",1);
GLvoid glPrintFast(GLint x, GLint y, char *string, int set) {
if (set>1)set=1;
glBlendFunc(GL_ZERO,GL_ONE_MINUS_SRC_COLOR);
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, g_Texture[TEX_FONT]);
glLoadIdentity();
glTranslatef((float)x,(float)y,0);
glScalef(3.0f,3.0f,0.0f);
glListBase(base-32+(128*set));
glCallLists(strlen(string),GL_BYTE,string);
glDisable(GL_BLEND);
}
/*
}
void OrthoProject() {
int c;
glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // Set Up An Ortho Screen
glOrtho(0,SCREEN_WIDTH,0,SCREEN_HEIGHT,-1,1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity();
// ScreenBorder_Render();
// GUI_Render();
if( InMenus == 1 )
{
glEnable(GL_BLEND);
glBindTexture(GL_TEXTURE_2D, g_Texture[TEX_GUI10]);
glLoadIdentity(); glBegin(GL_QUADS);
glTexCoord2f(0.0f,0.0f);
glVertex2i(0,0); glTexCoord2f(1.0f,0.0f);
glVertex2i(256,0); glTexCoord2f(1.0f,1.0f);
glVertex2i(256,256); glTexCoord2f(0.0f,1.0f);
glVertex2i(0,256); glEnd();
glDisable(GL_BLEND);
//Check Mouse positions and keys
GUI_DoMouseInMenus();
}
//Draw Mouse...
CrossHair();
glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_DEPTH_TEST);
}