1 /*
2  * NodeHAnimJoint.h
3  *
4  * Copyright (C) 1999 Stephen F. White, 2008 J. "MUFTI" Scheurich
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program (see the file "COPYING" for details); if
18  * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19  * Cambridge, MA 02139, USA.
20  */
21 
22 #pragma once
23 
24 #include "Node.h"
25 #include "ProtoMacros.h"
26 #include "Proto.h"
27 #include "SFMFTypes.h"
28 #include "NodeTransform.h"
29 #include "Array.h"
30 
31 class JointAndParent;
32 
33 class ProtoHAnimJoint : public ProtoTransform {
34 public:
35                     ProtoHAnimJoint(Scene *scene);
36     virtual Node   *create(Scene *scene);
37 
getType()38     virtual int     getType() const { return X3D_HANIM_JOINT; }
getNodeClass()39     virtual int     getNodeClass() const { return HANIM_CHILD_NODE; }
40 
isX3dInternalProto(void)41     virtual bool    isX3dInternalProto(void) { return true; }
42 
isDeclaredInRwd_h()43     virtual bool    isDeclaredInRwd_h() { return true; }
44 
45     FieldIndex displacers;
46     FieldIndex limitOrientation;
47     FieldIndex llimit;
48     FieldIndex name;
49     FieldIndex skinCoordIndex;
50     FieldIndex skinCoordWeight;
51     FieldIndex stiffness;
52     FieldIndex ulimit;
53 };
54 
55 class NodeHAnimJoint : public NodeTransform {
56 public:
57                     NodeHAnimJoint(Scene *scene, Proto *proto);
58 
59     virtual const char* getComponentName(void) const;
60     virtual int         getComponentLevel(void) const;
getX3dVersion(void)61     virtual int         getX3dVersion(void) const { return 0; }
copy()62     virtual Node   *copy() const { return new NodeHAnimJoint(*this); }
63 
64     void            setField(int field, FieldValue *value, int cf = -1);
65 
showFields()66     virtual bool    showFields() { return true; }
67     virtual void    applyJoint(int skinNum, MyMesh *mesh,
68                                MFVec3f *origVertices, Node *parent);
69     void            getJoints(MyArray<JointAndParent *> *outputJoints,
70                                       Node* parent);
71     void            accountJointMatrix(Node *parent);
72     virtual void    drawHandles(void);
73     virtual void    drawJointHandles(float scale, Node *parent, Node *that);
updateHandles()74     virtual void    updateHandles()
75                         { if (hasParent()) getParent()->updateHandles(); }
getMatrixDirty(void)76     virtual bool    getMatrixDirty(void) { return m_matrixDirty; }
77 
78     virtual void    setHandle(int handle, const Vec3f &v);
79 
getJointMatrix(Matrix & matrix)80     void            getJointMatrix(Matrix &matrix)
81                         { m_jointMatrix.copyTo(matrix); }
82 
83     fieldMacros(MFNode,     displacers,       ProtoHAnimJoint)
84     fieldMacros(SFRotation, limitOrientation, ProtoHAnimJoint)
85     fieldMacros(MFFloat,    llimit,           ProtoHAnimJoint)
86     fieldMacros(SFString,   name,             ProtoHAnimJoint)
87     fieldMacros(MFInt32,    skinCoordIndex,   ProtoHAnimJoint)
88     fieldMacros(MFFloat,    skinCoordWeight,  ProtoHAnimJoint)
89     fieldMacros(MFFloat,    stiffness,        ProtoHAnimJoint)
90     fieldMacros(MFFloat,    ulimit,           ProtoHAnimJoint)
91 protected:
92     Matrix m_jointMatrix;
93     NodeCoordinate *m_coord;
94 };
95 
96 class JointAndParent {
97 public:
98     NodeHAnimJoint *joint;
99     Node           *parent;
100 };
101 
102 
103