Skip to content
Snippets Groups Projects
szgPartiview.h 3.55 KiB
Newer Older
#ifndef _SZGPARTIVIEW_H
#define _SZGPARTIVIEW_H

/*
 * Main scene data for szgPartiview.
 */

#include "arMasterSlaveFramework.h"

#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 &center_; }
  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 );
};

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();

  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

  /* 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;

  virtual bool onStart( arSZGClient& SZGClient );
  virtual bool 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 );

};

extern struct Ppszg  ppszg;

extern void ppszg_refresh( struct stuff * );
extern int specks_commandfmt( struct stuff **, const char *fmt, ... );

#endif /*_SZGPARTIVIEW_H*/