void CObjectPlane::LoadMesh(void){ string strmesh = "PlaneMeshSYS00"; unsigned int hashed = gMeshes->GetMeshIndexFromFileName(strmesh.c_str()); if(gMeshes->IsMeshLoaded(strmesh.c_str()) == false) { float width, height; height = width = 5.0f; HRESULT hr = S_OK; unsigned int indices, verts, poly = 2; verts = 4; indices = poly * 3; LPDIRECT3DVERTEXBUFFER9 vb; LPD3DXMESH mbuf = NULL; hr = D3DXCreatePolygon(g_pd3dDevice,width,4, &mbuf, NULL); hr = D3DXComputeNormals(mbuf, NULL); LPD3DXMESH mb2; hr = mbuf->CloneMeshFVF(0,MY_VERT_FVF,g_pd3dDevice,&mb2); SAFE_RELEASE(mbuf); verts = mb2->GetNumVertices(); MY_VERT* myVerts = new MY_VERT[verts]; mb2->LockVertexBuffer(0, (void**)&vb); memcpy(myVerts,vb,verts*sizeof(MY_VERT)); float minx,maxx,miny,maxy; float tx,ty; minx = maxx = miny = maxy = 0.5; myVerts[1].x = width/2; myVerts[1].y = height/2; myVerts[1].tu = 1.0f; myVerts[1].tv = 1.0f; myVerts[1].nz = 1.0f; myVerts[2].x = width/2; myVerts[2].y = -height/2; myVerts[2].tu = 1.0f; myVerts[2].tv = 0.0f; myVerts[2].nz = 1.0f; myVerts[3].x = -width/2; myVerts[3].y = -height/2; myVerts[3].tu = 0.0f; myVerts[3].tv = 0.0f; myVerts[3].nz = 1.0f; myVerts[4].x = -width/2; myVerts[4].y = height/2; myVerts[4].tu = 0.0f; myVerts[4].tv = 1.0f; myVerts[4].nz = 1.0f; for(unsigned int i=0;i { tx = myVerts.x; ty = myVerts.y; if(tx < minx) minx = tx; if(tx > maxx) maxx = tx; if(ty < miny) miny = ty; if(ty > maxy) maxy = ty; myVerts.color = 0xFFFFFFFF; } myVerts[0].tu = 0.5f; myVerts[0].tv = 0.5f; myVerts[0].nz = 1.0f; for(unsigned int i=1;i { tx = myVerts.x; ty = myVerts.y; if(tx == minx) { myVerts.tu = 1.0f; //myVerts.tv = 1.0f; } if(tx == maxx) { myVerts.tu = 0.0f; //myVerts.tv = 0.0f; } if(ty == miny) { myVerts.tv = 1.0f; //myVerts.tu = 0.0f; } if(ty == maxy) { myVerts.tv = 0.0f; //myVerts.tu = 1.0f; } } memcpy(vb,myVerts,verts*sizeof(MY_VERT)); mb2->UnlockVertexBuffer(); LPDIRECT3DINDEXBUFFER9 ib; unsigned short INDICES[] = { 0,2,1, 0,3,2, 0,4,3, 0,1,4 }; mb2->LockIndexBuffer(0,(void**)&ib); memcpy(ib,INDICES,sizeof(unsigned short)*12); mb2->UnlockIndexBuffer(); gMeshes->AddMesh(strmesh.c_str(), mb2); delete[] myVerts; Direction = Vector3(0.0f,0.0f,1.0f); } pMesh = gMeshes->GetMeshPointerFromIndex(hashed); SetTexture("ORGANIC5.BMP"); //pTexture = gTextures->GetPointerFromFilename("ORGANIC5.BMP");}
I fixed the generated plane to be square (more so), and not a diamond shape like in my last post. Which got my to my all desired sky box class. I need to get it linked up to the camera so its always there, but I do have it rendering w/o z checking so its a real sky box. Blah blah, it was a bit of work getting the texture coords to work again, and then I had to fiddle with the indices to get it to wraw CW. And for all the work, here is the screenie. And here is the new plane generation code.
Previous Entry
not alot of time
Next Entry
immersed
Advertisement
Latest Entries
I love the morning!
932 views
Not bad.
1076 views
Its a little better.
952 views
Zoned out.
969 views
more
1031 views
Slow down champ.
866 views
I'll be back
829 views
Something programming related.
856 views
Busy.
982 views
oh teh noes!!
863 views
Advertisement