Volumes Of Fun
http://www.volumesoffun.com/phpBB3/

Getting an access violation when I go "into" a polyvox mesh!
http://www.volumesoffun.com/phpBB3/viewtopic.php?f=2&t=85
Page 1 of 1

Author:  paycheck [ Thu Nov 11, 2010 8:27 am ]
Post subject:  Getting an access violation when I go "into" a polyvox mesh!

this is my code:
Code:
//Create an empty volume and then place a sphere in it
   Volume<MaterialDensityPair44> volData(64, 64, 64);
   createSphereInVolume(volData, 30);

   //Extract the surface
   SurfaceMesh<PositionMaterialNormal> mesh;
   CubicSurfaceExtractorWithNormals<MaterialDensityPair44> surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
   surfaceExtractor.execute();

   Ogre::ManualObject* PVWorld = mSceneMgr->createManualObject("PVWorld");

    uint32_t noVertices = mesh.getNoOfVertices();
    uint32_t noIndices = mesh.getNoOfIndices();

    PVWorld->estimateVertexCount(noVertices);
    PVWorld->estimateIndexCount(noIndices);

    PVWorld->begin("ColouredCubicVoxel", Ogre::RenderOperation::OT_TRIANGLE_LIST);

    // vertices
    const std::vector<PolyVox::PositionMaterialNormal>& vVertices = mesh.getVertices();
    for (unsigned int i=0; i<noVertices; i++) {
        const PolyVox::Vector3DFloat& pos = vVertices[i].getPosition();
        PVWorld->position(pos.getX(), pos.getY(), pos.getZ());
    }

    // indices
   
    const std::vector<uint32_t>& vIndices = mesh.getIndices();
    for (unsigned int i=0; i<noIndices; i++) {
        PVWorld->index( vIndices[i] );
    }
   

    PVWorld->end();
   PVWorld->convertToMesh(Ogre::String("Sphere"));
   Ogre::Entity* lEntity = mSceneMgr->createEntity(Ogre::String("Sphere"));
   Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode();
   node->attachObject(lEntity);
   


any idea what is wrong? Also I thought it is very interesting that at least for me, using cubicsurfaceextratorwithnormals is identical in speed to using cubicsurfaceextractor. One oddity is that the fps drops in half at some viewing angles of the sphere... I imagine just because of more faces, but still it is sad to drop from 900 to 450fps. I kind of expected it to be much faster than this, but I dunno I guess.

Author:  AndiNo [ Thu Nov 11, 2010 10:16 am ]
Post subject:  Re: Getting an access violation when I go "into" a polyvox m

As this looks very much like my code the code I currently have is nearly exactly the same. The only differences I can see are these:
I use
Code:
PolyVox::SurfaceMesh< PolyVox::PositionMaterial > mesh;
as mesh extractor and
Code:
const std::vector< PolyVox::PositionMaterial >& vVertices = mesh.getVertices();
when getting the vertices. Here's how you can calculate the normals in the shader: http://www.thermite3d.org/phpBB3/viewtopic.php?f=2&t=81

The end of the code looks something like this:
Code:
   PVWorld->end();
   node->attachObject(PVWorld);


I'm not sure why your program crashes if these are not the problems. Did you look at the Ogre log if you use it? Or maybe you should just put some simple printf's in there to see where it crashes.

paycheck wrote:
One oddity is that the fps drops in half at some viewing angles of the sphere...
I experience something similar here. However this could also have other causes as I do not have only one volume right now.

Author:  paycheck [ Thu Nov 11, 2010 4:40 pm ]
Post subject:  Re: Getting an access violation when I go "into" a polyvox m

Code:
09:35:17: OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/GenerateVS: CG ERROR : "The compile returned an error."
(0) : error C6015: Output 'POSITION' not completely written
 in CgProgram::loadFromSource at ..\..\..\..\..\PlugIns\CgProgramManager\src\OgreCgProgramManagerDll.cpp (line 67)
09:35:17: High-level program Ogre/ParticleGS/GenerateVS encountered an error during loading and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/GenerateVS: CG ERROR : "The compile returned an error."
(0) : error C6015: Output 'POSITION' not completely written
 in CgProgram::loadFromSource at ..\..\..\..\..\PlugIns\CgProgramManager\src\OgreCgProgramManagerDll.cpp (line 67)
09:35:17: OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/DisplayVS: CG ERROR : "The compile returned an error."
(249) : warning C7050: "output.color" might be used before being initialized
(0) : error C6015: Output 'POSITION' not completely written
 in CgProgram::loadFromSource at ..\..\..\..\..\PlugIns\CgProgramManager\src\OgreCgProgramManagerDll.cpp (line 67)
09:35:17: High-level program Ogre/ParticleGS/DisplayVS encountered an error during loading and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/DisplayVS: CG ERROR : "The compile returned an error."
(249) : warning C7050: "output.color" might be used before being initialized
(0) : error C6015: Output 'POSITION' not completely written
 in CgProgram::loadFromSource at ..\..\..\..\..\PlugIns\CgProgramManager\src\OgreCgProgramManagerDll.cpp (line 67)
09:35:17: OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/DisplayPS: CG ERROR : "The compile returned an error."
(323) : fatal error C9999: unexpected cast operation
 in CgProgram::loadFromSource at ..\..\..\..\..\PlugIns\CgProgramManager\src\OgreCgProgramManagerDll.cpp (line 67)
09:35:17: High-level program Ogre/ParticleGS/DisplayPS encountered an error during loading and is thus not supported.
OGRE EXCEPTION(7:InternalErrorException): Unable to compile Cg program Ogre/ParticleGS/DisplayPS: CG ERROR : "The compile returned an error."
(323) : fatal error C9999: unexpected cast operation
 in CgProgram::loadFromSource at ..\..\..\..\..\PlugIns\CgProgramManager\src\OgreCgProgramManagerDll.cpp (line 67)


and
Code:
09:35:19: Compiler error: unknown error in RTShaderSystem.material(23): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(52): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(81): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(110): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(146): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(81): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(162): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(81): token "rtshader_system" is not recognized
09:35:19: Compiler error: unknown error in RTShaderSystem.material(110): token "rtshader_system" is not recognized


are the only errors in the log... I'm not 100% satisfied that that is the problem, but I'll try and get the normals calculated like you suggested.

Author:  paycheck [ Thu Nov 11, 2010 4:48 pm ]
Post subject:  Re: Getting an access violation when I go "into" a polyvox m

Actually, I have no idea where to put that shader code... I've never dealt with shaders before, so any pointers would be good. I got rid of the problem by commenting out my directional light though (which wasn't doing anything anyway, because the shader code is wrong!) so I'm pretty sure that is the problem.

Once again, any tips would be massively appreciated. While I'm not doing anything today at work (I do tech support) I'll try and read all the relavent code in polyvox so I can use it a bit more effectively... I always seem to get lost in the complexity of ogre unless I do things by trial and error (it is too big to read and understand everything, at least for me right now : /) I really appreciate all the help though. Thanks.

Author:  AndiNo [ Thu Nov 11, 2010 6:26 pm ]
Post subject:  Re: Getting an access violation when I go "into" a polyvox m

I don't have much time right now, but look at this post or the whole thread for more information:
http://www.thermite3d.org/phpBB3/viewtopic.php?p=450#p450
And look here for more info on shaders:
http://www.ogre3d.org/docs/manual/manual_14.html#SEC23

Author:  David Williams [ Thu Nov 11, 2010 9:27 pm ]
Post subject:  Re: Getting an access violation when I go "into" a polyvox m

Correct me if I'm wrong, but it seems like we are talking about an Ogre/material issue here rather than a problem with PolyVox as such? If so I'll just answer you question in the other thread.

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/