Clean build meaning rebuild (deleting all *.obj and all)? If so, then yes.
As for some code using thing, exactly what do you need? I have several THINGs in my code right now. Not too many however, I believe that it''s just the player, the level, and a pointer/array to ten items (only four of which are used, I believe). This is all stored in a vector<thING*> called g_Things and I have THING* g_Player Initialized in my Init code. If there''s any specific bit of code you need to see please ask, as I need all the help I can get, however I have several thousand lines of code revolving around that class, and a couple hundred that use that class directly. Anyway, the most relevant code I can think to show is below:
All member functions of THING
vector<THING*> extern g_Things;void AddMessage(char*);THING::THING(){ ID = g_Things.size();}THING::THING(LPDIRECT3DDEVICE9 pd3dd, char* file = "", D3DXVECTOR3 p = D3DXVECTOR3(0.0f, 0.0f, 0.0f), int t = TT_THING){ ID = g_Things.size(); Health = MaxHealth = 100; Velocity = Orientation = D3DXVECTOR3(0.0f, 0.0f, 0.0f); pd3dDevice = pd3dd; MeshFile = file; Position = p; Type = t; m_CurWeapon = -1; Mesh = MESH(); Mesh.InitMesh(pd3dDevice, MeshFile); CreateSpheres();}THING::~THING(){ SAFE_RELEASE(pd3dDevice);}void THING::SetVelocity(D3DXVECTOR3 v){ Velocity = v;}D3DXVECTOR3 THING::GetVelocity(){ return Velocity;}void THING::SetPosition(D3DXVECTOR3 p){ Position = p; Mesh.m_Pos = p;}D3DXVECTOR3 THING::GetPosition(){ if(this == NULL) return D3DXVECTOR3(0.0f, 0.0f, 0.0f); return Position;}void THING::SetOrientation(D3DXVECTOR3 o){ Orientation = o; Mesh.m_Pitch = o.x; Mesh.m_Yaw = o.y; Mesh.m_Roll = o.z;}D3DXVECTOR3 THING::GetOrientation(){ return Orientation;}void THING::SetMesh(char* file){ MeshFile = &(*file); Mesh.InitMesh(pd3dDevice, file);}char* THING::GetMesh(){ return MeshFile;}void THING::Update(float elapsed, bool gravity){ if(fabsf(Velocity.x) < 0.001f) Velocity.x = 0.0f; if(fabsf(Velocity.y) < 0.001f) Velocity.y = 0.0f; if(fabsf(Velocity.z) < 0.001f) Velocity.z = 0.0f; Position += Velocity*elapsed; Mesh.m_Pos = Position; if(Health > MaxHealth) Health = MaxHealth; if(Health < 0) Health = 0;}void THING::Render(){ if(Type != TT_ROOM) Mesh.RenderMesh(); else Mesh.RenderMesh(D3DCULL_NONE);}void THING::CreateSpheres(int level){ root.level = 1; NumVerts = Mesh.m_NumVertices; D3DXComputeBoundingSphere(&Mesh.m_Vertices[0].pos, Mesh.m_NumVertices, sizeof(MODELVERTEX), &root.center, &root.radius);}void THING::Event(DWORD event, DWORD sender, bool issender, void* param){ switch(event) { case EVENT_NULL: { } break; case EVENT_TOUCHED: { AddMessage("Two things just touched!"); } break; case EVENT_DAMAGED: { int amt = *(int*)(param); Health -= amt; if(Health <= 0) { Health = 0; this->Event(EVENT_KILLED, sender, issender, 0); } if(Health >= MaxHealth) Health = MaxHealth; } break; case EVENT_KILLED: { //... } break; case EVENT_RESPAWN: { //... } break; case EVENT_CREATED: { //... } break; case EVENT_FIRE: { //... } break; }}
Init code: (ACTOR is a derived class from THING)
ACTOR Player = ACTOR(g_pd3dDevice, "meshes//player.x", D3DXVECTOR3(0.0f, 2.44f, 10.0f));g_Player = &Playerg_Things.push_back(&Player);
Part of MESH::InitMesh that intializes data of vertices, indices, and faces:
if(m_Vertices) delete[] m_Vertices; if(m_Indices) delete[] m_Indices; if(m_Faces) delete[] m_Faces; m_Vertices = 0; m_Faces = 0; m_Indices = 0; m_Vertices = new MODELVERTEX[m_pMesh->GetNumVertices()]; m_Faces = new D3DXPLANE[m_pMesh->GetNumFaces()]; m_Indices = new WORD[m_pMesh->GetNumFaces()*3]; byte *ptr=NULL; DWORD numVerts; m_NumVertices = numVerts = m_pMesh->GetNumVertices(); DWORD fvf=m_pMesh->GetFVF(); DWORD vertSize=D3DXGetFVFVertexSize(fvf); WORD* indices; hr = m_pMesh->LockVertexBuffer(D3DLOCK_READONLY,(void**)&ptr); if(FAILED(hr)) FatalError(); hr = m_pMesh->LockIndexBuffer(D3DLOCK_READONLY, (void**)&indices); if(FAILED(hr)) FatalError(); m_NumFaces = m_pMesh->GetNumFaces(); for (DWORD i=0;i<numVerts;i++) { m_Vertices[i] = *(MODELVERTEX*)(ptr); m_CenterOfMass += m_Vertices[i].pos; ptr+=vertSize; } m_pMesh->UnlockVertexBuffer(); for(unsigned int i=0;i<m_pMesh->GetNumFaces();i++) { m_Indices[i*3] = indices[i*3]; m_Indices[i*3+1] = indices[i*3+1]; m_Indices[i*3+2] = indices[i*3+2]; D3DXPLANE temp; D3DXVECTOR3 t0 = m_Vertices[m_Indices[3*i]].pos; D3DXVECTOR3 t1 = m_Vertices[m_Indices[3*i + 1]].pos; D3DXVECTOR3 t2 = m_Vertices[m_Indices[3*i + 2]].pos; D3DXPlaneFromPoints(&temp, &t0, &t1, &t2); m_Faces[i] = temp; } m_CenterOfMass /= m_NumVertices*1.0f; m_pMesh->UnlockIndexBuffer();
I have a lot more waiting, just ask. Thank you a thousand times for your help and time!