April 26, 2024, 02:31:17 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Help Please: No appropiate conversion exists...

Started by Todd Riggins, October 14, 2006, 09:31:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Todd Riggins

October 14, 2006, 09:31:08 PM Last Edit: October 14, 2006, 09:45:41 PM by Todd Riggins
I must be getting tired... I cant see what Im doing wrong here...

My CreateMesh member function of C3DModel returns a pointer to a CustomMesh Structure. Is that allowed?

When compiled... I get the "No appropiate conversion exists" error at line 136.

snippet of CreateModel.src:

.
.
.
C3DModel *this3DModel;
CustomMesh *tempMesh;
unsigned int v0,v1,v2,v3;

this3DModel=new(C3DModel,1);

[line 136] tempMesh=this3DModel->CreateMesh(pScreen,0); // 0=VERTEX0TEXTURE, 1=VERTEX1TEXTURE, etc...
.
.
.


In class_c3dmodel.inc:

In Class C3DModel, the declare of CreateMesh is like this:

declare CreateMesh(C3DScreen thisScreen, unsigned int vertextype),CustomMesh *;

The CustomMesh structure is in the class_c3dmodel.inc if you want to look at it...

Ofcoarse, I have no idea if all of this is going to work or not. I'm just in the process in trying to apply these functions to see if the do work or not. Most likely will get some more errors after this one.


Any help in spotting what I did wrong here will be much apprieciated...




[Note: This is an Aurora project. Not a single file compile]
CreateModel.src:

//
//Arrow keys to move camera.
//PgUp/PgDn to pan up and down.
//Z and X to rotate on Z axis.
#include "class_c3dmodel.inc"

declare import,timeGetTime(),int;

C3DMesh m, sphere_blue, sphere_yellow;


sub main()
{
C3DScreen s;
C3DCamera c;

//C3DMesh *planet;

C3DModel *Quad;

C3DObject scene;
C3DLight light;
CDirectInput di;
float fadjust,fTarget;
//target 60FPS for camera movement
fTarget = 1.0f / /*FPS*/60.0f * 1000.0f;
fAdjust = 1.0f;

s.CreateWindowed(0,0,640,480,AWS_CAPTION|AWS_VISIBLE|AWS_SIZE|AWS_CENTERED,0,"Ellipsoid 2 Poly Test - ESC exits",NULL,false);
di.Init(s);
c.Create(s);
c.Position(0,0,-11);
c.Orient(0,0,1,0,1,0);
c.SetBackPlane(1000);

//m.EnableLighting(false);
//m.UseVertexColor(true);
//m.SetVisible(true);



Quad = Create3DModel(s);


//set our callback function and a parameter that will be passed
//when the device has been lost, such as an alt-tab switch
//s.SetRestoreCallback(&restore,planet);


light.Create(s,LIGHT_POINT,1);
light.Position(-80,20,-150);
light.SetAttenuation(0,1/200.0,0);
light.SetSpecular(.5,.5,.5,1);
light.SetAmbient(.4,.4,.4,1);

scene.CreateScene(s);
//sphere_blue.createSphere(s,15,.1,false);
//sphere_yellow.createSphere(s,15,.1,false);

scene.AddChild(light);
//scene.AddChild(m);
//scene.AddChild(planet);
//scene.AddChild(sphere_blue);
//scene.AddChild(sphere_yellow);

Quad->AddToScene(scene);

//D3DMATERIAL mat;
//mat.Diffuse = RGBAtoD3DC(RGBA(0,0,255,255));
//mat.Specular = RGBAtoD3DC(RGBA(0,0,255,255));
//mat.Ambient = RGBAtoD3DC(RGBA(0,0,0,0));
//mat.Emissive = RGBAtoD3DC(RGBA(0,0,0,0));
//mat.Power = 0.0;
//sphere_blue.SetMaterial(mat);
//sphere_blue.UseVertexColor(false);


//mat.Diffuse = RGBAtoD3DC(RGBA(255,255,0,255));
//mat.Specular = RGBAtoD3DC(RGBA(255,255,0,255));
//mat.Ambient = RGBAtoD3DC(RGBA(0,0,0,0));
//mat.Emissive = RGBAtoD3DC(RGBA(0,0,0,0));
//mat.Power = 0.0;
//sphere_yellow.SetMaterial(mat);
//sphere_yellow.UseVertexColor(false);


int fps = 0;
int startTime;

do
{
oldpos=c.GetPosition();

startTime = timeGetTime();
//check for keys and move camera accordingly
IF di.KeyDown(DIK_UP)
c.Move(0.0f,.25f * fAdjust);
IF di.KeyDown(DIK_DOWN)
c.Move(0.0f,-.25f * fAdjust);
IF di.KeyDown(DIK_RIGHT)
c.Rotate(1*.01745 * fAdjust,0,0);
IF di.KeyDown(DIK_LEFT)
c.Rotate(-1*.01745 * fAdjust,0,0);
IF di.KeyDown(DIK_Z)
c.Rotate(0,0,-1 *.01745 * fAdjust);
IF di.KeyDown(DIK_X)
c.Rotate(0,0,1 *.01745 * fAdjust);
IF di.KeyDown(DIK_PRIOR)
c.Rotate(0,-1 *.01745 * fAdjust,0);
IF di.KeyDown(DIK_NEXT)
c.Rotate(0,1 *.01745 * fAdjust,0);
IF di.KeyDown(DIK_R)
c.LookAt(0,0,0);



s.Clear(RGBA(0,0,0,255));
s.BeginScene(c);
scene.Draw();
s.RenderText(0,10,"FPS:"+NumToStr(fps),RGBA(255,255,0,255));
s.RenderText(0,30,"Use arrow keys,PgUp,PgDn to move around",RGBA(255,255,0,255));
fps = s.RenderScene();
fAdjust = (timeGetTime() - startTime) / fTarget;
}until di.KeyDown(DIK_ESCAPE);
Scene.Free();
}

SUB Create3DModel(C3DScreen* pScreen),C3DModel *
{
C3DModel *this3DModel;
CustomMesh *tempMesh;
unsigned int v0,v1,v2,v3;

this3DModel=new(C3DModel,1);

tempMesh=this3DModel->CreateMesh(pScreen,0); // 0=VERTEX0TEXTURE, 1=VERTEX1TEXTURE, etc...

v0=this3DModel->AddVertex(tempMesh,-5,-5,0);
this3DModel->VertexDiffuse(tempMesh,v0,255,0,0,255);
this3DModel->VertexNormal(tempMesh,v0,0.0f,0.0f,-1.0f);

v1=this3DModel->AddVertex(tempMesh,-5,5,0);
this3DModel->VertexDiffuse(tempMesh,v1,0,0,255,255);
this3DModel->VertexNormal(tempMesh,v1,0.0f,0.0f,-1.0f);

v2=this3DModel->AddVertex(tempMesh,5,5,0);
this3DModel->VertexDiffuse(tempMesh,v2,0,0,255,255);
this3DModel->VertexNormal(tempMesh,v2,0.0f,0.0f,-1.0f);

v3=this3DModel->AddVertex(tempMesh,5,-5,0);
this3DModel->VertexDiffuse(tempMesh,v3,0,0,255,255);
this3DModel->VertexNormal(tempMesh,v3,0.0f,0.0f,-1.0f);


this3DModel->AddTriangle(tempMesh,v0,v1,v2);
this3DModel->AddTriangle(tempMesh,v2,v3,v0);

RETURN this3DModel;
}

SUB restore(void *pParam)
{
//CreateQuad(null,pParam);
RETURN;
}




SUB RGBAtoD3DC(UINT col),D3DCOLORVALUE
{
D3DCOLORVALUE ret;
ret.b = (col & 0xff) / 255.0;
ret.g = ((col & 0xff00) >> 8) / 255.0;
ret.r = ((col & 0xff0000) >> 16) / 255.0;
ret.a = ((col & 0xff000000) >> 24) / 255.0;
return ret;
}




class_c3dmodel.inc:

// C3DModel.inc include file
// By: Todd Riggins

struct CustomV0T
{
VERTEX0TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV1T
{
VERTEX1TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV2T
{
VERTEX2TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV3T
{
VERTEX3TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV4T
{
VERTEX4TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV5T
{
VERTEX5TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV6T
{
VERTEX6TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV7T
{
VERTEX7TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}
struct CustomV8T
{
VERTEX8TEXTURE vertexlist;// holds a list of vertices for defining the shape of this mesh with.
int red,green,blue,alpha;
}

struct TriSet
{
unsigned int v1;
unsigned int v2;
unsigned int v3;
}

struct CustomMesh
{
C3DMesh *Mesh; // this actaully mesh that Aurora 3D creates.
TriSet *indexlist; // holds a list of indices for building triangle polys with.
word indextotal; // number of indices this mesh has.
// Below, a specific CustomV#T will only be used according to the vertextype value.
CustomV0T *v0t;
CustomV1T *v1t;
CustomV2T *v2t;
CustomV3T *v3t;
CustomV4T *v4t;
CustomV5T *v5t;
CustomV6T *v6t;
CustomV7T *v7t;
CustomV8T *v8t;
int vertextotal; // number of vertices this mesh has.
unsigned int vertextype; // what vertex#texture structure type this mesh uses.
}

class C3DModel
{
//private:
unsigned int meshtotal;
CustomMesh *ModelMesh;
C3DScreen screen;
float temp_x,temp_y,temp_z;
float temp_nx,temp_ny,temp_nz;
int temp_red,temp_green,temp_blue,temp_alpha;
float temp_u,temp_v;

//private:
declare C3DModel;
declare _C3DModel;
declare NullCustomMesh(unsigned int meshnumber);
declare SizeOfTextureType(unsigned int vertextype),unsigned int;
declare CheckVertexListPtr(CustomMesh *thisMesh),void *;
declare GetFVF(CustomMesh *thisMesh),unsigned int;
declare AllocateCorrectVertexList(CustomMesh *thisMesh);
declare UpdateCorrectVertexList(CustomMesh *thisMesh,
int vertexnumber,
int updateposition,
float x,
float y,
float z,
int updatenormal,
float nx,
float ny,
float nz,
int updatediffuse,
int red,
int green,
int blue,
int alpha,
int updatecoord,
int coordnumber,
float u,
float v);
declare SetCorrectVertexListValues(CustomMesh *thisMesh,int vertexnumber,int coordnumber);
declare CreateCustomMesh(CustomMesh *thisMesh);
declare RemoveAll();


// user functions
//public:
declare CreateMesh(C3DScreen thisScreen, unsigned int vertextype),CustomMesh *;
declare AddToScene(C3DObject *scene);
declare AddVertex(CustomMesh *thisMesh,float x, float y, float z),int;
declare AddTriangle(CustomMesh *thisMesh,int v1, int v2, int v3),int;
declare VertexCoords(CustomMesh *thisMesh, unsigned int vertexnumber, float x, float y, float z);
declare VertexNormal(CustomMesh *thisMesh, unsigned int vertexnumber, float nx, float ny, float nz);
declare VertexDiffuse(CustomMesh *thisMesh, unsigned int vertexnumber, int red, int green, int blue, int alpha);
declare VertexTexCoords(CustomMesh *thisMesh, unsigned int vertexnumber, unsigned int coordnumber, float u, float v);
declare VertexX(CustomMesh *thisMesh, unsigned int vertexnumber),float;
declare VertexY(CustomMesh *thisMesh, unsigned int vertexnumber),float;
declare VertexZ(CustomMesh *thisMesh, unsigned int vertexnumber),float;
declare VertexNX(CustomMesh *thisMesh, unsigned int vertexnumber),float;
declare VertexNY(CustomMesh *thisMesh, unsigned int vertexnumber),float;
declare VertexNZ(CustomMesh *thisMesh, unsigned int vertexnumber),float;
declare VertexRed(CustomMesh *thisMesh, unsigned int vertexnumber),int;
declare VertexGreen(CustomMesh *thisMesh, unsigned int vertexnumber),int;
declare VertexBlue(CustomMesh *thisMesh, unsigned int vertexnumber),int;
declare VertexU(CustomMesh *thisMesh, unsigned int vertexnumber, opt unsigned int unumber=0),float;
declare VertexV(CustomMesh *thisMesh, unsigned int vertexnumber, opt unsigned int vnumber=0),float;
declare ClearMesh(CustomMesh *thisMesh);
}




c3dmodel.src

// C3DModel.iba Source File
// By: Todd Riggins
#include "class_c3dmodel.inc"

DECLARE IMPORT,malloc(unsigned int size),void *;
DECLARE IMPORT,realloc(void *memblock,unsigned int size),void *;
DECLARE IMPORT,free(void *memblock);

//////////////////////
// Public Functions //
//////////////////////
C3DModel::CreateMesh(C3DScreen *thisScreen, unsigned int vertextype),CustomMesh *
{
if (ModelMesh==NULL)
{
meshtotal+=1;
screen=thisScreen;
ModelMesh=malloc(sizeof(CustomMesh)); // create the first mesh handle for this model.
NullCustomMesh(meshtotal-1);
ModelMesh[meshtotal-1]->vertextype=vertextype;
return ModelMesh[meshtotal-1]; // return pointer to the first mesh handle.
}
if (screen!=thisScreen)
{
MessageBox(0,"A new mesh must have the same C3DScreen"+chr$(10)+"object as the first mesh. ( returning NULL )","Info",MB_OK | MB_ICONEXCLAMATION );
return NULL;
}
meshtotal+=1;
ModelMesh = realloc(ModelMesh,meshtotal*sizeof(CustomMesh));
NullCustomMesh(meshtotal-1);
ModelMesh[meshtotal-1]->vertextype=vertextype;
return ModelMesh[meshtotal-1]; // return pointer to this new mesh handle.
}

C3DModel::AddToScene(C3DObject *scene)
{
if (ModelMesh!=NULL)
{
for(unsigned int i=0;i<meshtotal;i++)
{
if (ModelMesh[i]->Mesh!=NULL)
scene->AddChild(ModelMesh[i]->Mesh);
}
}
}

C3DModel::AddVertex(CustomMesh *thisMesh,float x, float y, float z),int
{
if (thisMesh!=NULL)
{
thisMesh->vertextotal+=1;
AllocateCorrectVertexList(thisMesh);
UpdateCorrectVertexList(thisMesh,thisMesh->vertextotal-1,1,x,y,z, 1,0.0f,0.0f,0.0f, 1,255,255,255,255, 0,0,0.0f,0.0f);
if (thisMesh->vertextype>0)
{
for(unsigned int i=1;i<thisMesh->vertextype;i++)
{
UpdateCorrectVertexList(thisMesh,thisMesh->vertextotal-1,0,0.0f,0.0f,0.0f, 0,0.0f,0.0f,0.0f, 0,0,0,0,0, 1,i,0.0f,0.0f);
}
}
return thisMesh->vertextotal-1;
}
return -1; // Can't add a vertex to a NULL ModelMesh(ie: a ModelMesh that holds mesh data that hasn't been initialized)
}

C3DModel::AddTriangle(CustomMesh *thisMesh,int v1, int v2, int v3),int
{
if (thisMesh!=NULL)
{
thisMesh->indextotal+=1;
if (thisMesh->indexlist=NULL)
{
thisMesh->indexlist=malloc(sizeof(TriSet)); // create the first mesh handle for this model.
thisMesh->indexlist[0]->v1=v1;
thisMesh->indexlist[0]->v2=v2;
thisMesh->indexlist[0]->v3=v3;
thisMesh->Mesh=new(C3DMesh,1);
thisMesh->Mesh->CreateMesh(screen,thisMesh->vertextotal,thisMesh->indextotal*3,GetFVF(thisMesh->vertextype));
CreateCustomMesh(thisMesh);
}
else
{
thisMesh->indexlist=realloc(thisMesh->indexlist,thisMesh->indextotal*sizeof(TriSet));
thisMesh->indexlist[thisMesh->indextotal-1]->v1=v1;
thisMesh->indexlist[thisMesh->indextotal-1]->v2=v2;
thisMesh->indexlist[thisMesh->indextotal-1]->v3=v3;
thisMesh->Mesh->ReallocateMesh(thisMesh->vertextotal,thisMesh->indextotal*3,GetFVF(thisMesh->vertextype));
CreateCustomMesh(thisMesh);
}
return thisMesh->indextotal-1;
}
return -1; // Can't add a vertex to a NULL ModelMesh(ie: a ModelMesh that holds mesh data that hasn't been initialized)
}

C3DModel::VertexCoords(CustomMesh *thisMesh, unsigned int vertexnumber, float x, float y, float z)
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
UpdateCorrectVertexList(thisMesh,thisMesh->vertextotal-1,1,x,y,z, 0,0.0f,0.0f,0.0f, 0,0,0,0,0, 0,0,0.0f,0.0f);
}
}


C3DModel::VertexNormal(CustomMesh *thisMesh, unsigned int vertexnumber, float nx, float ny, float nz)
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
UpdateCorrectVertexList(thisMesh,thisMesh->vertextotal-1,0,0.0f,0.0f,0.0f, 1,nx,ny,nz, 0,0,0,0,0, 0,0,0.0f,0.0f);
}
}

C3DModel::VertexDiffuse(CustomMesh *thisMesh, unsigned int vertexnumber, int red, int green, int blue, int alpha)
{
if (thisMesh!=NULL)
UpdateCorrectVertexList(thisMesh,thisMesh->vertextotal-1,0,0.0f,0.0f,0.0f, 0,0.0f,0.0f,0.0f, 1,red,green,blue,alpha, 0,0,0.0f,0.0f);
}

C3DModel::VertexTexCoords(CustomMesh *thisMesh, unsigned int vertexnumber, unsigned int coordnumber, float u, float v)
{
if (thisMesh!=NULL)
{
if((coordnumber>0) && (coordnumber<=thisMesh->vertextype))
UpdateCorrectVertexList(thisMesh,thisMesh->vertextotal-1,0,0.0f,0.0f,0.0f, 0,0.0f,0.0f,0.0f, 0,0,0,0,0, 1,coordnumber,u,v);
}
}

C3DModel::VertexX(CustomMesh *thisMesh, unsigned int vertexnumber),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_x;
}
return 0.0f;
}

C3DModel::VertexY(CustomMesh *thisMesh, unsigned int vertexnumber),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_y;
}
return 0.0f;
}

C3DModel::VertexZ(CustomMesh *thisMesh, unsigned int vertexnumber),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_z;
}
return 0.0f;
}

C3DModel::VertexNX(CustomMesh *thisMesh, unsigned int vertexnumber),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_nx;
}
return 0.0f;
}

C3DModel::VertexNY(CustomMesh *thisMesh, unsigned int vertexnumber),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_ny;
}
return 0.0f;
}

C3DModel::VertexNZ(CustomMesh *thisMesh, unsigned int vertexnumber),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_nz;
}
return 0.0f;
}

C3DModel::VertexRed(CustomMesh *thisMesh, unsigned int vertexnumber),int
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_red;
}
return 0;
}

C3DModel::VertexGreen(CustomMesh *thisMesh, unsigned int vertexnumber),int
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_green;
}
return 0;
}

C3DModel::VertexBlue(CustomMesh *thisMesh, unsigned int vertexnumber),int
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,0);

return temp_blue;
}
return 0;
}

C3DModel::VertexU(CustomMesh *thisMesh, unsigned int vertexnumber, opt unsigned int unumber=0),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,unumber);

return temp_u;
}
return 0.0f;
}

C3DModel::VertexV(CustomMesh *thisMesh, unsigned int vertexnumber, opt unsigned int vnumber=0),float
{
if (thisMesh!=NULL)
{
if((vertexnumber>=0) && (vertexnumber<thisMesh->vertextotal))
SetCorrectVertexListValues(thisMesh,vertexnumber,vnumber);

return temp_v;
}
return 0.0f;
}
// Deletes the C3DMesh, vertexlist and indexlist out of the CustomMesh. The CustomMesh is still left intaked to be reused.
C3DModel::ClearMesh(CustomMesh *thisMesh)
{
if (thisMesh!=NULL)
{
if (thisMesh->mesh!=NULL)
delete thisMesh->mesh;

delete thisMesh->indexlist;
if (thisMesh->v0t!=NULL) delete thisMesh->v0t;
if (thisMesh->v1t!=NULL) delete thisMesh->v1t;
if (thisMesh->v2t!=NULL) delete thisMesh->v2t;
if (thisMesh->v3t!=NULL) delete thisMesh->v3t;
if (thisMesh->v4t!=NULL) delete thisMesh->v4t;
if (thisMesh->v5t!=NULL) delete thisMesh->v5t;
if (thisMesh->v6t!=NULL) delete thisMesh->v6t;
if (thisMesh->v7t!=NULL) delete thisMesh->v7t;
if (thisMesh->v8t!=NULL) delete thisMesh->v8t;
thisMesh->mesh=NULL;
thisMesh->indexlist=NULL;
thisMesh->v0t=NULL;
thisMesh->v1t=NULL;
thisMesh->v2t=NULL;
thisMesh->v3t=NULL;
thisMesh->v4t=NULL;
thisMesh->v5t=NULL;
thisMesh->v6t=NULL;
thisMesh->v7t=NULL;
thisMesh->v8t=NULL;
thisMesh->indextotal=0;
thisMesh->vertextotal=0;
thisMesh->vertextype=-1;

}
}

///////////////////////
// Private Functions //
///////////////////////
C3DModel::C3DModel()
{
ModelMesh=NULL;
meshtotal=0;
}

C3DModel::_C3DModel()
{
if (ModelMesh!=NULL)
{
RemoveAll();
}
}

C3DModel::NullCustomMesh(unsigned int meshnumber)
{
// used only for init purposes... and for sanity purposes...
ModelMesh[meshnumber]->mesh=NULL;
ModelMesh[meshnumber]->indexlist=NULL;
ModelMesh[meshnumber]->indextotal=0;
ModelMesh[meshnumber]->v0t=NULL;
ModelMesh[meshnumber]->v1t=NULL;
ModelMesh[meshnumber]->v2t=NULL;
ModelMesh[meshnumber]->v3t=NULL;
ModelMesh[meshnumber]->v4t=NULL;
ModelMesh[meshnumber]->v5t=NULL;
ModelMesh[meshnumber]->v6t=NULL;
ModelMesh[meshnumber]->v7t=NULL;
ModelMesh[meshnumber]->v8t=NULL;
ModelMesh[meshnumber]->vertextotal=0;
ModelMesh[meshnumber]->vertextype=-1;
}

C3DModel::SizeOfTextureType(unsigned int vertextype),unsigned int
{
if(vertextype==0) return sizeof(CustomV0T);
if(vertextype==1) return sizeof(CustomV1T);
if(vertextype==2) return sizeof(CustomV2T);
if(vertextype==3) return sizeof(CustomV3T);
if(vertextype==4) return sizeof(CustomV4T);
if(vertextype==5) return sizeof(CustomV5T);
if(vertextype==6) return sizeof(CustomV6T);
if(vertextype==7) return sizeof(CustomV7T);
if(vertextype==8) return sizeof(CustomV8T);

return 0; // this should never happen
}

C3DModel::CheckVertexListPtr(CustomMesh *thisMesh),void *
{
if (thisMesh->vertextype==0) return thisMesh->v0t;
if (thisMesh->vertextype==1) return thisMesh->v1t;
if (thisMesh->vertextype==2) return thisMesh->v2t;
if (thisMesh->vertextype==3) return thisMesh->v3t;
if (thisMesh->vertextype==4) return thisMesh->v4t;
if (thisMesh->vertextype==5) return thisMesh->v5t;
if (thisMesh->vertextype==6) return thisMesh->v6t;
if (thisMesh->vertextype==7) return thisMesh->v7t;
if (thisMesh->vertextype==8) return thisMesh->v8t;

return NULL; // this should never happen
}

C3DModel::GetFVF(CustomMesh *thisMesh),unsigned int
{
unsigned int fvf;
fvf=0;
if (thisMesh->vertextype==0) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE;
if (thisMesh->vertextype==1) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1;
if (thisMesh->vertextype==2) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2;
if (thisMesh->vertextype==3) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3;
if (thisMesh->vertextype==4) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX4;
if (thisMesh->vertextype==5) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX5;
if (thisMesh->vertextype==6) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX6;
if (thisMesh->vertextype==7) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX7;
if (thisMesh->vertextype==8) fvf=D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX8;

return fvf;
}

C3DModel::AllocateCorrectVertexList(CustomMesh *thisMesh)
{

if (CheckVertexListPtr(thisMesh)==NULL)
{
if (thisMesh->vertextype==0) thisMesh->v0t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==1) thisMesh->v1t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==2) thisMesh->v2t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==3) thisMesh->v3t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==4) thisMesh->v4t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==5) thisMesh->v5t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==6) thisMesh->v6t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==7) thisMesh->v7t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
if (thisMesh->vertextype==8) thisMesh->v8t=malloc(SizeOfTextureType(thisMesh->vertextype)); // create the first mesh handle for this model.
}
else
{
if (thisMesh->vertextype==0) thisMesh->v0t=realloc(thisMesh->v0t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==1) thisMesh->v1t=realloc(thisMesh->v1t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==2) thisMesh->v2t=realloc(thisMesh->v2t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==3) thisMesh->v3t=realloc(thisMesh->v3t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==4) thisMesh->v4t=realloc(thisMesh->v4t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==5) thisMesh->v5t=realloc(thisMesh->v5t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==6) thisMesh->v6t=realloc(thisMesh->v6t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==7) thisMesh->v7t=realloc(thisMesh->v7t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
if (thisMesh->vertextype==8) thisMesh->v8t=realloc(thisMesh->v8t,thisMesh->vertextotal*SizeOfTextureType(thisMesh->vertextype));
}
}


C3DModel::UpdateCorrectVertexList(CustomMesh *thisMesh,
int vertexnumber,
int updateposition,
float x,
float y,
float z,
int updatenormal,
float nx,
float ny,
float nz,
int updatediffuse,
int red,
int green,
int blue,
int alpha,
int updatecoord,
int coordnumber,
float u,
float v)
{
if(thisMesh!=NULL)
{
if (thisMesh->vertextype==0)
{
if (updateposition==1) thisMesh->v0t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v0t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v0t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v0t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v0t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v0t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v0t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v0t[vertexnumber]->red=red;
thisMesh->v0t[vertexnumber]->green=green;
thisMesh->v0t[vertexnumber]->blue=blue;
thisMesh->v0t[vertexnumber]->alpha=alpha;
}
}
else
if (thisMesh->vertextype==1)
{
if (updateposition==1) thisMesh->v1t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v1t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v1t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v1t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v1t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v1t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v1t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v1t[vertexnumber]->red=red;
thisMesh->v1t[vertexnumber]->green=green;
thisMesh->v1t[vertexnumber]->blue=blue;
thisMesh->v1t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v1t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v1t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}
else
if (thisMesh->vertextype==2)
{
if (updateposition==1) thisMesh->v2t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v2t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v2t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v2t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v2t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v2t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v2t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v2t[vertexnumber]->red=red;
thisMesh->v2t[vertexnumber]->green=green;
thisMesh->v2t[vertexnumber]->blue=blue;
thisMesh->v2t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v2t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v2t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}
else
if (thisMesh->vertextype==3)
{
if (updateposition==1) thisMesh->v3t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v3t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v3t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v3t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v3t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v3t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v3t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v3t[vertexnumber]->red=red;
thisMesh->v3t[vertexnumber]->green=green;
thisMesh->v3t[vertexnumber]->blue=blue;
thisMesh->v3t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v3t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v3t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}
if (thisMesh->vertextype==4)
{
if (updateposition==1) thisMesh->v4t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v4t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v4t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v4t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v4t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v4t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v4t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v4t[vertexnumber]->red=red;
thisMesh->v4t[vertexnumber]->green=green;
thisMesh->v4t[vertexnumber]->blue=blue;
thisMesh->v4t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v4t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v4t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}
if (thisMesh->vertextype==5)
{
if (updateposition==1) thisMesh->v5t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v5t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v5t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v5t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v5t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v5t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v5t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v5t[vertexnumber]->red=red;
thisMesh->v5t[vertexnumber]->green=green;
thisMesh->v5t[vertexnumber]->blue=blue;
thisMesh->v5t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v5t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v5t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}
if (thisMesh->vertextype==6)
{
if (updateposition==1) thisMesh->v6t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v6t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v6t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v6t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v6t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v6t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v6t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v6t[vertexnumber]->red=red;
thisMesh->v6t[vertexnumber]->green=green;
thisMesh->v6t[vertexnumber]->blue=blue;
thisMesh->v6t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v6t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v6t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}
if (thisMesh->vertextype==7)
{
if (updateposition==1) thisMesh->v7t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v7t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v7t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v7t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v7t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v7t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v7t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v7t[vertexnumber]->red=red;
thisMesh->v7t[vertexnumber]->green=green;
thisMesh->v7t[vertexnumber]->blue=blue;
thisMesh->v7t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v7t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v7t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}
if (thisMesh->vertextype==8)
{
if (updateposition==1) thisMesh->v8t[vertexnumber]->vertexlist.position.x=x;
if (updateposition==1) thisMesh->v8t[vertexnumber]->vertexlist.position.y=y;
if (updateposition==1) thisMesh->v8t[vertexnumber]->vertexlist.position.z=z;
if (updatenormal==1) thisMesh->v8t[vertexnumber]->vertexlist.normal.x=nx;
if (updatenormal==1) thisMesh->v8t[vertexnumber]->vertexlist.normal.y=ny;
if (updatenormal==1) thisMesh->v8t[vertexnumber]->vertexlist.normal.z=nz;
if (updatediffuse==1)
{
thisMesh->v8t[vertexnumber]->vertexlist.diffuseColor=RGBA(red,green,blue,alpha);
thisMesh->v8t[vertexnumber]->red=red;
thisMesh->v8t[vertexnumber]->green=green;
thisMesh->v8t[vertexnumber]->blue=blue;
thisMesh->v8t[vertexnumber]->alpha=alpha;
}
if ((updatecoord==1)&&(coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
thisMesh->v8t[vertexnumber]->vertexlist.texCoords[coordnumber].x=u;
thisMesh->v8t[vertexnumber]->vertexlist.texCoords[coordnumber].y=v;
}
}


}
}

C3DModel::SetCorrectVertexListValues(CustomMesh *thisMesh,int vertexnumber,int coordnumber)
{
if(thisMesh!=NULL)
{
temp_x=0.0f;
temp_y=0.0f;
temp_z=0.0f;
temp_nx=0.0f;
temp_ny=0.0f;
temp_nz=0.0f;
temp_red=255;
temp_green=255;
temp_blue=255;
temp_alpha=255;
temp_u=0.0f;
temp_v=0.0f;

if (thisMesh->vertextype==0)
{
temp_x=thisMesh->v0t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v0t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v0t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v0t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v0t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v0t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v0t[vertexnumber]->red;
temp_green=thisMesh->v0t[vertexnumber]->green;
temp_blue=thisMesh->v0t[vertexnumber]->blue;
temp_alpha=thisMesh->v0t[vertexnumber]->alpha;
}
else
if (thisMesh->vertextype==1)
{
temp_x=thisMesh->v1t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v1t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v1t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v1t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v1t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v1t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v1t[vertexnumber]->red;
temp_green=thisMesh->v1t[vertexnumber]->green;
temp_blue=thisMesh->v1t[vertexnumber]->blue;
temp_alpha=thisMesh->v1t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v1t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v1t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}
else
if (thisMesh->vertextype==2)
{
temp_x=thisMesh->v2t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v2t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v2t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v2t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v2t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v2t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v2t[vertexnumber]->red;
temp_green=thisMesh->v2t[vertexnumber]->green;
temp_blue=thisMesh->v2t[vertexnumber]->blue;
temp_alpha=thisMesh->v2t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v2t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v2t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}
else
if (thisMesh->vertextype==3)
{
temp_x=thisMesh->v3t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v3t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v3t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v3t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v3t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v3t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v3t[vertexnumber]->red;
temp_green=thisMesh->v3t[vertexnumber]->green;
temp_blue=thisMesh->v3t[vertexnumber]->blue;
temp_alpha=thisMesh->v3t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v3t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v3t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}
if (thisMesh->vertextype==4)
{
temp_x=thisMesh->v4t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v4t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v4t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v4t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v4t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v4t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v4t[vertexnumber]->red;
temp_green=thisMesh->v4t[vertexnumber]->green;
temp_blue=thisMesh->v4t[vertexnumber]->blue;
temp_alpha=thisMesh->v4t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v4t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v4t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}
if (thisMesh->vertextype==5)
{
temp_x=thisMesh->v5t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v5t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v5t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v5t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v5t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v5t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v5t[vertexnumber]->red;
temp_green=thisMesh->v5t[vertexnumber]->green;
temp_blue=thisMesh->v5t[vertexnumber]->blue;
temp_alpha=thisMesh->v5t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v5t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v5t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}
if (thisMesh->vertextype==6)
{
temp_x=thisMesh->v6t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v6t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v6t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v6t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v6t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v6t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v6t[vertexnumber]->red;
temp_green=thisMesh->v6t[vertexnumber]->green;
temp_blue=thisMesh->v6t[vertexnumber]->blue;
temp_alpha=thisMesh->v6t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v6t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v6t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}
if (thisMesh->vertextype==7)
{
temp_x=thisMesh->v7t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v7t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v7t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v7t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v7t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v7t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v7t[vertexnumber]->red;
temp_green=thisMesh->v7t[vertexnumber]->green;
temp_blue=thisMesh->v7t[vertexnumber]->blue;
temp_alpha=thisMesh->v7t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v7t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v7t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}
if (thisMesh->vertextype==8)
{
temp_x=thisMesh->v8t[vertexnumber]->vertexlist.position.x;
temp_y=thisMesh->v8t[vertexnumber]->vertexlist.position.y;
temp_z=thisMesh->v8t[vertexnumber]->vertexlist.position.z;
temp_nx=thisMesh->v8t[vertexnumber]->vertexlist.normal.x;
temp_ny=thisMesh->v8t[vertexnumber]->vertexlist.normal.y;
temp_nz=thisMesh->v8t[vertexnumber]->vertexlist.normal.z;
temp_red=thisMesh->v8t[vertexnumber]->red;
temp_green=thisMesh->v8t[vertexnumber]->green;
temp_blue=thisMesh->v8t[vertexnumber]->blue;
temp_alpha=thisMesh->v8t[vertexnumber]->alpha;
if ((coordnumber>0)&&(coordnumber<=thisMesh->vertextype))
{
temp_u=thisMesh->v8t[vertexnumber]->vertexlist.texCoords[coordnumber].x;
temp_v=thisMesh->v8t[vertexnumber]->vertexlist.texCoords[coordnumber].y;
}
}


}
}


C3DModel::CreateCustomMesh(CustomMesh *thisMesh)
{
unsigned int i=0;
unsigned int j=0;
if(thisMesh!=NULL)
{
if (thisMesh->vertextype==0)
{
VERTEX0TEXTURE *pVB;
word *pIB;
pVB = thisMesh->Mesh->LockVertexBuffer();
pIB = thisMesh->Mesh->LockIndexBuffer();
for(i=0; i<thisMesh->vertextotal-1; i++)
{
pVB[i]->position.x=thisMesh->v0t[i]->vertexlist.position.x;
pVB[i]->position.y=thisMesh->v0t[i]->vertexlist.position.y;
pVB[i]->position.z=thisMesh->v0t[i]->vertexlist.position.z;
pVB[i]->normal.x=thisMesh->v0t[i]->vertexlist.normal.x;
pVB[i]->normal.y=thisMesh->v0t[i]->vertexlist.normal.y;
pVB[i]->normal.z=thisMesh->v0t[i]->vertexlist.normal.z;
pVB[i]->diffuseColor=thisMesh->v0t[i]->vertexlist.diffuseColor;
}
for(i=0; i<(thisMesh->indextotal*3)-1; i+=3)
{
pIB[i]=thisMesh->indexlist[i/3]->v1;
pIB[i+1]=thisMesh->indexlist[i/3]->v2;
pIB[i+2]=thisMesh->indexlist[i/3]->v3;
}
thisMesh->Mesh->UnlockIndexBuffer();
thisMesh->Mesh->UnlockVertexBuffer();
}
if (thisMesh->vertextype==1)
{
VERTEX1TEXTURE *pVB1;
word *pIB1;
pVB1 = thisMesh->Mesh->LockVertexBuffer();
pIB1 = thisMesh->Mesh->LockIndexBuffer();
for(i=0; i<thisMesh->vertextotal-1; i++)
{
pVB1[i]->position.x=thisMesh->v1t[i]->vertexlist.position.x;
pVB1[i]->position.y=thisMesh->v1t[i]->vertexlist.position.y;
pVB1[i]->position.z=thisMesh->v1t[i]->vertexlist.position.z;
pVB1[i]->normal.x=thisMesh->v1t[i]->vertexlist.normal.x;
pVB1[i]->normal.y=thisMesh->v1t[i]->vertexlist.normal.y;
pVB1[i]->normal.z=thisMesh->v1t[i]->vertexlist.normal.z;
pVB1[i]->diffuseColor=thisMesh->v1t[i]->vertexlist.diffuseColor;
for(j=0;j<thisMesh->vertextype-1;j++)
{
pVB1[i]->texCoords[j].x=thisMesh->v1t[i]->vertexlist.texCoords[j].x;
pVB1[i]->texCoords[j].y=thisMesh->v1t[i]->vertexlist.texCoords[j].y;
}
}
for(i=0; i<(thisMesh->indextotal*3)-1; i+=3)
{
pIB1[i]=thisMesh->indexlist[i/3]->v1;
pIB1[i+1]=thisMesh->indexlist[i/3]->v2;
pIB1[i+2]=thisMesh->indexlist[i/3]->v3;
}
thisMesh->Mesh->UnlockIndexBuffer();
thisMesh->Mesh->UnlockVertexBuffer();
}
thisMesh->Mesh->SetVisible(TRUE);
}
}

C3DModel::RemoveAll()
{
if (ModelMesh!=NULL)
{
for(unsigned int i=1;i<meshtotal;i++)
{
if (ModelMesh[i-1]->mesh!=NULL)
delete ModelMesh[i-1]->mesh;

delete ModelMesh[i-1]->indexlist;
if (ModelMesh[i-1]->v0t!=NULL) delete ModelMesh[i-1]->v0t;
if (ModelMesh[i-1]->v1t!=NULL) delete ModelMesh[i-1]->v1t;
if (ModelMesh[i-1]->v2t!=NULL) delete ModelMesh[i-1]->v2t;
if (ModelMesh[i-1]->v3t!=NULL) delete ModelMesh[i-1]->v3t;
if (ModelMesh[i-1]->v4t!=NULL) delete ModelMesh[i-1]->v4t;
if (ModelMesh[i-1]->v5t!=NULL) delete ModelMesh[i-1]->v5t;
if (ModelMesh[i-1]->v6t!=NULL) delete ModelMesh[i-1]->v6t;
if (ModelMesh[i-1]->v7t!=NULL) delete ModelMesh[i-1]->v7t;
if (ModelMesh[i-1]->v8t!=NULL) delete ModelMesh[i-1]->v8t;
ModelMesh[i-1]->mesh=NULL;
ModelMesh[i-1]->indexlist=NULL;
ModelMesh[i-1]->v0t=NULL;
ModelMesh[i-1]->v1t=NULL;
ModelMesh[i-1]->v2t=NULL;
ModelMesh[i-1]->v3t=NULL;
ModelMesh[i-1]->v4t=NULL;
ModelMesh[i-1]->v5t=NULL;
ModelMesh[i-1]->v6t=NULL;
ModelMesh[i-1]->v7t=NULL;
ModelMesh[i-1]->v8t=NULL;
}
free(ModelMesh);
ModelMesh=NULL;
}
}
Brought to you buy: http://www.exodev.com

Todd Riggins

Also learned that local scope of variables being created inside if statements do not stay that way as I get a compiler error.
Will local scope inside if statements and the like be supported?


This wont work...

First if statemnt has in it:
VERTEX0TEXTURE *pVB;         
word *pIB;
The other has:
VERTEX1TEXTURE *pVB;         
word *pIB;

if (thisMesh->vertextype==0)
{
VERTEX0TEXTURE *pVB;
word *pIB;
pVB = thisMesh->Mesh->LockVertexBuffer();
pIB = thisMesh->Mesh->LockIndexBuffer();
for(i=0; i<thisMesh->vertextotal-1; i++)
{
pVB[i]->position.x=thisMesh->v0t[i]->vertexlist.position.x;
pVB[i]->position.y=thisMesh->v0t[i]->vertexlist.position.y;
pVB[i]->position.z=thisMesh->v0t[i]->vertexlist.position.z;
pVB[i]->normal.x=thisMesh->v0t[i]->vertexlist.normal.x;
pVB[i]->normal.y=thisMesh->v0t[i]->vertexlist.normal.y;
pVB[i]->normal.z=thisMesh->v0t[i]->vertexlist.normal.z;
pVB[i]->diffuseColor=thisMesh->v0t[i]->vertexlist.diffuseColor;
}
for(i=0; i<(thisMesh->indextotal*3)-1; i+=3)
{
pIB[i]=thisMesh->indexlist[i/3]->v1;
pIB[i+1]=thisMesh->indexlist[i/3]->v2;
pIB[i+2]=thisMesh->indexlist[i/3]->v3;
}
thisMesh->Mesh->UnlockIndexBuffer();
thisMesh->Mesh->UnlockVertexBuffer();
}
if (thisMesh->vertextype==1)
{
VERTEX1TEXTURE *pVB;
word *pIB;
pVB = thisMesh->Mesh->LockVertexBuffer();
pIB = thisMesh->Mesh->LockIndexBuffer();
for(i=0; i<thisMesh->vertextotal-1; i++)
{
pVB[i]->position.x=thisMesh->v1t[i]->vertexlist.position.x;
pVB[i]->position.y=thisMesh->v1t[i]->vertexlist.position.y;
pVB[i]->position.z=thisMesh->v1t[i]->vertexlist.position.z;
pVB[i]->normal.x=thisMesh->v1t[i]->vertexlist.normal.x;
pVB[i]->normal.y=thisMesh->v1t[i]->vertexlist.normal.y;
pVB[i]->normal.z=thisMesh->v1t[i]->vertexlist.normal.z;
pVB[i]->diffuseColor=thisMesh->v1t[i]->vertexlist.diffuseColor;
for(j=0;j<thisMesh->vertextype-1;j++)
{
pVB[i]->texCoords[j].x=thisMesh->v1t[i]->vertexlist.texCoords[j].x;
pVB[i]->texCoords[j].y=thisMesh->v1t[i]->vertexlist.texCoords[j].y;
}
}
for(i=0; i<(thisMesh->indextotal*3)-1; i+=3)
{
pIB[i]=thisMesh->indexlist[i/3]->v1;
pIB[i+1]=thisMesh->indexlist[i/3]->v2;
pIB[i+2]=thisMesh->indexlist[i/3]->v3;
}
thisMesh->Mesh->UnlockIndexBuffer();
thisMesh->Mesh->UnlockVertexBuffer();
}


But this will obviously work...

one if statement has:
VERTEX0TEXTURE *pVB;         
word *pIB;
the other has:
VERTEX1TEXTURE *pVB1;         
word *pIB1;

if (thisMesh->vertextype==0)
{
VERTEX0TEXTURE *pVB;
word *pIB;
pVB = thisMesh->Mesh->LockVertexBuffer();
pIB = thisMesh->Mesh->LockIndexBuffer();
for(i=0; i<thisMesh->vertextotal-1; i++)
{
pVB[i]->position.x=thisMesh->v0t[i]->vertexlist.position.x;
pVB[i]->position.y=thisMesh->v0t[i]->vertexlist.position.y;
pVB[i]->position.z=thisMesh->v0t[i]->vertexlist.position.z;
pVB[i]->normal.x=thisMesh->v0t[i]->vertexlist.normal.x;
pVB[i]->normal.y=thisMesh->v0t[i]->vertexlist.normal.y;
pVB[i]->normal.z=thisMesh->v0t[i]->vertexlist.normal.z;
pVB[i]->diffuseColor=thisMesh->v0t[i]->vertexlist.diffuseColor;
}
for(i=0; i<(thisMesh->indextotal*3)-1; i+=3)
{
pIB[i]=thisMesh->indexlist[i/3]->v1;
pIB[i+1]=thisMesh->indexlist[i/3]->v2;
pIB[i+2]=thisMesh->indexlist[i/3]->v3;
}
thisMesh->Mesh->UnlockIndexBuffer();
thisMesh->Mesh->UnlockVertexBuffer();
}
if (thisMesh->vertextype==1)
{
VERTEX1TEXTURE *pVB1;
word *pIB1;
pVB1 = thisMesh->Mesh->LockVertexBuffer();
pIB1 = thisMesh->Mesh->LockIndexBuffer();
for(i=0; i<thisMesh->vertextotal-1; i++)
{
pVB1[i]->position.x=thisMesh->v1t[i]->vertexlist.position.x;
pVB1[i]->position.y=thisMesh->v1t[i]->vertexlist.position.y;
pVB1[i]->position.z=thisMesh->v1t[i]->vertexlist.position.z;
pVB1[i]->normal.x=thisMesh->v1t[i]->vertexlist.normal.x;
pVB1[i]->normal.y=thisMesh->v1t[i]->vertexlist.normal.y;
pVB1[i]->normal.z=thisMesh->v1t[i]->vertexlist.normal.z;
pVB1[i]->diffuseColor=thisMesh->v1t[i]->vertexlist.diffuseColor;
for(j=0;j<thisMesh->vertextype-1;j++)
{
pVB1[i]->texCoords[j].x=thisMesh->v1t[i]->vertexlist.texCoords[j].x;
pVB1[i]->texCoords[j].y=thisMesh->v1t[i]->vertexlist.texCoords[j].y;
}
}
for(i=0; i<(thisMesh->indextotal*3)-1; i+=3)
{
pIB1[i]=thisMesh->indexlist[i/3]->v1;
pIB1[i+1]=thisMesh->indexlist[i/3]->v2;
pIB1[i+2]=thisMesh->indexlist[i/3]->v3;
}
thisMesh->Mesh->UnlockIndexBuffer();
thisMesh->Mesh->UnlockVertexBuffer();
}
Brought to you buy: http://www.exodev.com

Ionic Wind Support Team

declare CreateMesh(C3DScreen thisScreen, unsigned int vertextype),CustomMesh *;

Should be:

declare CreateMesh(C3DScreen *thisScreen, unsigned int vertextype),CustomMesh *;

That is were the error is coming from, not the return. 
Ionic Wind Support Team

Ionic Wind Support Team

Quote from: Todd Riggins on October 14, 2006, 09:38:20 PM
Also learned that local scope of variables being created inside if statements do not stay that way as I get a compiler error.
Will local scope inside if statements and the like be supported?


This wont work...

First if statemnt has in it:
VERTEX0TEXTURE *pVB;         
word *pIB;
The other has:
VERTEX1TEXTURE *pVB;         
word *pIB;


No plans on block scoping at the moment.  Why not just use a void pointer and typecast to the correct one?
Ionic Wind Support Team

Todd Riggins

Arg... thanks for seeing that.

I guess I could typecast, but it would be about the same amount of typing...  ;D

Brought to you buy: http://www.exodev.com

Ionic Wind Support Team

Actually you can just use a pointer to VERTEX0TEXTURE then you only need to typecast when setting the texture coordinates.
Ionic Wind Support Team

Todd Riggins

Ah Thanks for the tip. I see what you are talking about.

Well, my malloc call is causing some kind of windows error fit.

Just downloaded the Battlefield 2142 demo... gonna take a break...
Brought to you buy: http://www.exodev.com