Re: [osg-users] exception with cullVisitor->traverse(*_camera) after manually creating a geode
Hi, awsome, thanks again for the advice. will do that from now on HAHA Thank you! Cheers, Renato -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46113#46113 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] exception with cullVisitor->traverse(*_camera) after manually creating a geode
Hi Renato, A trick we use in the OSG to prevent problems like this is to place the destructor of the class into the protected or private sections, these prevents these classes being allocated on the stack, forcing the user to use new. I would recommend using this approach on your Mesh class as this would have enabled the compiler to give you a warning about your problem usage. Robert. On 8 March 2012 18:25, Renato Oliveira wrote: > Hi, > > i finaly solved the problem. I kind of feel stupid with this issue. I was > creating the my mesh class with out allocating memory for it. > > Mesh mesh; //wrong > > Mesh* mesh = new Mesh; //right > > thanks again for the advices > > Thank you! > > Cheers, > Renato > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=46111#46111 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] exception with cullVisitor->traverse(*_camera) after manually creating a geode
Hi, i finaly solved the problem. I kind of feel stupid with this issue. I was creating the my mesh class with out allocating memory for it. Mesh mesh; //wrong Mesh* mesh = new Mesh; //right thanks again for the advices Thank you! Cheers, Renato -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46111#46111 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] exception with cullVisitor->traverse(*_camera) after manually creating a geode
On 03/07/2012 04:42 PM, Renato Oliveira wrote: Hi, sure i understand, sorry about that. i just wanted to know if someone already experienced the same issue before. what i am actually doing is i created a obj loader similar to the obj loader plugin from openscenegraph (the mojoraity of the code of copied directly just for test). once i have loaded the file, i create a mesh using all the information loaded and set the vertices, normals, texture cordinates, and primitive set. no problem there. than i attache my mesh to the a viewer like anyother example of the osg and run. like i said before, the crash happens when the cullvisitor's traverse function gets called when its building the sceneview. If the CullVisitor is crashing in the traverse() method, it's very likely that you've given the Viewer an invalid mesh to render. That method is used every frame by every OSG program in existence. It's extremely unlikely that it's the cause of your problem. You'll need to dig into your reworked .obj loader and figure out where the problem is. Make sure the vertices, normals, and texture coordinates all have the right number of items. Make sure that the primitives you create make sense (e.g. don't create a triangle with two or four vertices). Check for NaN's along the way. Things like that. I'd suggest starting with an .obj file that creates a single triangle. Test that, and work up from there. --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] exception with cullVisitor->traverse(*_camera) after manually creating a geode
Hi, sure i understand, sorry about that. i just wanted to know if someone already experienced the same issue before. what i am actually doing is i created a obj loader similar to the obj loader plugin from openscenegraph (the mojoraity of the code of copied directly just for test). once i have loaded the file, i create a mesh using all the information loaded and set the vertices, normals, texture cordinates, and primitive set. no problem there. than i attache my mesh to the a viewer like anyother example of the osg and run. like i said before, the crash happens when the cullvisitor's traverse function gets called when its building the sceneview. i have attached my mesh generator file to the post. Thank you! Cheers, Renato -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=46096#46096 // Alice - (C) Copyright 1993 Michel Gysen #pragma hdrfile "owlsys.csm" #pragma hdrstop #include //-- Mesh::Mesh():geometry(NULL),vertices(NULL),normals(NULL),texture(NULL), nullValue(0xf000),currentElementList(0) { geometry = new osg::Geometry; } //-- Mesh::~Mesh() { if(!geometry->empty()) geometry->unref(); } //-- PCChar Mesh::SetPath(PCChar pathIn,PCChar fileName,PCChar extName) { Char dev[4],dir[256],name[64],ext[64]; *dev = *dir = *name = *ext = 0; if(fileName) _splitpath(fileName,dev,dir,name,ext); _splitpath(pathIn,(*dev ? 0 : dev),(*dir ? 0 : dir),(*name ? 0 : name),(*ext ? 0 : ext)); if(!extName) extName = ext; _makepath(filePath,dev,dir,name,extName); return filePath; } //-- Int Mesh::addVertices(PCReal arr) { if(arr) { Real x = arr[0]; Real y = arr[1]; Real z = arr[2]; vertices.push_back(osg::Vec3(x,y,z)); return 0; } else return -1; } //-- Int Mesh::addNormals(PCReal arr) { if(arr) { Real x = arr[0]; Real y = arr[1]; Real z = arr[2]; normals.push_back(osg::Vec3(x,y,z)); return 0; } else return -1; } //-- Int Mesh::addTexture(PCReal arr) { if(arr) { Real x = arr[0]; Real y = arr[1]; texture.push_back(osg::Vec2(x,y)); return 0; } else return -1; } //-- /* * will add the primitive set beased on the element list data */ Int Mesh::addFace(PLong iworkSpace,Int nf) { if(iworkSpace) { //Elements array that will store our faces indexes Element* element = new Element(Element::POLYGON); //loop the number of entrires (v/vt/vn) in a line and //push the indexes into the element table. for(Int i = 0; i < nf; i++) { element->vertexIndices.push_back(remapVertexIndex(iworkSpace[3*i])); element->texCoordIndices.push_back(remapTexCoordIndex(iworkSpace[3*i+1])); element->normalIndices.push_back(remapNormalIndex(iworkSpace[3*i+2])); } if (!element->normalIndices.empty() && element->normalIndices.size() != element->vertexIndices.size()) element->normalIndices.clear(); if (!element->texCoordIndices.empty() && element->texCoordIndices.size() != element->vertexIndices.size()) element->texCoordIndices.clear(); if (!element->vertexIndices.empty()) { Element::CoordinateCombination coordateCombination = element->getCoordinateCombination(); if (coordateCombination!=currentElementState.coordinateCombination) { currentElementState.coordinateCombination = coordateCombination; currentElementList = 0; // reset the element list to force a recompute of which ElementList to use } if (!currentElementList) { currentElementList = & (elementStateMap[currentElementState]); } //push the elements previoulsy set to the main element list currentElementList->push_back(element); } else { // empty element, don't both adding, just unref to delete it. element->unref(); } //push the elements previoulsy set to the main element list return 0; } else return -1; } //-- /* * Convert the element list indices into primitive sets to build the faces * All of the code was copied from the openscenegraph obj plugin */ Int Mesh::convertElementListToGeometry(ElementList& elem) { UInt numVertexIndices = 0; UInt numNormalIndices = 0; UInt numTexCoordIndices = 0; UInt numPointElements = 0; UInt numPolylineElements = 0;
Re: [osg-users] exception with cullVisitor->traverse(*_camera) after manually creating a geode
On 03/07/2012 04:15 PM, Renato Oliveira wrote: Hi, I am having a problem in which i get an exception when OSG is trying to render my manually created geode. The crash happens in sceneView.cpp when calling cullVisitor->traverse(*_camera). Does anyone have any ideias what might be? Hi, Renato, We're going to need a lot more specific information than "I get an exception" and "my manually created geode" before any of us can come close to helping you. Take a look at this link and try again: http://catb.org/esr/faqs/smart-questions.html --"J" ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org