source: osgVisual/trunk/src/draw3D/visual_draw3D.cpp @ 238

Last change on this file since 238 was 221, checked in by Torben Dannhauer, 14 years ago

Updated copyright NOTICE
(No code changes)

File size: 3.0 KB
RevLine 
[221]1/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer
[31]2 *
3 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
9 * You have to aquire licenses for all used proprietary modules.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * OpenSceneGraph Public License for more details.
15*/
16
17#include <visual_draw3D.h>
18
19using namespace osgVisual;
20
21visual_draw3D::visual_draw3D(void)
22{
23}
24
25visual_draw3D::~visual_draw3D(void)
26{
27}
28
29void visual_draw3D::init( osg::CoordinateSystemNode* rootNode_, osgViewer::Viewer *viewer_ )
30{
31        osg::Matrix testmatrix = viewer_->getCamera()->getViewMatrix();
32
33        testmatrix.makeTranslate( 2.0, 2.0, 2.0 );
34        //testmatrix.
35        osg::ref_ptr<osg::Geode> hudGeode = new osg::Geode();
36        rootNode_->addChild( hudGeode );
37
38
39    // create background
40       
41        // configuring background shape
42        float depth = -0.1; // Paint background behind text.
43        osg::Vec4f bgColor_rgba = osg::Vec4(1.0f,1.0,0.8f,0.2f);
44        osg::Vec3 hudCenter = osg::Vec3(0.0, 0.0, 0.0);
45        float baseSize = 200;
46        float addSize = 70;
47
48
49        osg::Geometry* hudBackground = new osg::Geometry;
50
51        osg::Vec3Array* vertices = new osg::Vec3Array;
52        vertices->push_back(hudCenter+osg::Vec3(baseSize+addSize, baseSize, depth));
53        vertices->push_back(hudCenter+osg::Vec3(baseSize, baseSize+addSize, depth));
54        vertices->push_back(hudCenter+osg::Vec3(-baseSize , baseSize+addSize, depth));
55        vertices->push_back(hudCenter+osg::Vec3(-baseSize-addSize, baseSize,depth));
56        vertices->push_back(hudCenter+osg::Vec3(-baseSize-addSize, -baseSize,depth));
57        vertices->push_back(hudCenter+osg::Vec3(-baseSize , -baseSize-addSize, depth));
58        vertices->push_back(hudCenter+osg::Vec3(baseSize, -baseSize-addSize, depth));
59        vertices->push_back(hudCenter+osg::Vec3(baseSize+addSize, -baseSize, depth));
60        hudBackground->setVertexArray(vertices);
61       
62        osg::Vec3Array* normals = new osg::Vec3Array;
63        normals->push_back(osg::Vec3(0.0f,0.0f,1.0f));
64        hudBackground->setNormalArray(normals);
65        hudBackground->setNormalBinding(osg::Geometry::BIND_OVERALL);
66       
67        osg::Vec4Array* colors = new osg::Vec4Array;
68        colors->push_back( bgColor_rgba );
69        hudBackground->setColorArray(colors);
70        hudBackground->setColorBinding(osg::Geometry::BIND_OVERALL);
71       
72        hudBackground->addPrimitiveSet(new osg::DrawArrays(GL_POLYGON,0,8));
73       
74        osg::StateSet* stateset = hudBackground->getOrCreateStateSet();
75        stateset->setMode(GL_BLEND,osg::StateAttribute::ON);
76        stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
77
78}
Note: See TracBrowser for help on using the repository browser.