Changeset 293


Ignore:
Timestamp:
Jun 5, 2011, 10:33:34 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/bin/osgVisualConfig.xml

    r286 r293  
    1515 
    1616  <scenery>
    17     <terrain filename="D:/OpenSceneGraph/VPB-Testdatensatz/DB_Small/database.ive.terrainmod" filename2="J:\BRD1m_MUC0.25m_srtmEU_BM\terrain.ive.terrainmod"></terrain>
     17    <terrain filename="D:/OpenSceneGraph/VPB-Testdatensatz/DB_Small/database.ive.terrainmod" filename2="J:\BRD1m_MUC0.25m_srtmEU_BM\terrain.ive.terrainmod" filename3="axes.osg.10000000.scale"></terrain>
    1818    <animationpath filename="airport_muc.path"></animationpath>
    1919    <models>
  • osgVisual/trunk/include/util/visual_util.h

    r273 r293  
    296296        static bool strToBool(std::string s);
    297297
     298        /**
     299         * \brief \todo : Kommentieren
     300         *
     301         * @param StartPoint
     302         * @param EndPoint
     303         * @param radius
     304         * @param CylinderColor
     305         * @param pAddToThisGroup
     306         */
     307        static void AddCylinderBetweenPoints(osg::Vec3d StartPoint, osg::Vec3d EndPoint, float radius, float length, osg::Vec4d CylinderColor, osg::Group *pAddToThisGroup);
     308
    298309        template<class T>
    299310        class FindTopMostNodeOfTypeVisitor : public osg::NodeVisitor
     
    352363         */
    353364        static xmlNode* checkXMLNodeChildrenForScenery(xmlNode* node);
     365
    354366};
    355367
  • osgVisual/trunk/src/sky_Silverlining/skySilverLining_skyDrawable.cpp

    r292 r293  
    7878        //direction = view * direction;
    7979        direction.normalize();
     80               
     81//OSG_NOTIFY(osg::ALWAYS)       << "Light Vector: X:"<<direction.x()<<" Y:"<<direction.y()<<" Z:"<<direction.z() << std::endl;
     82util::AddCylinderBetweenPoints(osg::Vec3d(0,0,0), direction , 10000.0, 15000000.0, osg::Vec4d(1.0, 1.0, 0.0, 1 ), sceneRoot);
    8083
    8184        light->setAmbient(ambient);
    8285        light->setDiffuse(diffuse);
    8386        //light->setSpecular(osg::Vec4(0,0,0,1));
    84                 light->setSpecular(osg::Vec4(1.0,1.0,1.0,1));   // Test
     87                //light->setSpecular(osg::Vec4(1.0,1.0,1.0,1)); // Test
    8588        light->setPosition(osg::Vec4(direction.x(), direction.y(), direction.z(), 0));
    8689    }
  • osgVisual/trunk/src/util/visual_util.cpp

    r226 r293  
    1616
    1717#include <visual_util.h>
     18#include <osg/Material>
    1819
    1920using namespace osgVisual;
     
    569570        return(false);
    570571}
     572
     573void util::AddCylinderBetweenPoints(osg::Vec3d StartPoint, osg::Vec3d EndPoint, float radius, float length, osg::Vec4d CylinderColor, osg::Group *pAddToThisGroup)
     574{
     575        osg::ref_ptr<osg::Geode> geode = new osg::Geode;
     576        osg::Vec3d center;
     577        float height;
     578        osg::ref_ptr<osg::Cylinder> cylinder;
     579        osg::ref_ptr<osg::Drawable> cylinderDrawable;
     580        osg::ref_ptr<osg::Material> pMaterial;
     581
     582        //height = (StartPoint-EndPoint).length();
     583        height  = length;
     584        center = osg::Vec3( (StartPoint.x() + EndPoint.x()) / 2, (StartPoint.y() + EndPoint.y()) / 2, (StartPoint.z() + EndPoint.z()) / 2);
     585
     586        // This is the default direction for the cylinders to face in OpenGL
     587        osg::Vec3d z = osg::Vec3d(0,0,1);
     588
     589        // Get diff between two points you want cylinder along
     590        osg::Vec3d p = StartPoint - EndPoint;
     591
     592        // Get CROSS product (the axis of rotation)
     593        osg::Vec3d t = z ^ p;
     594
     595        // Get angle. length is magnitude of the vector
     596        double angle = acos( (z * p) / p.length());
     597
     598        // Create a cylinder between the two points with the given radius
     599        cylinder = new osg::Cylinder(center,radius,height);
     600        cylinder->setRotation(osg::Quat(angle, osg::Vec3(t.x(), t.y(), t.z())));
     601
     602        cylinderDrawable = new osg::ShapeDrawable(cylinder );
     603        geode->addDrawable(cylinderDrawable);
     604
     605        // Set the color of the cylinder that extends between the two points.
     606        pMaterial = new osg::Material;
     607        pMaterial->setDiffuse( osg::Material::FRONT, CylinderColor);
     608        geode->getOrCreateStateSet()->setAttribute( pMaterial, osg::StateAttribute::OVERRIDE );
     609
     610        // Add the cylinder between the two points to an existing group
     611        pAddToThisGroup->addChild(geode);
     612}
Note: See TracChangeset for help on using the changeset viewer.