Newer
Older
#ifndef _SZGPARTIVIEW_H
#define _SZGPARTIVIEW_H
/*
* Main scene data for szgPartiview.
*/
#include "arPrecompiled.h"
#include "arMasterSlaveFramework.h"
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifdef WIN32
# include "winjunk.h"
#endif
#include "specks.h"
#include "partiviewc.h"
#include <vector>
typedef struct subcam {
char name[8];
float azim, elev, roll;
float nleft, right, ndown, up;
} Subcam;
struct PvObject {
struct stuff *st_;
Matrix To2w_;
char *name_;
int id_; // id in parent's list of objects
int parent_; /* 0=world, GV_ID_CAMERA=attach-to-camera */
PvObject();
PvObject( const char *name, int id );
void init( const char *name, int id );
Matrix *To2w() { return &To2w_; }
void To2w( const Matrix *T ) { To2w_ = *T; }
int parent() const { return parent_; } // 0 if ordinary, -1 if parent is camera
void parent(int p) { parent_ = p; }
int id() const { return id_; }
void draw( bool inpick = false );
struct stuff *objstuff() { return st_; }
};
struct PvScene {
Point center_;
float censize_;
std::vector <class PvObject> objs_;
PvScene() {
center_.x[0] = center_.x[1] = center_.x[2] = 0;
censize_ = 1.0;
}
const Point *center() const { return ¢er_; }
void center( const Point *p ) { center_ = *p; }
float censize() const { return censize_; }
void censize( float s ) { censize_ = s; }
PvObject *obj( int id ) { return ((unsigned int)id < objs_.size()) ? &objs_[id] : 0; }
struct stuff *objstuff( int id ) {
PvObject *ob = obj(id);
return ob ? ob->objstuff() : 0;
}
int nobjs() const { return objs_.size(); }
PvObject *addobj( const char *name, int id = -1 );
void draw( bool inpick = false );
};
// For queueing commands for network transmission
typedef enum { CMD_NONE=0, CMD_DATA=1, CMD_CONTROL=2 } CmdType;
class PpCmd {
public:
CmdType type;
int argc;
char **argv;
PpCmd() { type = CMD_DATA; argc = -1; argv = 0; }
PpCmd( CmdType, int argc, char **argv );
~PpCmd();
int frozenLen() const; // length of serialized data including terminating 000
char* freezeInto( char *buf = 0, int size = 0, int *offsetp = 0 ) const;
int thawFrom( const char *buf, int &offset );
struct Ppszg : public arMasterSlaveFramework {
PvScene *scene;
// XXX Could have a draw callback kinda like
// XXX void draw() {
// glClearColor( bgcolor.x[0],bgcolor.x[1],bgcolor.x[2], 1 );
// glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT ); // or however you do background color in szg
// scene->draw();
// }
struct stuff *st; // ref for currently selected Object
Point bgcolor;
float clipnear_, clipfar_;
float focallen_;
Ppszg();
~Ppszg();
const Matrix *Tc2w() const;
void Tc2w( const Matrix * );
void nearclip( float s ) { clipnear_ = s; }
void farclip( float s ) { clipfar_ = s; }
float nearclip() const { return clipnear_; }
float farclip() const { return clipfar_; }
void focallen(float dist) { focallen_ = dist; }
float focallen() const { return focallen_; }
char *snapfmt;
int snapfno;
float pickrange;
float home[6]; //marx marx version 0.7.03 home is equivalent to a jump to a named point of view
SClock *clk; // master data clock
vector <PpCmd> cmdqueue;
/* camera animation stuff */
struct wfpath path;
int playing;
int playevery;
int playidling;
float playspeed;
int framebase;
float playtimebase;
int playloop;
double timebasetime;
std::vector <Subcam> sc;
int subcam;
void queueCmd( bool datacommand, int argc, char *argv[] );
// implementing arMasterSlaveFramework methods:
virtual bool onStart( arSZGClient& SZGClient );
virtual void onWindowStartGL( arGUIWindowInfo * );
virtual void onPreExchange( void ); // called on master only
virtual void onPostExchange( void ); // called on master + slaves
virtual void onWindowInit( void ); // clear to background... ar_defaultWindowInitCallback()
virtual void onDraw( arGraphicsWindow& win, arViewport& vp );
virtual void onDisconnectDraw( void );
virtual void onCleanup( void );
virtual void onUserMessage( const string& messageBody );