Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
Two problems! http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=143 |
Page 1 of 2 |
Author: | Shanee [ Sat Feb 19, 2011 8:44 am ] |
Post subject: | Two problems! |
Hello! I am having some difficulty getting the demo to work, maybe someone could help me. Ok, first, with a side note, including some hearts causes all my shared_ptr become ambiguous calls. Now for the real deal, I followed the OpenGL demo and did just about the same but with DirectX in a simple way just to test, here we go: Code: PolyVox::Volume<PolyVox::MaterialDensityPair44> m_VolumeData(64, 64, 64); Vector3 v3dVolCenter(m_VolumeData.getWidth() / 2, m_VolumeData.getHeight() / 2, m_VolumeData.getDepth() / 2); //This three-level for loop iterates over every voxel in the volume for (int z = 0; z < m_VolumeData.getWidth(); z++) { for (int y = 0; y < m_VolumeData.getHeight(); y++) { for (int x = 0; x < m_VolumeData.getDepth(); x++) { //Store our current position as a vector... Vector3 v3dCurrentPos(x,y,z); //And compute how far the current position is from the center of the volume if (IsInRange(v3dCurrentPos, v3dCurrentPos, 5)) { //Our new density value uint8_t uDensity = PolyVox::MaterialDensityPair44::getMaxDensity(); //Get the old voxel PolyVox::MaterialDensityPair44 voxel = m_VolumeData.getVoxelAt(x,y,z); //Modify the density voxel.setDensity(uDensity); //Wrte the voxel value into the volume m_VolumeData.setVoxelAt(x, y, z, voxel); } } } } PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> mesh; PolyVox::CubicSurfaceExtractorWithNormals<PolyVox::MaterialDensityPair44> surfaceExtractor(&m_VolumeData, m_VolumeData.getEnclosingRegion(), &mesh); surfaceExtractor.execute(); const vector<uint32_t>& vecIndices = mesh.getIndices(); const vector<PolyVox::PositionMaterialNormal>& vecVertices = mesh.getVertices(); m_VertexBuffer.Create(sizeof(PolyVox::PositionMaterialNormal) * mesh.getNoOfVertices()); m_IndexBuffer.Create(mesh.getNoOfIndices() * sizeof(DWORD), 8UL, D3DFMT_INDEX32); void* pVoid; m_IndexBuffer.Lock(&pVoid); const void* pIndices = static_cast<const void*>(&(vecIndices[0])); memcpy((pVoid), pIndices, sizeof(uint32_t) * vecIndices.size()); m_IndexBuffer.Unlock(); const void* pVertices = static_cast<const void*>(&(vecVertices[0])); m_VertexBuffer.Lock(&pVoid); count = 0; memcpy((pVoid), pVertices, sizeof(PolyVox::PositionMaterialNormal) * vecVertices.size()); m_VertexBuffer.Unlock(); m_NumVertices = vecVertices.size(); m_NumFaces = vecIndices.size() / 3; The problems: the returning std::vector for indices and vectors are empty. |
Author: | Shanee [ Sat Feb 19, 2011 9:02 am ] |
Post subject: | Re: Two problems! |
Follow up: I tried SurfaceExtractor instead of CubicSurfaceExtractorWithNormals now, I am getting triangles but not indices... what could be the problem? |
Author: | David Williams [ Sat Feb 19, 2011 3:35 pm ] |
Post subject: | Re: Two problems! |
Hi, I tried to test you code but actually you didn't post your IsInRange() function. For testing purposes, lets leave rendering aside and focus what data is in the vertex/index buffers. If your example compiles without Direct3D that would be easiest... Shanee wrote: I tried SurfaceExtractor instead of CubicSurfaceExtractorWithNormals now, I am getting triangles but not indices... what could be the problem? Not sure, in the example you can switch these two interchangebly. But I'm sure it will become slear when we solve the first problem ![]() |
Author: | Shanee [ Sat Feb 19, 2011 3:42 pm ] |
Post subject: | Re: Two problems! |
Hey David, thank you for the reply, again ![]() I did test I am actually getting the statement to work there and voxels being added so I should get something even if my function was broken, but hey: Code: bool IsInRange(CONST D3DXVECTOR3& pos1, CONST D3DXVECTOR3& pos2, float range) { Vector3 diffVec = pos2 - pos1; float distance = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z; range = range * range; if (distance <= range) return true; return false; } I am really baffled! tried downloading the zipped (older) source instead of using the SVN, still not working. Also tried to use smoothPositions to see if it might magically get indices working but I ended with an error on that part: Quote: Error 14 error C2039: 'isOnGeometryEdge' : is not a member of 'PolyVox::PositionMaterialNormal' d:\programming\mimiluna - svn\engine\libs\polyvoxcore\SurfaceMesh.inl 222 Something seems to be broken somehow, maybe I messed the build somehow on both versions I built? Edit: putting renderer APIs aside, I am looking into the mesh (PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> mesh) in debug, that's where I see there are some vertices (quite a bit even) but the index vector is empty (size = 0, as well as lack of content) |
Author: | Shanee [ Sat Feb 19, 2011 3:48 pm ] |
Post subject: | Re: Two problems! |
Not sure if this spam will help much: Code: - mesh {m_Region={...} m_iTimeStamp=-1 m_iNoOfLod0Tris=-858993460 ...} PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal>
- m_Region {m_v3dLowerCorner={...} m_v3dUpperCorner={...} dummy='d' } PolyVox::Region - m_v3dLowerCorner {m_tElements=0x006ae504 } PolyVox::Vector<3,short> - m_tElements 0x006ae504 short [3] [0] 0 short [1] 0 short [2] 0 short - m_v3dUpperCorner {m_tElements=0x006ae50a } PolyVox::Vector<3,short> - m_tElements 0x006ae50a short [3] [0] 63 short [1] 63 short [2] 63 short dummy 100 'd' unsigned char m_iTimeStamp -1 int m_iNoOfLod0Tris -858993460 int + m_vecTriangleIndices [0]() std::vector<unsigned int,std::allocator<unsigned int> > + m_vecVertices [12288]({position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=0.00000000 },{position={...} normal={...} material=??? },...,...) std::vector<PolyVox::PositionMaterialNormal,std::allocator<PolyVox::PositionMaterialNormal> > - m_vecLodRecords [1]({beginIndex=0 endIndex=0 }) std::vector<PolyVox::LodRecord,std::allocator<PolyVox::LodRecord> > [size] 1 unsigned long [capacity] 1 unsigned long + [0] {beginIndex=0 endIndex=0 } PolyVox::LodRecord - m_mapUsedMaterials [0]() std::set<unsigned char,std::less<unsigned char>,std::allocator<unsigned char> > [comp] less std::less<unsigned char> pIndices 0xcccccccc const void * count -858993460 int |
Author: | David Williams [ Sat Feb 19, 2011 3:58 pm ] |
Post subject: | Re: Two problems! |
The error is in this line: Code: if (IsInRange(v3dCurrentPos, v3dCurrentPos, 5)) You're using 'v3dCurrentPos' twice, one of those values should be v3dVolCenter ![]() However, it's strange that the SurfaceExtractor gives vetiecs but no indices in this case. It could be a bug. |
Author: | Shanee [ Sat Feb 19, 2011 4:01 pm ] |
Post subject: | Re: Two problems! |
Haha! Always fall on the most trivial of mistakes. Fast copy pasting and writing of code at 3 at night is never good ![]() Testing now... ![]() Yay! Thank you ![]() But hey, at least I might have found an actual bug there? ![]() |
Author: | David Williams [ Sat Feb 19, 2011 4:10 pm ] |
Post subject: | Re: Two problems! |
No problem, I'm glad it's working. And yes, I'll have to look into that bug. |
Author: | Shanee [ Sat Feb 19, 2011 4:37 pm ] |
Post subject: | Re: Two problems! |
I must congratulate you, you know ![]() ![]() |
Author: | David Williams [ Sat Feb 19, 2011 5:52 pm ] |
Post subject: | Re: Two problems! |
Thanks, people appriciating the library is one of the main things that insipres me to keep working on it ![]() Shanee wrote: And it is very generous of you to let everyone use it for free even in commercial products (hope you won't change that policy ![]() I can't change that policy for the code that has already been released, so everything you've got is free forever. The worst case is that I could decide that future versions of the library would be under a different license, but I have no intention of doing that. |
Page 1 of 2 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |