root/branches/Carsten_PtrWork2/Tools/osgBench/Test.h

Revision 213, 6.0 kB (checked in by dirk, 2 years ago)

Added simple benchmarking toolkit. Not for permanent use, just for now.

Line 
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 \*---------------------------------------------------------------------------*/
38
39 #ifndef _TEST_H_
40 #define _TEST_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
44
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"
52
53 class Test
54 {
55     /*==========================  PUBLIC  =================================*/
56   public:
57  
58     Test(void);
59    
60     ~Test();
61
62     // Set up scene characteristics
63     
64     void setScene(NodeBase &scene);
65    
66     void setScene(OSG::NodePtr scene);
67    
68     void setWindow(TestWindow &win);
69    
70     void setHeadlight(bool on);
71      
72     // set near and far, if any <= 0 use showAll() values
73     void setNearFar(OSG::Real32 n, OSG::Real32 f);
74    
75     // Setup Test Frames
76   
77     // clear all the animation data
78     void clear(void);
79    
80     // MinTime takes precedence, the path is repeated fully until the time is
81     // reached
82   
83     void setNFrames(OSG::UInt32 nframes);     
84     void setMinTime(OSG::Real32 minTime);
85    
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);
89    
90     void addFromAtUp(OSG::Pnt3f from, OSG::Pnt3f at, OSG::Vec3f up);
91    
92     // Define Path from VRML-Style Positon/Quaternion Strings
93     void addFromOri(OSG::Char8 *from, OSG::Char8 *ori);
94    
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);
98    
99     // Make a pirouette inside the model
100     void makePirouette(OSG::Real32 upx,   OSG::Real32 upy,   OSG::Real32 upz);
101
102     // add a FOV to animate
103     void addFov(OSG::Real32 fov); 
104    
105     // Run Test
106     
107     void setVerbose(bool on);
108    
109     void useRenderTraversal(bool on);
110    
111     void setIgnoreGeometry(bool ignore);
112    
113     void setStatistics(OSG::UInt16 level);
114    
115     OSG::UInt16 getStatistics(void);
116    
117     void run(void);
118    
119     Image snapshot(OSG::UInt32 frame);
120    
121     // Get Results
122     
123     OSG::Real32 getFPS(void);
124    
125     OSG::Real32 getTime(void);
126    
127     OSG::UInt32 getNRenderedFrames(void);
128    
129     OSG::Real64 getStatValue(OSG::Char8 *name, OSG::UInt32 frame);
130    
131          
132     /*=========================  PROTECTED  ===============================*/
133   protected:
134
135     // Expand the data to fit NFrames
136     void expandData(std::vector<OSG::Matrix>& views,
137                     std::vector<OSG::Real32> &fovs);
138
139     void runLoop(std::vector<OSG::Matrix> &views,
140                  std::vector<OSG::Real32> &fovs);
141
142     /*==========================  PRIVATE  ================================*/
143   private:
144    
145     TestWindow *_win;
146
147     OSG::NodePtr _scene;
148    
149     OSG::Real32 _near, _far;   
150     std::vector<OSG::Pnt3f> _froms;
151     std::vector<OSG::Quaternion> _oris;
152     std::vector<OSG::Real32> _fovs;
153    
154     OSG::Real32 _minTime;   
155     OSG::UInt32 _nFrames;
156     bool _headlight;
157     OSG::UInt16 _statsLevel;
158     bool _verbose;
159     bool _useRenderTraversal;
160    
161     // Results
162     OSG::Real32 _time;   
163     OSG::UInt32 _nRenderedFrames;
164
165     std::vector<OSG::StatCollector> _stats;
166 };
167
168 #endif
Note: See TracBrowser for help on using the browser.