| 1 | #include <osg/Geode> |
|---|
| 2 | #include <osg/ShapeDrawable> |
|---|
| 3 | #include <osg/Material> |
|---|
| 4 | #include <osg/Texture2D> |
|---|
| 5 | #include <osg/Geometry> |
|---|
| 6 | #include <osg/MatrixTransform> |
|---|
| 7 | #include <osg/PositionAttitudeTransform> |
|---|
| 8 | #include <osg/BlendFunc> |
|---|
| 9 | #include <osg/ClearNode> |
|---|
| 10 | |
|---|
| 11 | #include <osgUtil/Tesselator> |
|---|
| 12 | #include <osgUtil/CullVisitor> |
|---|
| 13 | |
|---|
| 14 | #include <osgText/Text> |
|---|
| 15 | |
|---|
| 16 | #include <osgGA/TrackballManipulator> |
|---|
| 17 | |
|---|
| 18 | #include <osgProducer/Viewer> |
|---|
| 19 | |
|---|
| 20 | #include <osgDB/ReadFile> |
|---|
| 21 | |
|---|
| 22 | static bool s_ProfessionalServices = false; |
|---|
| 23 | |
|---|
| 24 | class MyBillboardTransform : public osg::PositionAttitudeTransform |
|---|
| 25 | { |
|---|
| 26 | public: |
|---|
| 27 | |
|---|
| 28 | MyBillboardTransform(): |
|---|
| 29 | _axis(0.0f,0.0f,1.0f), |
|---|
| 30 | _normal(0.0f,-1.0f,0.0f) |
|---|
| 31 | { |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const |
|---|
| 35 | { |
|---|
| 36 | osg::Quat billboardRotation; |
|---|
| 37 | osgUtil::CullVisitor* cullvisitor = dynamic_cast<osgUtil::CullVisitor*>(nv); |
|---|
| 38 | if (cullvisitor) |
|---|
| 39 | { |
|---|
| 40 | osg::Vec3 eyevector = cullvisitor->getEyeLocal()-_position; |
|---|
| 41 | eyevector.normalize(); |
|---|
| 42 | |
|---|
| 43 | osg::Vec3 side = _axis^_normal; |
|---|
| 44 | side.normalize(); |
|---|
| 45 | |
|---|
| 46 | float angle = atan2(eyevector*_normal,eyevector*side); |
|---|
| 47 | billboardRotation.makeRotate(osg::PI_2-angle,_axis); |
|---|
| 48 | |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | matrix.preMult(osg::Matrix::translate(-_pivotPoint)* |
|---|
| 53 | osg::Matrix::rotate(_attitude)* |
|---|
| 54 | osg::Matrix::rotate(billboardRotation)* |
|---|
| 55 | osg::Matrix::translate(_position)); |
|---|
| 56 | return true; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | void setAxis(const osg::Vec3& axis) { _axis = axis; } |
|---|
| 62 | |
|---|
| 63 | void setNormal(const osg::Vec3& normal) { _normal = normal; } |
|---|
| 64 | |
|---|
| 65 | protected: |
|---|
| 66 | |
|---|
| 67 | virtual ~MyBillboardTransform() {} |
|---|
| 68 | |
|---|
| 69 | osg::Vec3 _axis; |
|---|
| 70 | osg::Vec3 _normal; |
|---|
| 71 | }; |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | osg::Geometry* createWing(const osg::Vec3& left, const osg::Vec3& nose, const osg::Vec3& right,float chordRatio,const osg::Vec4& color) |
|---|
| 75 | { |
|---|
| 76 | osg::Geometry* geom = new osg::Geometry; |
|---|
| 77 | |
|---|
| 78 | osg::Vec3 normal = (nose-right)^(left-nose); |
|---|
| 79 | normal.normalize(); |
|---|
| 80 | |
|---|
| 81 | osg::Vec3 left_to_right = right-left; |
|---|
| 82 | osg::Vec3 mid = (right+left)*0.5f; |
|---|
| 83 | osg::Vec3 mid_to_nose = (nose-mid)*chordRatio*0.5f; |
|---|
| 84 | |
|---|
| 85 | osg::Vec3Array* vertices = new osg::Vec3Array; |
|---|
| 86 | vertices->push_back(left); |
|---|
| 87 | |
|---|
| 88 | |
|---|
| 89 | unsigned int noSteps = 40; |
|---|
| 90 | for(unsigned int i=1;i<noSteps;++i) |
|---|
| 91 | { |
|---|
| 92 | float ratio = (float)i/(float)noSteps; |
|---|
| 93 | vertices->push_back(left + left_to_right*ratio + mid_to_nose* (cosf((ratio-0.5f)*osg::PI*2.0f)+1.0f)); |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | vertices->push_back(right); |
|---|
| 97 | vertices->push_back(nose); |
|---|
| 98 | |
|---|
| 99 | geom->setVertexArray(vertices); |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | osg::Vec3Array* normals = new osg::Vec3Array; |
|---|
| 103 | normals->push_back(normal); |
|---|
| 104 | geom->setNormalArray(normals); |
|---|
| 105 | geom->setNormalBinding(osg::Geometry::BIND_OVERALL); |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | osg::Vec4Array* colors = new osg::Vec4Array; |
|---|
| 109 | colors->push_back(color); |
|---|
| 110 | geom->setColorArray(colors); |
|---|
| 111 | geom->setColorBinding(osg::Geometry::BIND_OVERALL); |
|---|
| 112 | |
|---|
| 113 | |
|---|
| 114 | geom->addPrimitiveSet(new osg::DrawArrays(GL_POLYGON,0,vertices->getNumElements())); |
|---|
| 115 | |
|---|
| 116 | osgUtil::Tesselator tesselator; |
|---|
| 117 | tesselator.retesselatePolygons(*geom); |
|---|
| 118 | |
|---|
| 119 | return geom; |
|---|
| 120 | |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | osg:: Node* createTextBelow(const osg::BoundingBox& bb) |
|---|
| 124 | { |
|---|
| 125 | osg::Geode* geode = new osg::Geode(); |
|---|
| 126 | |
|---|
| 127 | std::string font("fonts/arial.ttf"); |
|---|
| 128 | |
|---|
| 129 | osgText::Text* text = new osgText::Text; |
|---|
| 130 | |
|---|
| 131 | text->setFont(font); |
|---|
| 132 | text->setFontResolution(64,64); |
|---|
| 133 | text->setAlignment(osgText::Text::CENTER_CENTER); |
|---|
| 134 | text->setAxisAlignment(osgText::Text::XZ_PLANE); |
|---|
| 135 | text->setPosition(bb.center()-osg::Vec3(0.0f,0.0f,(bb.zMax()-bb.zMin()))); |
|---|
| 136 | text->setColor(osg::Vec4(0.37f,0.48f,0.67f,1.0f)); |
|---|
| 137 | text->setText("OpenSceneGraph"); |
|---|
| 138 | |
|---|
| 139 | geode->addDrawable( text ); |
|---|
| 140 | |
|---|
| 141 | return geode; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | osg:: Node* createTextLeft(const osg::BoundingBox& bb) |
|---|
| 145 | { |
|---|
| 146 | osg::Geode* geode = new osg::Geode(); |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | osg::StateSet* stateset = geode->getOrCreateStateSet(); |
|---|
| 150 | stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | std::string font("fonts/arial.ttf"); |
|---|
| 155 | |
|---|
| 156 | osgText::Text* text = new osgText::Text; |
|---|
| 157 | |
|---|
| 158 | text->setFont(font); |
|---|
| 159 | text->setFontResolution(110,120); |
|---|
| 160 | text->setAlignment(osgText::Text::RIGHT_CENTER); |
|---|
| 161 | text->setAxisAlignment(osgText::Text::XZ_PLANE); |
|---|
| 162 | text->setCharacterSize((bb.zMax()-bb.zMin())*1.0f); |
|---|
| 163 | text->setPosition(bb.center()-osg::Vec3((bb.xMax()-bb.xMin()),-(bb.yMax()-bb.yMin())*0.5f,(bb.zMax()-bb.zMin())*0.1f)); |
|---|
| 164 | |
|---|
| 165 | text->setColor(osg::Vec4(0.20f,0.45f,0.60f,1.0f)); |
|---|
| 166 | text->setText("OpenSceneGraph"); |
|---|
| 167 | |
|---|
| 168 | #if 1 |
|---|
| 169 | text->setBackdropType(osgText::Text::OUTLINE); |
|---|
| 170 | text->setBackdropOffset(0.05f); |
|---|
| 171 | text->setBackdropColor(osg::Vec4(0.0f, 0.0f, 0.5f, 1.0f)); |
|---|
| 172 | #endif |
|---|
| 173 | |
|---|
| 174 | |
|---|
| 175 | #if 1 |
|---|
| 176 | text->setColorGradientMode(osgText::Text::OVERALL); |
|---|
| 177 | osg::Vec4 lightblue(0.30f,0.6f,0.90f,1.0f); |
|---|
| 178 | osg::Vec4 blue(0.10f,0.30f,0.40f,1.0f); |
|---|
| 179 | text->setColorGradientCorners(lightblue, blue, blue, lightblue); |
|---|
| 180 | #else |
|---|
| 181 | text->setColorGradientMode(osgText::Text::OVERALL); |
|---|
| 182 | osg::Vec4 light = osg::Vec4(0.0f, 1.0f, 1.0f, 1.0f); |
|---|
| 183 | osg::Vec4 dark = osg::Vec4(0.0f, 0.0f, 0.5f, 1.0f); |
|---|
| 184 | text->setColorGradientCorners(light, dark, dark, light); |
|---|
| 185 | |
|---|
| 186 | #endif |
|---|
| 187 | |
|---|
| 188 | geode->addDrawable( text ); |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | if (s_ProfessionalServices) |
|---|
| 192 | { |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | osgText::Text* subscript = new osgText::Text; |
|---|
| 196 | subscript->setFont(font); |
|---|
| 197 | subscript->setText("Professional Services"); |
|---|
| 198 | subscript->setAlignment(osgText::Text::RIGHT_CENTER); |
|---|
| 199 | subscript->setAxisAlignment(osgText::Text::XZ_PLANE); |
|---|
| 200 | subscript->setPosition(bb.center()-osg::Vec3((bb.xMax()-bb.xMin())*4.3f,-(bb.yMax()-bb.yMin())*0.5f,(bb.zMax()-bb.zMin())*0.6f)); |
|---|
| 201 | subscript->setColor(osg::Vec4(0.0f,0.0f,0.0f,1.0f)); |
|---|
| 202 | |
|---|
| 203 | geode->addDrawable( subscript ); |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | return geode; |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | osg:: Node* createGlobe(const osg::BoundingBox& bb,float ratio, const std::string& filename) |
|---|
| 210 | { |
|---|
| 211 | osg::MatrixTransform* xform = new osg::MatrixTransform; |
|---|
| 212 | xform->setUpdateCallback(new osg::AnimationPathCallback(bb.center(),osg::Vec3(0.0f,0.0f,1.0f),osg::inDegrees(10.0f))); |
|---|
| 213 | |
|---|
| 214 | osg::Node* bluemarble = filename.empty() ? 0 : osgDB::readNodeFile(filename.c_str()); |
|---|
| 215 | if (bluemarble) |
|---|
| 216 | { |
|---|
| 217 | const osg::BoundingSphere& bs = bluemarble->getBound(); |
|---|
| 218 | float s = 1.2*bb.radius()/bs.radius(); |
|---|
| 219 | osg::MatrixTransform* positioner = new osg::MatrixTransform; |
|---|
| 220 | positioner->setMatrix(osg::Matrix::translate(-bs.center())*osg::Matrix::scale(s,s,s)*osg::Matrix::translate(bb.center())); |
|---|
| 221 | positioner->addChild(bluemarble); |
|---|
| 222 | |
|---|
| 223 | xform->addChild(positioner); |
|---|
| 224 | } |
|---|
| 225 | else |
|---|
| 226 | { |
|---|
| 227 | |
|---|
| 228 | osg::Geode* geode = new osg::Geode(); |
|---|
| 229 | |
|---|
| 230 | osg::StateSet* stateset = geode->getOrCreateStateSet(); |
|---|
| 231 | |
|---|
| 232 | osg::Image* image = osgDB::readImageFile("Images/land_shallow_topo_2048.jpg"); |
|---|
| 233 | if (image) |
|---|
| 234 | { |
|---|
| 235 | osg::Texture2D* texture = new osg::Texture2D; |
|---|
| 236 | texture->setImage(image); |
|---|
| 237 | texture->setMaxAnisotropy(8); |
|---|
| 238 | stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON); |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | osg::Material* material = new osg::Material; |
|---|
| 242 | stateset->setAttribute(material); |
|---|
| 243 | |
|---|
| 244 | |
|---|
| 245 | geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(bb.center(),bb.radius()*ratio))); |
|---|
| 246 | |
|---|
| 247 | xform->addChild(geode); |
|---|
| 248 | } |
|---|
| 249 | |
|---|
| 250 | return xform; |
|---|
| 251 | } |
|---|
| 252 | |
|---|
| 253 | osg:: Node* createBox(const osg::BoundingBox& bb,float chordRatio) |
|---|
| 254 | { |
|---|
| 255 | osg::Geode* geode = new osg::Geode(); |
|---|
| 256 | |
|---|
| 257 | osg::Vec4 white(1.0f,1.0f,1.0f,1.0f); |
|---|
| 258 | |
|---|
| 259 | |
|---|
| 260 | geode->addDrawable(createWing(bb.corner(4),bb.corner(6),bb.corner(7),chordRatio,white)); |
|---|
| 261 | geode->addDrawable(createWing(bb.corner(7),bb.corner(5),bb.corner(4),chordRatio,white)); |
|---|
| 262 | |
|---|
| 263 | geode->addDrawable(createWing(bb.corner(4),bb.corner(5),bb.corner(1),chordRatio,white)); |
|---|
| 264 | geode->addDrawable(createWing(bb.corner(1),bb.corner(0),bb.corner(4),chordRatio,white)); |
|---|
| 265 | |
|---|
| 266 | geode->addDrawable(createWing(bb.corner(1),bb.corner(5),bb.corner(7),chordRatio,white)); |
|---|
| 267 | geode->addDrawable(createWing(bb.corner(7),bb.corner(3),bb.corner(1),chordRatio,white)); |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | geode->addDrawable(createWing(bb.corner(2),bb.corner(0),bb.corner(1),chordRatio,white)); |
|---|
| 271 | geode->addDrawable(createWing(bb.corner(1),bb.corner(3),bb.corner(2),chordRatio,white)); |
|---|
| 272 | |
|---|
| 273 | geode->addDrawable(createWing(bb.corner(2),bb.corner(3),bb.corner(7),chordRatio,white)); |
|---|
| 274 | geode->addDrawable(createWing(bb.corner(7),bb.corner(6),bb.corner(2),chordRatio,white)); |
|---|
| 275 | |
|---|
| 276 | geode->addDrawable(createWing(bb.corner(2),bb.corner(6),bb.corner(4),chordRatio,white)); |
|---|
| 277 | geode->addDrawable(createWing(bb.corner(4),bb.corner(0),bb.corner(2),chordRatio,white)); |
|---|
| 278 | |
|---|
| 279 | return geode; |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | osg:: Node* createBoxNo5(const osg::BoundingBox& bb,float chordRatio) |
|---|
| 283 | { |
|---|
| 284 | osg::Geode* geode = new osg::Geode(); |
|---|
| 285 | |
|---|
| 286 | osg::Vec4 white(1.0f,1.0f,1.0f,1.0f); |
|---|
| 287 | |
|---|
| 288 | |
|---|
| 289 | geode->addDrawable(createWing(bb.corner(4),bb.corner(6),bb.corner(7),chordRatio,white)); |
|---|
| 290 | |
|---|
| 291 | geode->addDrawable(createWing(bb.corner(1),bb.corner(0),bb.corner(4),chordRatio,white)); |
|---|
| 292 | |
|---|
| 293 | geode->addDrawable(createWing(bb.corner(7),bb.corner(3),bb.corner(1),chordRatio,white)); |
|---|
| 294 | |
|---|
| 295 | |
|---|
| 296 | geode->addDrawable(createWing(bb.corner(2),bb.corner(0),bb.corner(1),chordRatio,white)); |
|---|
| 297 | geode->addDrawable(createWing(bb.corner(1),bb.corner(3),bb.corner(2),chordRatio,white)); |
|---|
| 298 | |
|---|
| 299 | geode->addDrawable(createWing(bb.corner(2),bb.corner(3),bb.corner(7),chordRatio,white)); |
|---|
| 300 | geode->addDrawable(createWing(bb.corner(7),bb.corner(6),bb.corner(2),chordRatio,white)); |
|---|
| 301 | |
|---|
| 302 | geode->addDrawable(createWing(bb.corner(2),bb.corner(6),bb.corner(4),chordRatio,white)); |
|---|
| 303 | geode->addDrawable(createWing(bb.corner(4),bb.corner(0),bb.corner(2),chordRatio,white)); |
|---|
| 304 | |
|---|
| 305 | return geode; |
|---|
| 306 | } |
|---|
| 307 | |
|---|
| 308 | osg:: Node* createBoxNo5No2(const osg::BoundingBox& bb,float chordRatio) |
|---|
| 309 | { |
|---|
| 310 | osg::Geode* geode = new osg::Geode(); |
|---|
| 311 | |
|---|
| 312 | |
|---|
| 313 | |
|---|
| 314 | |
|---|
| 315 | |
|---|
| 316 | osg::Vec4 red(1.0f,0.12f,0.06f,1.0f); |
|---|
| 317 | osg::Vec4 green(0.21f,0.48f,0.03f,1.0f); |
|---|
| 318 | osg::Vec4 blue(0.20f,0.45f,0.60f,1.0f); |
|---|
| 319 | |
|---|
| 320 | |
|---|
| 321 | geode->addDrawable(createWing(bb.corner(4),bb.corner(6),bb.corner(7),chordRatio,red)); |
|---|
| 322 | |
|---|
| 323 | geode->addDrawable(createWing(bb.corner(1),bb.corner(0),bb.corner(4),chordRatio,green)); |
|---|
| 324 | |
|---|
| 325 | geode->addDrawable(createWing(bb.corner(7),bb.corner(3),bb.corner(1),chordRatio,blue)); |
|---|
| 326 | |
|---|
| 327 | return geode; |
|---|
| 328 | } |
|---|
| 329 | |
|---|
| 330 | osg:: Node* createBackdrop(const osg::Vec3& corner,const osg::Vec3& top,const osg::Vec3& right) |
|---|
| 331 | { |
|---|
| 332 | |
|---|
| 333 | |
|---|
| 334 | |
|---|
| 335 | osg::Geometry* geom = new osg::Geometry; |
|---|
| 336 | |
|---|
| 337 | osg::Vec3 normal = (corner-top)^(right-corner); |
|---|
| 338 | normal.normalize(); |
|---|
| 339 | |
|---|
| 340 | osg::Vec3Array* vertices = new osg::Vec3Array; |
|---|
| 341 | vertices->push_back(top); |
|---|
| 342 | vertices->push_back(corner); |
|---|
| 343 | |
|---|
| 344 | vertices->push_back(right); |
|---|
| 345 | vertices->push_back(right+(top-corner)); |
|---|
| 346 | |
|---|
| 347 | geom->setVertexArray(vertices); |
|---|
| 348 | |
|---|
| 349 | osg::Vec3Array* normals = new osg::Vec3Array; |
|---|
| 350 | normals->push_back(normal); |
|---|
| 351 | geom->setNormalArray(normals); |
|---|
| 352 | geom->setNormalBinding(osg::Geometry::BIND_OVERALL); |
|---|
| 353 | |
|---|
| 354 | osg::Vec4Array* colors = new osg::Vec4Array; |
|---|
| 355 | colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); |
|---|
| 356 | geom->setColorArray(colors); |
|---|
| 357 | geom->setColorBinding(osg::Geometry::BIND_OVERALL); |
|---|
| 358 | |
|---|
| 359 | geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,vertices->getNumElements())); |
|---|
| 360 | |
|---|
| 361 | osg::Geode* geode = new osg::Geode(); |
|---|
| 362 | geode->addDrawable(geom); |
|---|
| 363 | |
|---|
| 364 | return geode; |
|---|
| 365 | } |
|---|
| 366 | |
|---|
| 367 | osg::Node* createLogo(const std::string& filename) |
|---|
| 368 | { |
|---|
| 369 | osg::BoundingBox bb(osg::Vec3(0.0f,0.0f,0.0f),osg::Vec3(100.0f,100.0f,100.0f)); |
|---|
| 370 | float chordRatio = 0.5f; |
|---|
| 371 | float sphereRatio = 0.6f; |
|---|
| 372 | |
|---|
| 373 | |
|---|
| 374 | osg::Group* logo_group = new osg::Group; |
|---|
| 375 | |
|---|
| 376 | osg::Quat r1,r2; |
|---|
| 377 | r1.makeRotate(-osg::inDegrees(45.0f),0.0f,0.0f,1.0f); |
|---|
| 378 | r2.makeRotate(osg::inDegrees(45.0f),1.0f,0.0f,0.0f); |
|---|
| 379 | |
|---|
| 380 | |
|---|
| 381 | MyBillboardTransform* xform = new MyBillboardTransform; |
|---|
| 382 | xform->setPivotPoint(bb.center()); |
|---|
| 383 | xform->setPosition(bb.center()); |
|---|
| 384 | xform->setAttitude(r1*r2); |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | |
|---|
| 388 | |
|---|
| 389 | |
|---|
| 390 | |
|---|
| 391 | |
|---|
| 392 | |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | |
|---|
| 396 | |
|---|
| 397 | |
|---|
| 398 | xform->addChild(createBoxNo5No2(bb,chordRatio)); |
|---|
| 399 | |
|---|
| 400 | logo_group->addChild(xform); |
|---|
| 401 | |
|---|
| 402 | logo_group->addChild(createGlobe(bb,sphereRatio,filename)); |
|---|
| 403 | |
|---|
| 404 | |
|---|
| 405 | |
|---|
| 406 | logo_group->addChild(createTextLeft(bb)); |
|---|
| 407 | |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | osg::Vec3 corner(-900.0f,150.0f,-100.0f); |
|---|
| 411 | osg::Vec3 top(0.0f,0.0f,300.0f); top += corner; |
|---|
| 412 | osg::Vec3 right(1100.0f,0.0f,0.0f); right += corner; |
|---|
| 413 | |
|---|
| 414 | |
|---|
| 415 | |
|---|
| 416 | |
|---|
| 417 | |
|---|
| 418 | osg::ClearNode* backdrop = new osg::ClearNode; |
|---|
| 419 | backdrop->setClearColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); |
|---|
| 420 | |
|---|
| 421 | |
|---|
| 422 | |
|---|
| 423 | |
|---|
| 424 | osg::Group* scene = new osg::Group; |
|---|
| 425 | |
|---|
| 426 | osg::StateSet* stateset = scene->getOrCreateStateSet(); |
|---|
| 427 | stateset->setMode(GL_LIGHTING,osg::StateAttribute::OVERRIDE|osg::StateAttribute::OFF); |
|---|
| 428 | |
|---|
| 429 | |
|---|
| 430 | scene->addChild(logo_group); |
|---|
| 431 | scene->addChild(backdrop); |
|---|
| 432 | |
|---|
| 433 | return scene; |
|---|
| 434 | } |
|---|
| 435 | |
|---|
| 436 | int main( int argc, char **argv ) |
|---|
| 437 | { |
|---|
| 438 | |
|---|
| 439 | |
|---|
| 440 | osg::ArgumentParser arguments(&argc,argv); |
|---|
| 441 | |
|---|
| 442 | |
|---|
| 443 | arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which demonstrates both text, animation and billboard via custom transform to create the OpenSceneGraph logo.."); |
|---|
| 444 | |
|---|
| 445 | arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+"[options] [filename] ..."); |
|---|
| 446 | arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); |
|---|
| 447 | arguments.getApplicationUsage()->addCommandLineOption("ps","Render the Professional Services logo"); |
|---|
| 448 | |
|---|
| 449 | |
|---|
| 450 | osgProducer::Viewer viewer(arguments); |
|---|
| 451 | |
|---|
| 452 | |
|---|
| 453 | viewer.setUpViewer(osgProducer::Viewer::STANDARD_SETTINGS); |
|---|
| 454 | |
|---|
| 455 | |
|---|
| 456 | viewer.getUsage(*arguments.getApplicationUsage()); |
|---|
| 457 | |
|---|
| 458 | |
|---|
| 459 | if (arguments.read("-h") || arguments.read("--help")) |
|---|
| 460 | { |
|---|
| 461 | arguments.getApplicationUsage()->write(std::cout); |
|---|
| 462 | return 1; |
|---|
| 463 | } |
|---|
| 464 | |
|---|
| 465 | while (arguments.read("ps")) s_ProfessionalServices = true; |
|---|
| 466 | |
|---|
| 467 | |
|---|
| 468 | arguments.reportRemainingOptionsAsUnrecognized(); |
|---|
| 469 | |
|---|
| 470 | |
|---|
| 471 | if (arguments.errors()) |
|---|
| 472 | { |
|---|
| 473 | arguments.writeErrorMessages(std::cout); |
|---|
| 474 | return 1; |
|---|
| 475 | } |
|---|
| 476 | |
|---|
| 477 | osg::Node* node = 0; |
|---|
| 478 | |
|---|
| 479 | if (arguments.argc()>1) createLogo(arguments[1]); |
|---|
| 480 | else node = createLogo(""); |
|---|
| 481 | |
|---|
| 482 | |
|---|
| 483 | viewer.setSceneData( node ); |
|---|
| 484 | |
|---|
| 485 | |
|---|
| 486 | viewer.realize(); |
|---|
| 487 | |
|---|
| 488 | while( !viewer.done() ) |
|---|
| 489 | { |
|---|
| 490 | |
|---|
| 491 | viewer.sync(); |
|---|
| 492 | |
|---|
| 493 | |
|---|
| 494 | |
|---|
| 495 | viewer.update(); |
|---|
| 496 | |
|---|
| 497 | |
|---|
| 498 | viewer.frame(); |
|---|
| 499 | |
|---|
| 500 | } |
|---|
| 501 | |
|---|
| 502 | |
|---|
| 503 | viewer.sync(); |
|---|
| 504 | |
|---|
| 505 | return 0; |
|---|
| 506 | } |
|---|