Hi all, Trying for hours to create a new geode, I'am having a bug I can't fix
Doing > _root->addChild(createSun(config->Sunpath)); > the program crashes This is the code of "createSun" osg::Geode* createSun(std::string texturePath) > { > int nb_edge = 30; > float radius = SUN_RADIUS/UNIT_METER/SUN_DIVIDER; > osg::Vec3 center = osg::Vec3(SUN_CENTER); > center.normalize(); > center *= SUN_DISTANCE/UNIT_METER/SUN_DIVIDER; > > osg::ref_ptr<osg::Billboard> billboard = new osg::Billboard(); > osg::Geometry* geometry = new osg::Geometry(); > > > osg::Vec3Array* vertices = new osg::Vec3Array(); > osg::Vec3Array* normals = new osg::Vec3Array(); > osg::Vec4Array* colors = new osg::Vec4Array(); > > //1st point is the center of the triangle fan > vertices->push_back(osg::Vec3(0,0,0)); > > for(int i=1; i<nb_edge; ++i) > { > vertices->push_back(osg::Vec3( radius * > cos(osg::DegreesToRadians(i/(float)(nb_edge/360.0f))), > radius * > sin(osg::DegreesToRadians(i/(float)(nb_edge/360.0f))), > .0f )); > } > > geometry->setVertexArray(vertices); > > normals->push_back(osg::Vec3(0,0,1)); > geometry->setNormalArray(normals); > geometry->setNormalBinding(osg::Geometry::BIND_OVERALL); > > colors->push_back(osg::Vec4(1,1,0,1)); > geometry->setColorArray(colors); > geometry->setColorBinding(osg::Geometry::BIND_OVERALL); > > osg::DrawElementsUShort* primitive = new > osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLE_FAN); > primitive->push_back(0); > for(int i=1; i<nb_edge; ++i) > primitive->push_back(i); > > geometry->addPrimitiveSet(primitive); > > billboard->addDrawable(geometry,center); > billboard->setMode(osg::Billboard::POINT_ROT_EYE); > center.normalize(); > billboard->setNormal(-center); > > return billboard.get(); > > } On crash it return the error: Exception non gérée à 0x10028b41 (osg25-osgd.dll) dans 3DEM.exe : > 0xC0000005: Violation d'accès lors de la lecture de l'emplacement 0xfeeefeee > Do you see any mistake ? Thanks a lot Regards, Vincent.
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org