fixed: auto_ptr -> unique_ptr
[opensg.git] / Tools / osgBench / Test.h
blob698bc7c74cecd231abf82fa432366c8454109192
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _TEST_H_
40 #define _TEST_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include <vector>
46 #include <OpenSG/OSGConfig.h>
47 #include <OpenSG/OSGNode.h>
48 #include <OpenSG/OSGStatCollector.h>
49 #include "TestWindow.h"
50 #include "Nodes.h"
51 #include "Image.h"
53 class Test
55 /*========================== PUBLIC =================================*/
56 public:
58 Test(void);
60 ~Test();
62 // Set up scene characteristics
64 void setScene(NodeBase &scene);
66 void setScene(OSG::NodePtr scene);
68 void setWindow(TestWindow &win);
70 void setHeadlight(bool on);
72 // set near and far, if any <= 0 use showAll() values
73 void setNearFar(OSG::Real32 n, OSG::Real32 f);
75 // Setup Test Frames
77 // clear all the animation data
78 void clear(void);
80 // MinTime takes precedence, the path is repeated fully until the time is
81 // reached
83 void setNFrames(OSG::UInt32 nframes);
84 void setMinTime(OSG::Real32 minTime);
86 void addFromAtUp(OSG::Real32 fromx, OSG::Real32 fromy, OSG::Real32 fromz,
87 OSG::Real32 atx, OSG::Real32 aty, OSG::Real32 atz,
88 OSG::Real32 upx, OSG::Real32 upy, OSG::Real32 upz);
90 void addFromAtUp(OSG::Pnt3f from, OSG::Pnt3f at, OSG::Vec3f up);
92 // Define Path from VRML-Style Positon/Quaternion Strings
93 void addFromOri(OSG::Char8 *from, OSG::Char8 *ori);
95 // Make a rotational path around the whole model
96 void makeOrbit(OSG::Real32 upx = 0, OSG::Real32 upy = 1, OSG::Real32 upz =
97 0);
99 // Make a pirouette inside the model
100 void makePirouette(OSG::Real32 upx, OSG::Real32 upy, OSG::Real32 upz);
102 // add a FOV to animate
103 void addFov(OSG::Real32 fov);
105 // Run Test
107 void setVerbose(bool on);
109 void useRenderTraversal(bool on);
111 void setIgnoreGeometry(bool ignore);
113 void setStatistics(OSG::UInt16 level);
115 OSG::UInt16 getStatistics(void);
117 void run(void);
119 Image snapshot(OSG::UInt32 frame);
121 // Get Results
123 OSG::Real32 getFPS(void);
125 OSG::Real32 getTime(void);
127 OSG::UInt32 getNRenderedFrames(void);
129 OSG::Real64 getStatValue(OSG::Char8 *name, OSG::UInt32 frame);
132 /*========================= PROTECTED ===============================*/
133 protected:
135 // Expand the data to fit NFrames
136 void expandData(std::vector<OSG::Matrix>& views,
137 std::vector<OSG::Real32> &fovs);
139 void runLoop(std::vector<OSG::Matrix> &views,
140 std::vector<OSG::Real32> &fovs);
142 /*========================== PRIVATE ================================*/
143 private:
145 TestWindow *_win;
147 OSG::NodePtr _scene;
149 OSG::Real32 _near, _far;
150 std::vector<OSG::Pnt3f> _froms;
151 std::vector<OSG::Quaternion> _oris;
152 std::vector<OSG::Real32> _fovs;
154 OSG::Real32 _minTime;
155 OSG::UInt32 _nFrames;
156 bool _headlight;
157 OSG::UInt16 _statsLevel;
158 bool _verbose;
159 bool _useRenderTraversal;
161 // Results
162 OSG::Real32 _time;
163 OSG::UInt32 _nRenderedFrames;
165 std::vector<OSG::StatCollector> _stats;
168 #endif