bugman wrote:You got my 'reaching for the stars' reference The code I'm looking at is a few of the key parts of what needs to be adapted for landing on the moon! The ephemeris code, the lighting code, and the osg scene set up in the FG renderer. I was thinking of exactly what needs to be done for a moon landing (or orbit) as I was looking at all of this.
Referring to the idea of allowing arbitrary 3D spheres to be instantiated/created, textured and updated at run-time (aka Earthview in C++):
The boilerplate code required to add a new subsystem to the FlightGear main loop is this: http://wiki.flightgear.org/Howto:Create_new_subsystems
Adding a new "shape" or "sphere" subsystem would be pretty simple.
Next, it would need to instantiate, and position, an osg::Sphere - i.e. adapting the sample code at: http://trac.openscenegraph.org/document ... gShape.htm
- Code: Select all
osg::Sphere* unitSphere = new osg::Sphere( osg::Vec3(0,0,0), 1.0);
osg::PositionAttitudeTransform* sphereXForm =
new osg::PositionAttitudeTransform();
sphereXForm->setPosition(osg::Vec3(2.5,0,0));
osg::Geode* unitSphereGeode = new osg::Geode();
root->addChild(sphereXForm);
sphereXForm->addChild(unitSphereGeode);
unitSphereGeode->addDrawable(unitSphereDrawable);
Obviously, these are hard-coded values for now - but those could be either re-implemented using the propertyObject<> helper and/or by using the SGPropertyChangeListener interface to treat certain properties as "events", e.g. having /sphere/moon/position, /sphere/moon/size and /sphere/moon/texture nodes etc.
The main osg classes that would seem useful for this would be:
- osg::LightSource
- osg::Sphere (the 3D object itself)
- osg::PositionAttitudeTransformMatrix (PAT, for transforming & positioning the 3D model)
- osg::LOD to support different LODs
- osg::StateSet (for setting texturing/shader related attributes and modes)
References:
http://osghelp.com/?p=167
http://www.cuboslocos.com/tutorials/OSG-BasicLighting
http://trac.openscenegraph.org/document ... 00454.html