~ubuntu-branches/ubuntu/trusty/openscenegraph/trusty

« back to all changes in this revision

Viewing changes to OpenSceneGraph/examples/osgautotransform/osgautotransform.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-07-29 04:34:38 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 lenny)
  • Revision ID: james.westby@ubuntu.com-20080729043438-no1h9h0dpsrlzp1y
* Non-maintainer upload.
* No longer try to detect (using /proc/cpuinfo when available) how many
  CPUs are available, fixing the FTBFS (due to -j0) on various platforms
  (Closes: #477353). The right way to do it is to support parallel=n in
  DEB_BUILD_OPTIONS (see Debian Policy §4.9.1), and adequate support has
  been implemented.
* Add patch to fix FTBFS due to the build system now refusing to handle
  whitespaces (Policy CMP0004 say the logs), thanks to Andreas Putzo who
  provided it (Closes: #482239):
   - debian/patches/fix-cmp0004-build-failure.dpatch
* Remove myself from Uploaders, as requested a while ago, done by Luk in
  his 2.2.0-2.1 NMU, which was never acknowledged.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <osg/AutoTransform>
29
29
#include <osg/Geometry>
30
30
 
 
31
#include <osgDB/WriteFile>
 
32
 
31
33
#include <osgText/Text>
32
34
 
33
35
#include <iostream>
112
114
        osg::Geometry* geom = new osg::Geometry;
113
115
        geom->setVertexArray(vertices);
114
116
        geom->setColorArray(colors);
 
117
        geom->setColorBinding(osg::Geometry::BIND_OVERALL);
115
118
        geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size()));
116
119
 
117
120
        osg::Geode* geode = new osg::Geode;
138
141
        osg::Geometry* geom = new osg::Geometry;
139
142
        geom->setVertexArray(vertices);
140
143
        geom->setColorArray(colors);
 
144
        geom->setColorBinding(osg::Geometry::BIND_OVERALL);
141
145
        geom->addPrimitiveSet(new osg::DrawArrays(GL_LINE_STRIP,0,vertices->size()));
142
146
 
143
147
        osg::Geode* geode = new osg::Geode;
149
153
    return group;
150
154
}
151
155
 
 
156
osg::Node* createAutoScale(const osg::Vec3& position, float characterSize, const std::string& message, float minScale=0.0, float maxScale=FLT_MAX)
 
157
{
 
158
    std::string timesFont("fonts/arial.ttf");
 
159
 
 
160
    osgText::Text* text = new osgText::Text;
 
161
    text->setCharacterSize(characterSize);
 
162
    text->setText(message);
 
163
    text->setFont(timesFont);
 
164
    text->setAlignment(osgText::Text::CENTER_CENTER);
 
165
 
 
166
    osg::Geode* geode = new osg::Geode;
 
167
    geode->addDrawable(text);
 
168
    geode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
 
169
 
 
170
    osg::AutoTransform* at = new osg::AutoTransform;
 
171
    at->addChild(geode);
 
172
    
 
173
    at->setAutoRotateMode(osg::AutoTransform::ROTATE_TO_SCREEN);
 
174
    at->setAutoScaleToScreen(true);
 
175
    at->setMinimumScale(minScale);
 
176
    at->setMaximumScale(maxScale);
 
177
    at->setPosition(position);
 
178
    
 
179
    return at;
 
180
}
 
181
 
152
182
osg::Node* createScene()
153
183
{
154
184
    osg::Group* root = new osg::Group;
158
188
    root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(1000.0,0.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_CAMERA,osgText::Text::XY_PLANE, "ROTATE_TO_CAMERA"));
159
189
    root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,1000.0,0.0),numReps,osg::AutoTransform::ROTATE_TO_SCREEN,osgText::Text::XY_PLANE, "ROTATE_TO_SCREEN"));
160
190
    root->addChild(createAxis(osg::Vec3(0.0,0.0,0.0),osg::Vec3(0.0,0.0,1000.0),numReps,osg::AutoTransform::NO_ROTATION,osgText::Text::XZ_PLANE, "NO_ROTATION"));    
161
 
    
 
191
 
 
192
    root->addChild(createAutoScale(osg::Vec3(500.0,500.0,500.0), 25.0, "AutoScale with no min, max limits"));
 
193
    root->addChild(createAutoScale(osg::Vec3(500.0,500.0,300.0), 25.0, "AutoScale with minScale = 1, maxScale = 2.0 ", 1, 2.0));
 
194
    root->addChild(createAutoScale(osg::Vec3(500.0,500.0,700.0), 25.0, "AutoScale with minScale = 0.0, maxScale = 5.0 ", 0.0, 5.0));
162
195
    return root;
163
196
}
164
197