Jump to content
  • Advertisement

byrdJR

Member
  • Content Count

    43
  • Joined

  • Last visited

Community Reputation

127 Neutral

About byrdJR

  • Rank
    Member
  1. Hi. I used you guys advice and changed my input control from a switch to a set of if statements, but I still get the same result. here's what I changed it to: void CMyEngineApplication::KeyMessageProc( WPARAM wParam ) { if( wParam =='W'||wParam =='w') { bool bCollided = false; if(bSphereTest(copyPos, copyPos2)) { bCollided = true; } // stop forward movement if(!bCollided) // if false { x+= 0.5; //m_pCamera->SetRotationSpeedY( -0.08f ); }// if }// W if(wParam=='S'||wParam == 's') { //m_pCamera->SetSpeed( -3.0f ); x-= 0.5; //m_pCamera->SetRotationSpeedY( 0.08f ); }// S if(wParam =='I'||wParam =='i') { //m_pCamera->SetRotationSpeedY( 1.2f ); bool bCollided2 = false; if(bSphereTest(copyPos2, copyPos)) { bCollided2 = true; } // stop forward movement if(!bCollided2) // if false { x2-=0.5; //m_pCamera->SetRotationSpeedY( 0.08f ); }// if }// I if(wParam == 'O'||wParam =='o') { //m_pCamera->SetRotationSpeedY( 1.2f ); x2+=0.5; }//O } // KeyMessageProcand this function is called here: switch(msg) { // our app has the focus case WM_ACTIVATE: { if ( (BOOL)wParam ) m_pEngine->SetActive( true ); else m_pEngine->SetActive( false ); } break; // key was pressed case WM_KEYDOWN: { switch (wParam) { case VK_ESCAPE: { // this will post WM_DESTROY message // if not handled otherwise by us PostMessage(hWnd, WM_CLOSE, 0, 0); return 0; } break; case VK_F1: { m_pRenderDevice->EnableWireframe( !m_pRenderDevice->IsWireframe() ); } break; case VK_F2: { m_pRenderDevice->EnableTextures( !m_pRenderDevice->IsTextured() ); } break; default: KeyMessageProc( wParam ); } } break;So is it operating the same because it is being called in a switch? help me please! Thanx --Karl
  2. hey thanx for the helpful replys! anyway here's my switch void CMyEngineApplication::KeyMessageProc( WPARAM wParam ) { switch ( wParam ) { case 'W': case 'w': { bool bCollided = false; if(bSphereTest(copyPos, copyPos2)) { bCollided = true; break; } // stop forward movement if(!bCollided) // if false { x+= 0.5; m_pCamera->SetRotationSpeedY( -0.08f ); }// if } break; case 'S': case 's': { //m_pCamera->SetSpeed( -3.0f ); x-= 0.5; m_pCamera->SetRotationSpeedY( 0.08f ); } break; case 'Q': case 'q': { m_pCamera->SetRotationSpeedX( -1.2f ); } break; case 'E': case 'e': { m_pCamera->SetRotationSpeedX( 1.2f ); } break; case 'D': case 'd': { //m_pCamera->SetRotationSpeedY( -1.2f ); } break; case 'A': case 'a': { //m_pCamera->SetRotationSpeedY( 1.2f ); } break; case 'I': case 'i': { //m_pCamera->SetRotationSpeedY( 1.2f ); x2-=0.5; } break; case 'O': case 'o': { //m_pCamera->SetRotationSpeedY( 1.2f ); x2+=0.5; } break; default: break; } } // KeyMessageProc /*----------------------------------------------------------------*/ I going to try your suggestions now any further advice would also be welcomed. Thanx --Karl
  3. Thanx for the reply! But it looks like your using the same method I already tried. The API I'm using is DX9. I'm using a switch that checks for which key is pressed, but when I press two keys a the same time one object moves while the other doesn't. So how can I get them to move at the same time?
  4. I'm trying to make a simple multiplayer fighting game and I want the users to keep it as simple a possible so I was thinking that allowing the users to use only one keyboard would be easier, but I don't know how to do it so any suggestions would be helpful.
  5. Hi. I'm trying to texture a mesh created by the D3DX (DX9)createSphere function and here's my FVF: #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) and here's how I cloned my mesh: LPDIRECT3DVERTEXBUFFER9 pTempVertexBuffer; pTempMesh->CloneMeshFVF( 0, D3DFVF_CUSTOMVERTEX, g_pd3dDevice, &g_pMesh ); if( SUCCEEDED( g_pMesh->GetVertexBuffer( &pTempVertexBuffer ) ) ) { int nNumVerts = g_pMesh->GetNumVertices(); CUSTOMVERTEX *pVertices = NULL; pTempVertexBuffer->Lock( 0, 0, (void**)&pVertices, 0 ); { for( int i = 0; i < nNumVerts; i++ ) { pVertices[i+0].tu = ((FLOAT)i)/(nNumVerts-1); pVertices[i+0].tv = 0.0f; pVertices[i+1].tu = ((FLOAT)i)/(nNumVerts-1); pVertices[i+1].tv = 1.0f; } pTempVertexBuffer->Unlock(); pTempVertexBuffer->Release(); } } Now all I get as output is a wireframe sphere. I think my problem is my algorithm for maping the tex coords to the sphere is all wrong and I would like to know how I should manually calculate texturing a sphere. I have a basic understanding of how to texture a mesh and I know that u and v are between 0 and 1 and I can texture simpler polys, but I don't have a clear idea of how to manually texture a sphere. I mean I think I have to calulate the four points that make a square on the sphere for each vert on the sphere, but I don't know how to put that into an array. I really need a clear explaination of how to manually texture simple meshes like spheres or cubes and an explaination of the logic behind the process. I have tried using a 3d program and I loaded x files before, but I spent so much time trying to learn those programs that I'm not completing any of my projects, so I'd rather get the basics of D3D down before I spend any more time on a 3d program. Anyway, if you or anyone here can point me in the right direction I would greatly appreciate it.
  6. byrdJR

    texturing tutorials

    Thanx for the help circlesoft. I did create an FVF with texture coords and I set the FVF when I cloned my mesh. Here's my FVF:#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) and here's how I cloned my mesh: LPDIRECT3DVERTEXBUFFER9 pTempVertexBuffer; pTempMesh->CloneMeshFVF( 0, D3DFVF_CUSTOMVERTEX, g_pd3dDevice, &g_pMesh ); if( SUCCEEDED( g_pMesh->GetVertexBuffer( &pTempVertexBuffer ) ) ) { int nNumVerts = g_pMesh->GetNumVertices(); CUSTOMVERTEX *pVertices = NULL; pTempVertexBuffer->Lock( 0, 0, (void**)&pVertices, 0 ); { for( int i = 0; i < nNumVerts; i++ ) { pVertices[i+0].tu = ((FLOAT)i)/(nNumVerts-1); pVertices[i+0].tv = 0.0f; pVertices[i+1].tu = ((FLOAT)i)/(nNumVerts-1); pVertices[i+1].tv = 1.0f; } pTempVertexBuffer->Unlock(); pTempVertexBuffer->Release(); } }Now all I get as output is a wireframe sphere. I think my problem is my algorithm for maping the tex coords to the sphere is all wrong and I would like to know how I should manually calculate texturing a sphere. I have a basic understanding of how to texture a mesh and I know that u and v are between 0 and 1 and I can texture simpler polys, but I don't have a clear idea of how to manually texture a sphere. I mean I think I have to calulate the four points that make a square on the sphere for each vert on the sphere, but I don't know how to put that into an array. I really need a clear explaination of how to manually texture simple meshes like spheres or cubes and an explaination of the logic behind the process. I have tried using a 3d program and I loaded x files before, but I spent so much time trying to learn those programs that I'm not completing any of my projects, so I'd rather get the basics of D3D down before I spend any more time on a 3d program. Anyway, if you or anyone here can point me in the right direction I would greatly appreciate it.
  7. I've been searching the web for tutorials on texturing a sphere. I'm using the D3DX function to create my sphere and then I'm cloning the sphere so I can isolate the verts and draw the textures on the sphere, but it aint working. any help would be greatly appreciated!
  8. byrdJR

    need more help!

    Thanx!
  9. byrdJR

    need more help!

    O.K. I'm using an algorithm to create a sphere. Here's my code: DWORD i = 0; DWORD k = 0; FLOAT a= 2*D3DX_PI/24; FLOAT b= D3DX_PI/24; for( DWORD j=0; j<625; j++) { FLOAT theta = i*a; FLOAT phi = k*b; pVertices[2*j].position = D3DXVECTOR3(FLOAT(2*(sin(phi)*cos(theta))), FLOAT(2*(sin(phi)*sin(theta))), FLOAT(2*(cos(phi))) ); if((j%25) == 0 && j != 0) { i += 1; k = 0; } if((j%25) != 0 || j == 0) { k++; } }Now the algorithm does make a sphere, but it's not solid. Imagine a ball with vertical slices all about the center of the circle and you have an idea of what my output looks like. So I raised the resolution, but still have the same general result, which also raised the number of primitives I drew to almost 20k. Now I know 20k polygons is way too much for one sphere so what is it that I am missing and what should be the average amount of polys rendered when drawing only one sphere?
  10. byrdJR

    I need help!

    Daos can you please explain why you increment v by dv for P2 and P3 and also increment u by du for P3 and P4? thanx
  11. I am trying to algorithmically build a sphere. I am using parametric equations to develop the sphere. It doesn't work, but here is my code: // Create the vertex buffer. if( FAILED( g_pd3dDevice->CreateVertexBuffer( 50*25*sizeof(CUSTOMVERTEX), 0, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL ) ) ) { return E_FAIL; } // Fill the vertex buffer. We are algorithmically generating a shpere // here, including the normals, which are used for lighting. CUSTOMVERTEX* pVertices; if( FAILED( g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) ) return E_FAIL; FLOAT a= 2*D3DX_PI/24; FLOAT b= D3DX_PI/24; for(DWORD i=0; i<25; i++) { FLOAT theta = i*a; for( DWORD j=0; j<25; j++) { FLOAT phi = j*b; pVertices[2*j].position = D3DXVECTOR3( (FLOAT(sinf(phi)*cos(theta))), (FLOAT(sin(phi)*sin(theta))), (FLOAT(cosf(phi))) ); pVertices[2*j+1].position = D3DXVECTOR3( (FLOAT(sinf(phi+b)*cos(theta))), (FLOAT(sin(phi+b)*sin(theta))), (FLOAT(cosf(phi+b))) ); } } Now I think I have 1250 vertices being pumped into the vertex buffer, so then in my render function I call DrawPrimitive(TriangleStrip,0,416). I divided 1250 by 3, which why I use 416 as a parameter in DrawPrimitive. Anyway, I tried using pVertices without doubling the index value and when I do this I only get one tiangle and a few dots going around in the shape of semi-circle in the xz-plane, but when I do double the indicies of the vertex buffer I get a complete semicircle in the xz plane. now my first question is why am I only getting a semi-circle, when I am generating 1250 vertices? next, why do I have to double my indicies? finally, how exactly does DX determine how it draws each triangle? please help thanx! Edited by Coder: Used source tags. Check GDNet Forums FAQ, please [Edited by - Coder on August 25, 2004 7:45:09 AM]
  12. I am trying to algorithmically create a sphere using DX9. I came up with an algorithm, but it didn't create a sphere and I asked in the begginer and DX forums what was the problem with my code. anyway two methods were suggested which was to normalized my vectors or use parametric equations. So I chose to use parametric equations. Daos gave me the suggestion and here's his [a href:http://www.gamedev.net/community/forums/topic.asp?topic_id=264993]algorithm[/a] now I think I understand what is generally going on in his algorithm and I think he has four points because he called GL_QUADS. So what I don't understand is why he adds dv to v for P2 and P3 and adds du to u for P3 and P4. Also, since I'm using DX, would I only need to have three points? Thanx!
  13. byrdJR

    I need help!

    ok I used the parametric equations for a sphere, but nothing is being drawn. Only the back buffer is being shown. here's my code: // Fill the vertex buffer. We are algorithmically generating a shpere // here, including the normals, which are used for lighting. CUSTOMVERTEX* pVertices; if( FAILED( g_pVB->Lock( 0, 0, (void**)&pVertices, 0 ) ) ) return E_FAIL; for( DWORD j=0; j<100; j++) { FLOAT theta = (2*D3DX_PI*j)/(100-1); FLOAT phi = (D3DX_PI*j)/(100-1); pVertices[2*j+0].position = D3DXVECTOR3( 2*(FLOAT(sinf(phi)*cos(theta))), 2*(FLOAT(sin(phi)*sin(theta))), 2*(FLOAT(cosf(phi))) ); pVertices[2*j+1].position = D3DXVECTOR3( 2*(FLOAT(sinf(phi)*cos(theta))), 2*(FLOAT(sin(phi)*sin(theta))), 2*(FLOAT(cosf(phi))) ); } g_pVB->Unlock();
  14. byrdJR

    I need help!

    O.K I think I understand. Thanx! I'm about to see if I can get it to work!
  15. I posted my code in the beginner forum and I was wondering if anybody here would also be of assistance. I have been going through the tutorials that came with the SDK and I've been trying to approximate a sphere based on the cylinder algorithm given in the lighting tutorial. However, all I get is a shape that resembles a Hershey's kiss. If anyone has a better method or any suggestions based on my code: FLOAT Y = 1.0f; FLOAT Y2 = 0.0f; Y2 = (FLOAT)(Y - 0.04); DWORD n = 0; for( DWORD i=1; i<26; i++ ) { if( i>=13 ) { cylinderSize = i - n; n = n + 2; } else { cylinderSize = i; } if(i>=2) { Y = Y2; Y2 = (FLOAT)(Y - 0.04); } for( DWORD j=0; j<50; j++) { FLOAT theta = (2*D3DX_PI*j)/(50-1); pVertices[2*j+((i-1)*48)].position = D3DXVECTOR3( cylinderSize*(sinf(theta)/13), Y, cylinderSize*(cosf(theta)/13) ); pVertices[2*j+((i-1)*49)].position = D3DXVECTOR3( cylinderSize*(sinf(theta)/13), Y2, cylinderSize*(cosf(theta)/13) ); } } I would greatly appreciated it. Someone has already suggested that my problem is that I'm linearly increasing and decreasing the radius of each cylinder and he/she suggested that I take the square root of the normalized cylinder radius. Is this the best way and what does normalized mean exactly? Thanx!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!