Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

320 Neutral

About Xrystal

  • Rank
  1. Just wanted to thank all you guys for your suggestions. Looks like the problem was how I was positioning or splitting the terrain up or the heightmap I was using in the test. I've finally managed to incorporate the ability to convert vertex data into a mesh and display a terrain mesh in segments by adjusting the attribute value to reflect what segment ID to tie a face to. I haven't been able to repeat the problem now but then alot of the code I used before is not in play at present.
  2. Thats a possibility Matt, thanks. Scaling the patches were one of the next steps I needed to take but didn't want to do too much before I got a standard display working. Will have to work that into the code and see if it worked.
  3. Thanks, for the replies. I wasn't sure if you needed more information or if the visual was enough. But yes, it is the the background coming through that I am seeing. I'm attempting to see if turning the patches into meshes make a difference as that way I can test the code the book I'm learning from is using instead of my old code I used before in an old project. I'll hook out the offending geometry code which might help. And replacing the original image with one that should be more close up. This is from the Terrain class file void CDXTerrain::GeneratePatches(int nPXSize, int nPZSize) { // Make enough room to store patch details Resize(nPXSize * nPZSize); // Make sure that the patches can be made if (m_nXSize % nPXSize != 0) return; if (m_nZSize % nPZSize != 0) return; // Now that we know it is fully divisible work out the patch sizes m_nXPatch = (m_nXSize / nPXSize); m_nZPatch = (m_nZSize / nPZSize); // Should make this a member variable but sets the terrain RECT for patches RECT rTerrainData; rTerrainData.top = 0; rTerrainData.left = 0; rTerrainData.bottom = rTerrainData.top + m_nZSize; rTerrainData.right = rTerrainData.left + m_nXSize; // variable to store RECT data for each patch (will be section of rTerrain RECT rPatchData; int index = 0; for (int z = 0; z < m_nZSize; z+= m_nZPatch) { for (int x = 0; x < m_nXSize; x+= m_nXPatch) { // Create Patch Data from Terrain Data rPatchData.top = z; rPatchData.left = x; rPatchData.bottom = z + m_nZPatch; rPatchData.right = x + m_nXPatch; m_vPatches[index] = new CDXPatch(m_pDevice); m_vPatches[index]->Create(index,rPatchData,m_Heights,rTerrainData); index++; } } return; } This is from the Patch Class void CDXPatch::Create(int nID, int nXPatches, int nZPatches,CString sFile, float fScale) { m_nID = nID; m_VertsPerRow = nXPatches; m_VertsPerCol = nZPatches; m_CellsPerRow = m_VertsPerRow - 1; m_CellsPerCol = m_VertsPerCol - 1; m_VertsPerGrid = m_VertsPerRow * m_VertsPerCol; m_IndicesPerGrid = (m_VertsPerRow * 2) * (m_VertsPerCol -1) + (m_VertsPerCol - 2); m_halfWidth = ((float)m_VertsPerRow - 1.0f) / 2.0f; m_halfLength = ((float)m_VertsPerCol - 1.0f) / 2.0f; m_pVertices = new CDXVertices(m_pDevice); m_pVertices->ReserveSpace(m_VertsPerGrid); m_pVertices->HasPosition(false,false); m_pVertices->HasTexture(1); for (int z = 0; z < m_VertsPerCol; z++) { for (int x = 0; x < m_VertsPerRow; x++) { int index = (z * m_VertsPerCol + x); m_pVertices->InsertPosition(index,stCoords((float)(x - m_halfWidth),(float)m_Heights.GetDataAt(index),(float)((z - m_halfLength)))); m_pVertices->InsertTexture(index,stTextures((float)x / (m_VertsPerRow - 1),(float)z / (m_VertsPerCol - 1))); } } int i = 0; for (int z = 0; z < m_VertsPerCol - 1; z++ ) { // Even rows move left to right, odd rows move right to left. if ( z % 2 == 0 ) { // Even row for (int x = 0; x < m_VertsPerRow; x++ ) { m_pVertices->AddIndex( x + (z * m_VertsPerRow) + 0 ); m_pVertices->AddIndex( x + (z * m_VertsPerRow) + m_VertsPerRow); } // Insert degenerate vertex if this isn't the last row if ( z != m_VertsPerCol - 2) { m_pVertices->AddIndex( --x + (z * m_VertsPerRow) + 0 ); } } else { // Odd row for (int x = m_VertsPerRow - 1; x >= 0; x-- ) { m_pVertices->AddIndex( x + (z * m_VertsPerRow) + 0 ); m_pVertices->AddIndex( x + (z * m_VertsPerRow) + m_VertsPerRow); } // Insert degenerate vertex if this isn't the last row if ( z != m_VertsPerCol - 2) { m_pVertices->AddIndex( ++x + (z * m_VertsPerRow) + 0 ); } } } m_pVertices->CreateVertexDeclaration(); m_pVertices->CreateVertexBuffer(m_VertsPerGrid,NULL,NULL); m_pVertices->CreateIndexBuffer(m_IndicesPerGrid,NULL,NULL); m_pVertices->UseMaterial(new CDXMaterial(m_pDevice)); m_pVertices->Material()->SetColor(true,true,true,false,0.5f,0.0f,0.5f,0.0f); } The Code to generate the terrain in this function was taken from another book or website example. I can't see anything wrong with it per-se so if you see something that I may have overlooked when converting variable names please point it out. Admittedly my TriangleStrip knowledge is not that great. I try to use Triangle Lists myself. I hope this code and the new picture helps somewhat in confirming your suspicions. I'll be sure to update the thread if the problem resolves itself by converting each patch to a mesh but for learning purposes I would like to know what may have caused the glitch. Thanks again.
  4. I've finally managed to build a terrain and split it into patches. Currently working as a 3 x 3 patch display. However if you look at the following image you will see a tear in the seams. Is there anyway this can be resolved? I assume the stretching of a texture over the whole terrain solves the problem but is there anything else ? Thanks for any ideas that can be thrown my way as to why it does this. It seems to be related to the height as the more height there is in an area the more pronounced the tear. [Edited by - Xrystal on July 24, 2007 7:35:46 PM]
  5. Xrystal

    HRESULT does not name a type

    Well went to the section with the complete working program and copied the main source into a file I created .. main.cpp and then saved the d3dfuncs files into the same directory. They're DirectX8 commands so added #pragma comment(lib,"d3d8.lib") amongst the includes and everything compiled and ran fine. If that still doesn't work I can only think that your IDE environment or Project settings are different and are causing problems.
  6. Xrystal

    HRESULT does not name a type

    Hmm, can't see why it wouldn't work. I just threw a HRESULT returning function into one of my classes and it compiled with no problems. You are writing a Win32 application aren't you or is it one of the newer types? The others might have a different way of working. As far as I am aware the HRESULT values are defined in winerror.h and are a part of the Windows.h system.
  7. Xrystal

    Simple program error

    As to the 2 errors you have there.. On the lines in question before the LoadImage command do a cast to HICON and see if that resolves it.
  8. Xrystal

    [C++ 2003] Weird Problem

    Yep, tested with far plane from 1000 upto 10000000 with no differences. One side looks like it is 4 times the size of the other side even though the individual vertices are spaced similarly apart. Too many to count though to confirm. What is weird though is that the terrain is supposed to be centered on the 0,0,0 central viewpoint which works on the lower sizes but not on these problem ones. Which gives the impression that the map is positioned right just not displaying. And yes, I have cullmode off and wireframe on and the background red instead of black. This is what my 512 sized terrain looks like with the farthest out far plane used. Hopefully that gives you a better idea of what I am talking about. 256 sizes and lower are clearly shown as squares.
  9. I have an old terrain project that was coded in .Net Managed and a new project coded in unmanaged. The code used to generate the terrain was moved across to my new project and all seems to be fine with terrains of 16x16, 32x32 etc up to 256x256. The moment I test 512x512 and 1024x1024 terrains they display as a rectangular plane rather than a square plane like the others. I've checked that the right values are being passed, made sure my video card can handle that many vertices and indices, confirmed I didn't make some silly mistakes while copying the code over and confirmed that the old program could display square terrains of that high magnitude. Oh, and I also made sure the perspective test was the same. All passed the tests. Now my question is this : Is there anything that would make 512 and 1024 size terrains to render strangely like this and those smaller to be rendered fine. I'm sure it is something in my new code but I cannot think of what else would effect the rendering like this. Thanks for any ideas you can offer.
  10. Okay, here goes. Ended up doing the following before it would work. 1) Delete all files in output folder. 2) Recompiled - OK 3) Resaved source file thus adjusting its timestamp. 4) Recompiled - Registered nothing to compile 5) Closed all files currently open in IDE 6) Recompiled - OK 7) Repeated step 3 and successfully rebuilt everytime. So must be something to do with the project file itself. Thanks for the input guys.
  11. For the last few days I have noticed something weird happening when I compile my program. If I choose to rebuild all it compiles fine as it deletes any intermediate files it creates and thus the program runs as expected. However, if I choose rebuild to recompile just the files that have been changed it acts as if nothing has been changed and thus the program runs as if I had made no changes to the code. It's no biggie as I just remember to choose Rebuild each time but its annoying having to rebuild all source files when only 1 has changed. Has anyone else come across this before ? Does anyone know what could be causing it ? Thanks [Edited by - Xrystal on June 29, 2007 2:04:40 PM]
  12. Xrystal

    Problem using LPD3DXEFFECT

    Quote: //Select technique and store result if(FAILED(g_pEffect->FindNextValidTechnique(NULL,&hTech))) return FALSE; if(FAILED(effectt=g_pEffect->ValidateTechnique(hTech))) return FALSE; if(FAILED(effectt=g_pEffect->SetTechnique(hTech))) return FALSE; I've never used these commands myself so will have to try it to see what happens in my case. .. Okay, I added ValidateTechnique to my code and worked a treat. My effect file has multiple techniques in that have to be used specifically so can't use the FindNext option. Also, what is effectt? it seems to be a variable of some manner but I am not seeing it being initialised, set or used anywhere else in that code. Ah I am guessing it is HRESULT variable. Another thought I have is maybe try removing the use of the effect file and see if the program falls over using the fixed program functionality. I usually do this if I get a memory error and can't find where the owner of the problem is.
  13. Xrystal

    Problem using LPD3DXEFFECT

    The first thought that springs to mind is a memory leak somewhere but the DX Debug process should tell you that when you exit. I don't recall seeing that problem with my old Effect Class. And just tested it with DXDebug switched on. It might be more basic than your own but here's what I have in it. Feel free to take a gander in case you spot something you overlooked. CDXEffect::CDXEffect(LPDIRECT3DDEVICE9 pD3DDevice,LPCTSTR szFileName) { m_pD3DDevice = pD3DDevice; m_pD3DEffect = NULL; m_pD3DDefines = NULL; m_pD3DInclude = NULL; m_pD3DPool = NULL; m_pD3DCompileErrors = NULL; m_dwShaderFlags = NULL; m_szFileName = szFileName; m_bCreated = false; } CDXEffect::~CDXEffect() { m_pD3DDefines = NULL; m_pD3DInclude = NULL; m_szFileName = NULL; m_szTechnique = NULL; if (m_bCreated) { SAFE_RELEASE(m_pD3DCompileErrors); SAFE_RELEASE(m_pD3DPool); SAFE_RELEASE(m_pD3DEffect); } } bool CDXEffect::CreateFromFile(void) { m_dwShaderFlags = D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION; HRESULT hr = D3DXCreateEffectFromFile(m_pD3DDevice,m_szFileName, m_pD3DDefines,m_pD3DInclude, m_dwShaderFlags,m_pD3DPool, &m_pD3DEffect,&m_pD3DCompileErrors); if (hr == D3D_OK) { m_bCreated = true; return true; } if (hr == D3DERR_INVALIDCALL) { MessageBox(NULL,"Invalid Call","Create Effect from File",MB_OK); return false; } if (hr == D3DXERR_INVALIDDATA) { MessageBox(NULL,"Invalid Data","Create Effect from File",MB_OK); return false; } if (hr == E_OUTOFMEMORY) { MessageBox(NULL,"Out of Memory","Create Effect from File",MB_OK); return false; } if (!m_pD3DEffect) { LPCTSTR buff = (LPCTSTR)m_pD3DCompileErrors->GetBufferPointer(); MessageBox(NULL,buff,"Compiler Errors",MB_OK); return false; } return true; } void CDXEffect::UseTechnique(void) { HRESULT hr = m_pD3DEffect->SetTechnique(m_pD3DEffect->GetTechniqueByName(m_szTechnique)); if (hr == D3D_OK) { } if (hr == D3DERR_INVALIDCALL) { MessageBox(NULL,"Invalid Call","UseTechnique",MB_OK); } } void CDXEffect::SetTechnique(LPCTSTR szTechnique) { m_szTechnique = szTechnique; } UINT CDXEffect::Begin(void) { UINT passes; HRESULT hr = m_pD3DEffect->Begin(&passes,D3DXFX_DONOTSAVESTATE); if (hr == D3D_OK) return passes; if (hr == D3DERR_INVALIDCALL) { MessageBox(NULL,"Invalid Call","Begin Effect",MB_OK); return 0; } if (hr == D3DXERR_INVALIDDATA) { MessageBox(NULL,"Invalid Data","Begin Effect",MB_OK); return 0; } return 0; } void CDXEffect::BeginPass(UINT pass) { m_pD3DEffect->BeginPass(pass); } void CDXEffect::EndPass(void) { m_pD3DEffect->EndPass(); } void CDXEffect::End(void) { m_pD3DEffect->End(); } Good luck. Hope you find the culprit soon.
  14. I don't think there is a workable way of getting windows controls to draw over a directx scene. But I would imagine if the scene was drawn in a window control then other window controls would work fine, as per 3D Object programs that are flying about. The only way you can get user interface functionality, as far as I am aware, in a directx scene environment would be to create your own or use one of the systems designed for this use out there somewhere.
  15. Xrystal

    Why does my texture not show?

    hehe, and there I was gonna suggest what Peter said too :)) But glad it sorted the problem out for you :D I usually have the wireframe/solid ability as a keypress test while running for that precise reason myself and to confirm that an object has drawn and just not being displayed where I am expecting it to be.
  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!