root/OpenSceneGraph/trunk/examples/osgunittests/osgunittests.cpp @ 8399

Revision 8399, 22.5 kB (checked in by robert, 6 years ago)

Added unit test to smoke out a thread issue with using ofstream("/dev/null") inside
osg::notify()

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* OpenSceneGraph example, osgunittests.
2*
3*  Permission is hereby granted, free of charge, to any person obtaining a copy
4*  of this software and associated documentation files (the "Software"), to deal
5*  in the Software without restriction, including without limitation the rights
6*  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7*  copies of the Software, and to permit persons to whom the Software is
8*  furnished to do so, subject to the following conditions:
9*
10*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13*  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14*  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15*  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
16*  THE SOFTWARE.
17*/
18
19#include <osg/ArgumentParser>
20#include <osg/ApplicationUsage>
21
22#include <osg/Vec3>
23#include <osg/Matrix>
24#include <osg/Polytope>
25#include <osg/Timer>
26#include <osg/io_utils>
27
28#include <OpenThreads/Thread>
29
30#include "UnitTestFramework.h"
31#include "performance.h"
32
33#include <iostream>
34
35void testFrustum(double left,double right,double bottom,double top,double zNear,double zFar)
36{
37    osg::Matrix f;
38    f.makeFrustum(left,right,bottom,top,zNear,zFar);
39
40    double c_left=0;
41    double c_right=0;
42    double c_top=0;
43    double c_bottom=0;
44    double c_zNear=0;
45    double c_zFar=0;
46   
47   
48    std::cout << "testFrustum"<<f.getFrustum(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar)<<std::endl;
49    std::cout << "  left = "<<left<<" compute "<<c_left<<std::endl;
50    std::cout << "  right = "<<right<<" compute "<<c_right<<std::endl;
51
52    std::cout << "  bottom = "<<bottom<<" compute "<<c_bottom<<std::endl;
53    std::cout << "  top = "<<top<<" compute "<<c_top<<std::endl;
54
55    std::cout << "  zNear = "<<zNear<<" compute "<<c_zNear<<std::endl;
56    std::cout << "  zFar = "<<zFar<<" compute "<<c_zFar<<std::endl;
57   
58    std::cout << std::endl;
59}
60
61void testOrtho(double left,double right,double bottom,double top,double zNear,double zFar)
62{
63    osg::Matrix f;
64    f.makeOrtho(left,right,bottom,top,zNear,zFar);
65
66    double c_left=0;
67    double c_right=0;
68    double c_top=0;
69    double c_bottom=0;
70    double c_zNear=0;
71    double c_zFar=0;
72
73    std::cout << "testOrtho "<< f.getOrtho(c_left,c_right,c_bottom,c_top,c_zNear,c_zFar) << std::endl;
74    std::cout << "  left = "<<left<<" compute "<<c_left<<std::endl;
75    std::cout << "  right = "<<right<<" compute "<<c_right<<std::endl;
76
77    std::cout << "  bottom = "<<bottom<<" compute "<<c_bottom<<std::endl;
78    std::cout << "  top = "<<top<<" compute "<<c_top<<std::endl;
79
80    std::cout << "  zNear = "<<zNear<<" compute "<<c_zNear<<std::endl;
81    std::cout << "  zFar = "<<zFar<<" compute "<<c_zFar<<std::endl;
82   
83    std::cout << std::endl;
84}
85
86void testPerspective(double fovy,double aspect,double zNear,double zFar)
87{
88    osg::Matrix f;
89    f.makePerspective(fovy,aspect,zNear,zFar);
90
91    double c_fovy=0;
92    double c_aspect=0;
93    double c_zNear=0;
94    double c_zFar=0;
95
96    std::cout << "testPerspective "<< f.getPerspective(c_fovy,c_aspect,c_zNear,c_zFar) << std::endl;
97    std::cout << "  fovy = "<<fovy<<" compute "<<c_fovy<<std::endl;
98    std::cout << "  aspect = "<<aspect<<" compute "<<c_aspect<<std::endl;
99
100    std::cout << "  zNear = "<<zNear<<" compute "<<c_zNear<<std::endl;
101    std::cout << "  zFar = "<<zFar<<" compute "<<c_zFar<<std::endl;
102   
103    std::cout << std::endl;
104}
105
106void testLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up)
107{
108    osg::Matrix mv;
109    mv.makeLookAt(eye,center,up);
110   
111    osg::Vec3 c_eye,c_center,c_up;
112    mv.getLookAt(c_eye,c_center,c_up);
113   
114    std::cout << "testLookAt"<<std::endl;
115    std::cout << "  eye "<<eye<< " compute "<<c_eye<<std::endl;
116    std::cout << "  center "<<center<< " compute "<<c_center<<std::endl;
117    std::cout << "  up "<<up<< " compute "<<c_up<<std::endl;
118   
119    std::cout << std::endl;
120   
121}
122
123
124void testMatrixInvert(const osg::Matrix& matrix)
125{
126    //Invert it twice using the two inversion functions and view the results
127    osg::notify(osg::NOTICE)<<"testMatrixInvert("<<std::endl;
128    osg::notify(osg::NOTICE)<<matrix<<std::endl;
129    osg::notify(osg::NOTICE)<<")"<<std::endl;
130
131    osg::Matrix invM1_0;
132    invM1_0.invert(matrix);
133    osg::notify(osg::NOTICE)<<"Matrix::invert"<<std::endl;
134    osg::notify(osg::NOTICE)<<invM1_0<<std::endl;
135    osg::Matrix default_result = matrix*invM1_0;
136    osg::notify(osg::NOTICE)<<"matrix * invert="<<std::endl;
137    osg::notify(osg::NOTICE)<<default_result<<std::endl;;
138
139}
140
141void sizeOfTest()
142{
143  std::cout<<"sizeof(bool)=="<<sizeof(bool)<<std::endl;
144  std::cout<<"sizeof(char)=="<<sizeof(char)<<std::endl;
145  std::cout<<"sizeof(short)=="<<sizeof(short)<<std::endl;
146  std::cout<<"sizeof(short int)=="<<sizeof(short int)<<std::endl;
147  std::cout<<"sizeof(int)=="<<sizeof(int)<<std::endl;
148  std::cout<<"sizeof(long)=="<<sizeof(long)<<std::endl;
149  std::cout<<"sizeof(long int)=="<<sizeof(long int)<<std::endl;
150
151#if defined(_MSC_VER)
152  // long long isn't supported on VS6.0...
153  std::cout<<"sizeof(__int64)=="<<sizeof(__int64)<<std::endl;
154#else
155  std::cout<<"sizeof(long long)=="<<sizeof(long long)<<std::endl;
156#endif
157  std::cout<<"sizeof(float)=="<<sizeof(float)<<std::endl;
158  std::cout<<"sizeof(double)=="<<sizeof(double)<<std::endl;
159
160  std::cout<<"sizeof(std::istream::pos_type)=="<<sizeof(std::istream::pos_type)<<std::endl;
161  std::cout<<"sizeof(std::istream::off_type)=="<<sizeof(std::istream::off_type)<<std::endl;
162  std::cout<<"sizeof(OpenThreads::Mutex)=="<<sizeof(OpenThreads::Mutex)<<std::endl;
163
164  std::cout<<"sizeof(std::string)=="<<sizeof(std::string)<<std::endl;
165
166}
167
168/// Exercise the Matrix.getRotate function.
169/// Compare the output of:
170///  q1 * q2
171/// versus
172///  (mat(q1)*mat(q2)*scale).getRotate()
173/// for a range of rotations
174void testGetQuatFromMatrix(const osg::Vec3d& scale)
175{
176   
177    // Options
178   
179    // acceptable error range
180    double eps=1e-6;
181
182    // scale matrix
183    // To not test with scale, use 1,1,1
184    // Not sure if 0's or negative values are acceptable
185    osg::Matrixd scalemat;
186    scalemat.makeScale(scale);
187   
188    // range of rotations
189#if 1
190    // wide range
191    double rol1start = 0.0;
192    double rol1stop = 360.0;
193    double rol1step = 20.0;
194
195    double pit1start = 0.0;
196    double pit1stop = 90.0;
197    double pit1step = 20.0;
198
199    double yaw1start = 0.0;
200    double yaw1stop = 360.0;
201    double yaw1step = 20.0;
202
203    double rol2start = 0.0;
204    double rol2stop = 360.0;
205    double rol2step = 20.0;
206
207    double pit2start = 0.0;
208    double pit2stop = 90.0;
209    double pit2step = 20.0;
210
211    double yaw2start = 0.0;
212    double yaw2stop = 360.0;
213    double yaw2step = 20.0;
214#else
215    // focussed range
216    double rol1start = 0.0;
217    double rol1stop = 0.0;
218    double rol1step = 0.1;
219
220    double pit1start = 0.0;
221    double pit1stop = 5.0;
222    double pit1step = 5.0;
223
224    double yaw1start = 89.0;
225    double yaw1stop = 91.0;
226    double yaw1step = 0.1;
227
228    double rol2start = 0.0;
229    double rol2stop = 0.0;
230    double rol2step = 0.1;
231
232    double pit2start = 0.0;
233    double pit2stop = 0.0;
234    double pit2step = 0.1;
235
236    double yaw2start = 89.0;
237    double yaw2stop = 91.0;
238    double yaw2step = 0.1;
239#endif
240
241    std::cout << std::endl << "Starting testGetQuatFromMatrix, it can take a while ..." << std::endl;
242
243    osg::Timer_t tstart, tstop;
244    tstart = osg::Timer::instance()->tick();
245    int count=0;
246    for (double rol1 = rol1start; rol1 <= rol1stop; rol1 += rol1step) {
247        for (double pit1 = pit1start; pit1 <= pit1stop; pit1 += pit1step) {
248            for (double yaw1 = yaw1start; yaw1 <= yaw1stop; yaw1 += yaw1step) {
249                for (double rol2 = rol2start; rol2 <= rol2stop; rol2 += rol2step) {
250                    for (double pit2 = pit2start; pit2 <= pit2stop; pit2 += pit2step) {
251                        for (double yaw2 = yaw2start; yaw2 <= yaw2stop; yaw2 += yaw2step)
252                        {
253                            count++;
254                            // create two quats based on the roll, pitch and yaw values
255                            osg::Quat rot_quat1 =
256                            osg::Quat(osg::DegreesToRadians(rol1),osg::Vec3d(1,0,0),
257                                  osg::DegreesToRadians(pit1),osg::Vec3d(0,1,0),
258                                  osg::DegreesToRadians(yaw1),osg::Vec3d(0,0,1));
259
260                            osg::Quat rot_quat2 =
261                            osg::Quat(osg::DegreesToRadians(rol2),osg::Vec3d(1,0,0),
262                                  osg::DegreesToRadians(pit2),osg::Vec3d(0,1,0),
263                                  osg::DegreesToRadians(yaw2),osg::Vec3d(0,0,1));
264
265                            // create an output quat using quaternion math
266                            osg::Quat out_quat1;
267                            out_quat1 = rot_quat2 * rot_quat1;
268
269                            // create two matrices based on the input quats
270                            osg::Matrixd mat1,mat2;
271                            mat1.makeRotate(rot_quat1);
272                            mat2.makeRotate(rot_quat2);
273
274                            // create an output quat by matrix multiplication and getRotate
275                            osg::Matrixd out_mat;
276                            out_mat = mat2 * mat1;
277                            // add matrix scale for even more nastiness
278                            out_mat = out_mat * scalemat;
279                            osg::Quat out_quat2;
280                            out_quat2 = out_mat.getRotate();
281
282                            // If the quaternion W is <0, then we should reflect
283                            // to get it into the positive W.
284                            // Unfortunately, when W is very small (close to 0), the sign
285                            // does not really make sense because of precision problems
286                            // and the reflection might not work.
287                            if(out_quat1.w()<0) out_quat1 = out_quat1 * -1.0;
288                            if(out_quat2.w()<0) out_quat2 = out_quat2 * -1.0;
289
290                            // if the output quat length is not one
291                            // or if the components do not match,
292                            // something is amiss
293
294                            bool componentsOK = false;
295                            if ( ((fabs(out_quat1.x()-out_quat2.x())) < eps) &&
296                                 ((fabs(out_quat1.y()-out_quat2.y())) < eps) &&
297                                 ((fabs(out_quat1.z()-out_quat2.z())) < eps) &&
298                                 ((fabs(out_quat1.w()-out_quat2.w())) < eps) )
299                                    {
300                                componentsOK = true;
301                            }
302                            // We should also test for q = -q which is valid, so reflect
303                            // one quat.
304                            out_quat2 = out_quat2 * -1.0;
305                            if ( ((fabs(out_quat1.x()-out_quat2.x())) < eps) &&
306                                 ((fabs(out_quat1.y()-out_quat2.y())) < eps) &&
307                                 ((fabs(out_quat1.z()-out_quat2.z())) < eps) &&
308                                 ((fabs(out_quat1.w()-out_quat2.w())) < eps) )
309                            {
310                                componentsOK = true;
311                            }
312
313                            bool lengthOK = false;
314                            if (fabs(1.0-out_quat2.length()) < eps)
315                            {
316                                lengthOK = true;
317                            }
318
319                            if (!lengthOK || !componentsOK)
320                            {
321                                std::cout << "testGetQuatFromMatrix problem at: \n"
322                                      << " r1=" << rol1
323                                      << " p1=" << pit1
324                                      << " y1=" << yaw1
325                                      << " r2=" << rol2
326                                      << " p2=" << pit2
327                                      << " y2=" << yaw2 << "\n";
328                                std::cout << "quats:        " << out_quat1 << " length: " << out_quat1.length() << "\n";
329                                std::cout << "mats and get: " << out_quat2 << " length: " << out_quat2.length() << "\n\n";
330                            }
331                        }
332                    }
333                }
334            }
335        }
336    }
337    tstop = osg::Timer::instance()->tick();
338    double duration = osg::Timer::instance()->delta_s(tstart,tstop);
339    std::cout << "Time for testGetQuatFromMatrix with " << count << " iterations: " << duration << std::endl << std::endl;
340}
341
342void testQuatRotate(const osg::Vec3d& from, const osg::Vec3d& to)
343{
344    osg::Quat q_nicolas;
345    q_nicolas.makeRotate(from,to);
346   
347    osg::Quat q_original;
348    q_original.makeRotate_original(from,to);
349   
350    std::cout<<"osg::Quat::makeRotate("<<from<<", "<<to<<")"<<std::endl;
351    std::cout<<"  q_nicolas = "<<q_nicolas<<std::endl;
352    std::cout<<"  q_original = "<<q_original<<std::endl;
353    std::cout<<"  from * M4x4(q_nicolas) = "<<from * osg::Matrixd::rotate(q_nicolas)<<std::endl;
354    std::cout<<"  from * M4x4(q_original) = "<<from * osg::Matrixd::rotate(q_original)<<std::endl;
355}
356
357void testQuat(const osg::Vec3d& quat_scale)
358{
359    osg::Quat q1;
360    q1.makeRotate(osg::DegreesToRadians(30.0),0.0f,0.0f,1.0f);
361
362    osg::Quat q2;
363    q2.makeRotate(osg::DegreesToRadians(133.0),0.0f,1.0f,1.0f);
364
365    osg::Quat q1_2 = q1*q2;
366    osg::Quat q2_1 = q2*q1;
367
368    osg::Matrix m1 = osg::Matrix::rotate(q1);
369    osg::Matrix m2 = osg::Matrix::rotate(q2);
370   
371    osg::Matrix m1_2 = m1*m2;
372    osg::Matrix m2_1 = m2*m1;
373   
374    osg::Quat qm1_2;
375    qm1_2.set(m1_2);
376   
377    osg::Quat qm2_1;
378    qm2_1.set(m2_1);
379   
380    std::cout<<"q1*q2 = "<<q1_2<<std::endl;
381    std::cout<<"q2*q1 = "<<q2_1<<std::endl;
382    std::cout<<"m1*m2 = "<<qm1_2<<std::endl;
383    std::cout<<"m2*m1 = "<<qm2_1<<std::endl;
384
385
386    testQuatRotate(osg::Vec3d(1.0,0.0,0.0),osg::Vec3d(0.0,1.0,0.0));
387    testQuatRotate(osg::Vec3d(0.0,1.0,0.0),osg::Vec3d(1.0,0.0,0.0));
388    testQuatRotate(osg::Vec3d(0.0,0.0,1.0),osg::Vec3d(0.0,1.0,0.0));
389    testQuatRotate(osg::Vec3d(1.0,1.0,1.0),osg::Vec3d(1.0,0.0,0.0));
390    testQuatRotate(osg::Vec3d(1.0,0.0,0.0),osg::Vec3d(1.0,0.0,0.0));
391    testQuatRotate(osg::Vec3d(1.0,0.0,0.0),osg::Vec3d(-1.0,0.0,0.0));
392    testQuatRotate(osg::Vec3d(-1.0,0.0,0.0),osg::Vec3d(1.0,0.0,0.0));
393    testQuatRotate(osg::Vec3d(0.0,1.0,0.0),osg::Vec3d(0.0,-1.0,0.0));
394    testQuatRotate(osg::Vec3d(0.0,-1.0,0.0),osg::Vec3d(0.0,1.0,0.0));
395    testQuatRotate(osg::Vec3d(0.0,0.0,1.0),osg::Vec3d(0.0,0.0,-1.0));
396    testQuatRotate(osg::Vec3d(0.0,0.0,-1.0),osg::Vec3d(0.0,0.0,1.0));
397
398    // Test a range of rotations
399    testGetQuatFromMatrix(quat_scale);
400
401    // This is a specific test case for a matrix containing scale and rotation
402    osg::Matrix matrix(0.5, 0.0, 0.0, 0.0,
403                       0.0, 0.5, 0.0, 0.0,
404                       0.0, 0.0, 0.5, 0.0,
405                       1.0, 1.0, 1.0, 1.0);
406                       
407    osg::Quat quat;
408    matrix.get(quat);
409   
410    osg::notify(osg::NOTICE)<<"Matrix = "<<matrix<<"rotation = "<<quat<<", expected quat = (0,0,0,1)"<<std::endl;
411}
412
413class MyThread : public OpenThreads::Thread {
414public:
415    void run(void) { }
416};
417
418class NotifyThread : public OpenThreads::Thread {
419public:
420
421    NotifyThread(osg::NotifySeverity level, const std::string& message):
422    _done(false),
423    _level(level),
424    _message(message) {}
425
426    ~NotifyThread()
427    {
428        _done = true;
429        while(isRunning())
430        {
431            OpenThreads::Thread::YieldCurrentThread();
432        }
433    }
434
435    void run(void)
436    {
437        std::cout << "Entering thread ..." <<_message<< std::endl;
438
439        unsigned int count=0;
440
441        while(!_done)
442        {
443            ++count;
444#if 1
445            osg::notify(_level)<<_message<<this<<"\n";
446#else
447            osg::notify(_level)<<_message<<this<<std::endl;
448#endif
449        }
450
451        std::cout << "Leaving thread ..." <<_message<< " count="<<count<<std::endl;
452    }
453
454    bool                  _done;
455    osg::NotifySeverity   _level;
456    std::string           _message;
457 
458};
459
460void testThreadInitAndExit()
461{
462    std::cout<<"******   Running thread start and delete test   ****** "<<std::endl;
463
464    {
465        MyThread thread;
466        thread.startThread();
467    }
468   
469    // add a sleep to allow the thread start to fall over it its going to.
470    OpenThreads::Thread::microSleep(500000);
471   
472    std::cout<<"pass    thread start and delete test"<<std::endl<<std::endl;
473
474
475    std::cout<<"******   Running notify thread test   ****** "<<std::endl;
476
477    {
478        NotifyThread thread1(osg::INFO,"thread one:");
479        NotifyThread thread2(osg::INFO,"thread two:");
480        NotifyThread thread3(osg::INFO,"thread three:");
481        NotifyThread thread4(osg::INFO,"thread four:");
482        thread1.startThread();
483        thread2.startThread();
484        thread3.startThread();
485        thread4.startThread();
486
487        // add a sleep to allow the thread start to fall over it its going to.
488        OpenThreads::Thread::microSleep(5000000);
489    }
490
491    std::cout<<"pass    noitfy thread test."<<std::endl<<std::endl;
492}
493
494void testPolytope()
495{
496    osg::Polytope pt;
497    pt.setToBoundingBox(osg::BoundingBox(-1000, -1000, -1000, 1000, 1000, 1000));
498    bool bContains = pt.contains(osg::Vec3(0, 0, 0));
499    if (bContains)
500    {
501        std::cout<<"Polytope pt.contains(osg::Vec3(0, 0, 0)) has succeeded."<<std::endl;
502    }
503    else
504    {
505        std::cout<<"Polytope pt.contains(osg::Vec3(0, 0, 0)) has failed."<<std::endl;
506    }
507
508}
509
510
511int main( int argc, char** argv )
512{
513    osg::ArgumentParser arguments(&argc,argv);
514
515    // set up the usage document, in case we need to print out how to use this program.
516    arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the example which runs units tests.");
517    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options]");
518    arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
519    arguments.getApplicationUsage()->addCommandLineOption("qt","Display qualified tests.");
520    arguments.getApplicationUsage()->addCommandLineOption("quat","Display extended quaternion tests.");
521    arguments.getApplicationUsage()->addCommandLineOption("quat_scaled sx sy sz","Display extended quaternion tests of pre scaled matrix.");
522    arguments.getApplicationUsage()->addCommandLineOption("sizeof","Display sizeof tests.");
523    arguments.getApplicationUsage()->addCommandLineOption("matrix","Display qualified tests.");
524    arguments.getApplicationUsage()->addCommandLineOption("performance","Display qualified tests.");
525 
526
527    if (arguments.argc()<=1)
528    {
529        arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);
530        return 1;
531    }
532
533    bool printQualifiedTest = false;
534    while (arguments.read("qt")) printQualifiedTest = true;
535
536    bool printMatrixTest = false;
537    while (arguments.read("matrix")) printMatrixTest = true;
538
539    bool printSizeOfTest = false;
540    while (arguments.read("sizeof")) printSizeOfTest = true;
541
542    bool printQuatTest = false;
543    while (arguments.read("quat")) printQuatTest = true;
544
545    bool printPolytopeTest = false;
546    while (arguments.read("polytope")) printPolytopeTest = true;
547   
548    bool doTestThreadInitAndExit = false;
549    while (arguments.read("thread")) doTestThreadInitAndExit = true;
550
551    osg::Vec3d quat_scale(1.0,1.0,1.0);
552    while (arguments.read("quat_scaled", quat_scale.x(), quat_scale.y(), quat_scale.z() )) printQuatTest = true;
553
554    bool performanceTest = false;
555    while (arguments.read("p") || arguments.read("performance")) performanceTest = true;
556
557    // if user request help write it out to cout.
558    if (arguments.read("-h") || arguments.read("--help"))
559    {
560        std::cout<<arguments.getApplicationUsage()->getCommandLineUsage()<<std::endl;
561        arguments.getApplicationUsage()->write(std::cout,arguments.getApplicationUsage()->getCommandLineOptions());
562        return 1;
563    }
564
565    // any option left unread are converted into errors to write out later.
566    arguments.reportRemainingOptionsAsUnrecognized();
567
568    // report any errors if they have occurred when parsing the program arguments.
569    if (arguments.errors())
570    {
571        arguments.writeErrorMessages(std::cout);
572        return 1;
573    }
574   
575    if (printQuatTest)
576    {
577        testQuat(quat_scale);
578    }
579
580    if (printMatrixTest)
581    {
582        std::cout<<"******   Running matrix tests   ******"<<std::endl;
583
584        testFrustum(-1,1,-1,1,1,1000);
585        testFrustum(0,1,1,2,2.5,100000);
586
587        testOrtho(0,1,1,2,2.1,1000);
588        testOrtho(-1,10,1,20,2.5,100000);
589
590        testPerspective(20,1,1,1000);
591        testPerspective(90,2,1,1000);
592
593        testLookAt(osg::Vec3(10.0,4.0,2.0),osg::Vec3(10.0,4.0,2.0)+osg::Vec3(0.0,1.0,0.0),osg::Vec3(0.0,0.0,1.0));
594        testLookAt(osg::Vec3(10.0,4.0,2.0),osg::Vec3(10.0,4.0,2.0)+osg::Vec3(1.0,1.0,0.0),osg::Vec3(0.0,0.0,1.0));
595       
596        testMatrixInvert(osg::Matrix(0.999848,  -0.002700,  0.017242, -0.1715,
597                                     0,         0.987960,   0.154710,  0.207295,
598                                     -0.017452, -0.154687,  0.987809, -0.98239,
599                                     0,         0,          0,         1));
600
601        testMatrixInvert(osg::Matrix(0.999848,  -0.002700,  0.017242,   0.0,
602                                     0.0,        0.987960,   0.154710,   0.0,
603                                     -0.017452, -0.154687,  0.987809,   0.0,
604                                     -0.1715,    0.207295,  -0.98239,   1.0));
605
606    }
607   
608    if (printSizeOfTest)
609    {
610        std::cout<<"**** sizeof() tests  ******"<<std::endl;
611       
612        sizeOfTest();
613
614        std::cout<<std::endl;
615    }
616
617
618    if (performanceTest)
619    {
620        std::cout<<"**** performance tests  ******"<<std::endl;
621       
622        runPerformanceTests();
623    }
624
625    if (printPolytopeTest)
626    {
627        testPolytope();
628    }
629
630
631    if (printQualifiedTest)
632    {
633         std::cout<<"*****   Qualified Tests  ******"<<std::endl;
634
635         osgUtx::QualifiedTestPrinter printer;
636         osgUtx::TestGraph::instance().root()->accept( printer );   
637         std::cout<<std::endl;
638    }
639
640    if (doTestThreadInitAndExit)
641    {
642        testThreadInitAndExit();
643    }
644
645    std::cout<<"******   Running tests   ******"<<std::endl;
646
647    // Global Data or Context
648    osgUtx::TestContext ctx;
649    osgUtx::TestRunner runner( ctx );
650    runner.specify("root");
651
652    osgUtx::TestGraph::instance().root()->accept( runner );
653
654    return 0;
655}
Note: See TracBrowser for help on using the browser.