wademcgillis
Guest
|
|
« Reply #1911 on: March 16, 2011, 05:12:21 PM » |
|
We're supposed to put why we're mad at programming, right?
I think you did fine I don't understand what's wrong. I even made the method output to a text file to manually check the colors, but it still happens even though the text file says everything is OK. The only thing that fixes it is hardcoding the colors, which I don't want to do. void CTools::DrawBlockModify(FLOAT xx1, FLOAT yy1, FLOAT zz1, FLOAT xx2, FLOAT yy2, FLOAT zz2, IDirect3DTexture9 *texture, FLOAT hrepeat, FLOAT vrepeat, BOOL left, BOOL back, BOOL right, BOOL front, BOOL top, BOOL bottom, D3DCOLOR awesome) { // THIS CULLS RIGHT (counterclockwise) FLOAT x1 = min(xx1, xx2); FLOAT x2 = max(xx1, xx2); FLOAT y1 = min(yy1, yy2); FLOAT y2 = max(yy1, yy2); FLOAT z1 = min(zz1, zz2); FLOAT z2 = max(zz1, zz2); int numVertices = 0; sVertex Verts[36]; unsigned char shade = 160; D3DCOLOR lightcolor = awesome;//game->GetGraphics()->GetColor(); D3DCOLOR shadowcolor = awesome;//game->GetGraphics()->GetColor(); if (front) { // Front Verts[numVertices] = MAKEVERTEX( x2, y2, z1, shadowcolor, hrepeat, 0.0f ); Verts[numVertices+1] = MAKEVERTEX( x2, y1, z1, shadowcolor, hrepeat, vrepeat ); Verts[numVertices+2] = MAKEVERTEX( x1, y1, z1, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+3] = MAKEVERTEX( x1, y1, z1, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+4] = MAKEVERTEX( x1, y2, z1, shadowcolor, 0.0f, 0.0f ); Verts[numVertices+5] = MAKEVERTEX( x2, y2, z1, shadowcolor, hrepeat, 0.0f ); numVertices += 6; } if (back) { // Back Verts[numVertices] = MAKEVERTEX( x1, y1, z2, shadowcolor, hrepeat, vrepeat ); Verts[numVertices+1] = MAKEVERTEX( x2, y1, z2, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+2] = MAKEVERTEX( x2, y2, z2, shadowcolor, 0.0f, 0.0f ); Verts[numVertices+3] = MAKEVERTEX( x1, y1, z2, shadowcolor, hrepeat, vrepeat ); Verts[numVertices+4] = MAKEVERTEX( x2, y2, z2, shadowcolor, 0.0f, 0.0f ); Verts[numVertices+5] = MAKEVERTEX( x1, y2, z2, shadowcolor, hrepeat, 0.0f ); numVertices += 6; } if (left) { // Left Verts[numVertices] = MAKEVERTEX( x1, y2, z2, shadowcolor, 0.0f, 0.0f ); Verts[numVertices+1] = MAKEVERTEX( x1, y1, z1, shadowcolor, hrepeat, vrepeat ); Verts[numVertices+2] = MAKEVERTEX( x1, y1, z2, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+3] = MAKEVERTEX( x1, y2, z2, shadowcolor, 0.0f, 0.0f ); Verts[numVertices+4] = MAKEVERTEX( x1, y2, z1, shadowcolor, hrepeat, 0.0f ); Verts[numVertices+5] = MAKEVERTEX( x1, y1, z1, shadowcolor, hrepeat, vrepeat ); numVertices += 6; } if (right) { // Right Verts[numVertices] = MAKEVERTEX( x2, y2, z2, shadowcolor, hrepeat, 0.0f ); Verts[numVertices+1] = MAKEVERTEX( x2, y1, z2, shadowcolor, hrepeat, vrepeat ); Verts[numVertices+2] = MAKEVERTEX( x2, y1, z1, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+3] = MAKEVERTEX( x2, y1, z1, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+4] = MAKEVERTEX( x2, y2, z1, shadowcolor, 0.0f, 0.0f ); Verts[numVertices+5] = MAKEVERTEX( x2, y2, z2, shadowcolor, hrepeat, 0.0f ); numVertices += 6; } if (top) { //game->DebugString("Top:"); //game->DebugColor(shadowcolor); // Top Verts[numVertices] = MAKEVERTEX( x2, y2, z2, shadowcolor, hrepeat, 0.0f ); Verts[numVertices+1] = MAKEVERTEX( x2, y2, z1, shadowcolor, hrepeat, vrepeat ); Verts[numVertices+2] = MAKEVERTEX( x1, y2, z1, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+3] = MAKEVERTEX( x1, y2, z1, shadowcolor, 0.0f, vrepeat ); Verts[numVertices+4] = MAKEVERTEX( x1, y2, z2, shadowcolor, 0.0f, 0.0f ); Verts[numVertices+5] = MAKEVERTEX( x2, y2, z2, shadowcolor, hrepeat, 0.0f ); numVertices += 6; } if (numVertices == 0) return; IDirect3DDevice9 *pD3DDevice = game->GetGraphics()->GetDirect3DDevice9(); IDirect3DVertexBuffer9 *pD3DVB = NULL; pD3DDevice->CreateVertexBuffer(numVertices*sizeof(sVertex),0, VertexFVF, D3DPOOL_MANAGED, &pD3DVB, NULL); BYTE *Ptr; pD3DVB->Lock(0,numVertices*sizeof(sVertex),(void**)&Ptr,0); memcpy(Ptr, Verts, numVertices*sizeof(sVertex)); pD3DVB->Unlock(); pD3DDevice->SetTexture(0,texture); pD3DDevice->SetStreamSource(0, pD3DVB, 0, sizeof(sVertex)); pD3DDevice->SetFVF(VertexFVF); pD3DDevice->DrawPrimitive(D3DPT_TRIANGLELIST,0,numVertices); pD3DVB->Release(); }
For some reason, whenever I call CTools::DrawBlockModify(0,0,0,m*collide->GetWidth(),m*collide->GetHeight(),m*collide->GetDepth(),game->GetTextureManager()->GetTextureFromName("Dragon"),1,1,TRUE,TRUE,TRUE,TRUE,TRUE,FALSE,game->GetGraphics()->MakeColorRGB(255,0,0)); and then in the next object, CTools::DrawBlockModify(0,0,0,m*collide->GetWidth(),m*collide->GetHeight(),m*collide->GetDepth(),game->GetTextureManager()->GetTextureFromName("Stone"),1,1,left,back,right,front,TRUE,FALSE,game->GetGraphics()->MakeColorRGB(255,255,255)); The top of the next object is the color of the previous one.
|
|
|
Logged
|
|
|
|