2010-03-02 21:22:31 +03:00
|
|
|
#ifndef STATE_H_
|
|
|
|
#define STATE_H_
|
|
|
|
|
2011-08-25 00:25:15 +04:00
|
|
|
#include <cstring>
|
2011-10-04 05:41:43 +04:00
|
|
|
#include "linalg.h"
|
2011-08-25 00:25:15 +04:00
|
|
|
|
2010-03-02 21:22:31 +03:00
|
|
|
class State
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
State(const class AbstractNode *parent)
|
2010-08-28 19:34:22 +04:00
|
|
|
: parentnode(parent), isprefix(false), ispostfix(false), numchildren(0) {
|
2011-10-04 05:41:43 +04:00
|
|
|
m = Transform3d::Identity();
|
2011-09-03 01:35:10 +04:00
|
|
|
for (int i=0;i<4;i++) this->c[i] = -1.0;
|
2010-08-28 19:34:22 +04:00
|
|
|
}
|
2010-03-02 21:22:31 +03:00
|
|
|
virtual ~State() {}
|
|
|
|
|
|
|
|
void setPrefix(bool on) { this->isprefix = on; }
|
|
|
|
void setPostfix(bool on) { this->ispostfix = on; }
|
|
|
|
void setNumChildren(unsigned int numc) { this->numchildren = numc; }
|
|
|
|
void setParent(const AbstractNode *parent) { this->parentnode = parent; }
|
2011-10-04 05:41:43 +04:00
|
|
|
void setMatrix(const Transform3d &m) { this->m = m; }
|
2011-09-03 01:35:10 +04:00
|
|
|
void setColor(const double c[4]) { memcpy(this->c, c, 4*sizeof(double)); }
|
2010-03-02 21:22:31 +03:00
|
|
|
|
|
|
|
bool isPrefix() const { return this->isprefix; }
|
|
|
|
bool isPostfix() const { return this->ispostfix; }
|
|
|
|
unsigned int numChildren() const { return this->numchildren; }
|
|
|
|
const AbstractNode *parent() const { return this->parentnode; }
|
2011-10-04 05:41:43 +04:00
|
|
|
const Transform3d &matrix() const { return this->m; }
|
2011-09-03 01:35:10 +04:00
|
|
|
const double *color() const { return this->c; }
|
2010-03-02 21:22:31 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
const AbstractNode * parentnode;
|
|
|
|
bool isprefix;
|
|
|
|
bool ispostfix;
|
|
|
|
unsigned int numchildren;
|
2010-08-28 19:34:22 +04:00
|
|
|
|
2011-09-03 01:35:10 +04:00
|
|
|
// Transformation matrix and color. FIXME: Generalize such state variables?
|
2011-10-04 05:41:43 +04:00
|
|
|
Transform3d m;
|
2011-09-03 01:35:10 +04:00
|
|
|
double c[4];
|
2010-03-02 21:22:31 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|