File: example3.cpp

package info (click to toggle)
openscenegraph 1.2.0-2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 26,924 kB
  • ctags: 25,229
  • sloc: cpp: 239,326; ansic: 2,178; sh: 1,990; yacc: 548; perl: 237; makefile: 227; lex: 151
file content (49 lines) | stat: -rw-r--r-- 1,760 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
//C++ source file - Open Producer - Copyright (C) 2002 Don Burns
//Distributed under the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE (LGPL)
//as published by the Free Software Foundation.

// Simple example of use of Producer::RenderSurface
// The myGraphics class is a simple sample of how one would implement
// graphics drawing with Producer::RenderSurface

#include <Producer/Camera>
#include <Producer/KeyboardMouse>
#include <Producer/Trackball>

#include "MySceneHandler2"
#include "MyKeyboardMouseCallback"

int main()
{
    Producer::ref_ptr<Producer::Camera> camera = new Producer::Camera;
    Producer::ref_ptr<Producer::RenderSurface> rs = camera->getRenderSurface();
    rs->setWindowRectangle( 100, 100, 640, 480 );
    rs->setWindowName( "Producer Example using Camera" );

    Producer::ref_ptr<MySceneHandler> sh = new MySceneHandler;
    camera->setSceneHandler( sh.get() );

    Producer::ref_ptr<Producer::KeyboardMouse> kbm = new Producer::KeyboardMouse(rs.get());
    bool done = false;

    Producer::ref_ptr<MyKeyboardMouseCallback> kbmcb = new MyKeyboardMouseCallback(done);
    kbm->setCallback( kbmcb.get() );
    kbm->startThread();

    Producer::ref_ptr<Producer::Trackball> tb = new Producer::Trackball;
    tb->setOrientation( Producer::Trackball::Y_UP );

    while( !done )
    {
        tb->input( kbmcb->mx(), kbmcb->my(), kbmcb->mbutton() );
        sh->setMatrix( tb->getMatrix().ptr() );
        // Place the Camera into the world
        camera->setViewByLookat( 
                        0.0, 0.0, 8.0,   /// Position of the eye
                        0.0, 0.0, 0.0,   /// Point the eye is looking at
                        0.0, 1.0, 0.0 ); /// Up
        camera->frame();
    }
    return 0;
}