00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __PLSCENE_SCENENODEMODIFIER_MESHJOINT_H__
00024 #define __PLSCENE_SCENENODEMODIFIER_MESHJOINT_H__
00025 #pragma once
00026
00027
00028
00029
00030
00031 #include <PLMath/Vector3.h>
00032 #include "PLScene/Scene/SceneNodeModifiers/SNMMesh.h"
00033
00034
00035
00036
00037
00038 namespace PLRenderer {
00039 class Renderer;
00040 }
00041 namespace PLScene {
00042 class VisNode;
00043 }
00044
00045
00046
00047
00048
00049 namespace PLScene {
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 class SNMMeshJoint : public SNMMesh {
00064
00065
00066
00067
00068
00069 public:
00070
00071
00072
00073
00074 enum EFlags {
00075 UseFallbackRotation = 1<<2
00076 };
00077 pl_enum(EFlags)
00078 pl_enum_base(SNMMesh::EFlags)
00079 pl_enum_value(UseFallbackRotation, "Use fallback rotation if the target is 'out of rotation range'")
00080 pl_enum_end
00081
00082
00083
00084
00085
00086 pl_class(PLS_RTTI_EXPORT, SNMMeshJoint, "PLScene", PLScene::SNMMesh, "Mesh scene node joint modifier class")
00087
00088 pl_attribute(Name, PLCore::String, "", ReadWrite, GetSet, "Name of the joint to modify", "")
00089 pl_attribute(Rotation, PLMath::Vector3, PLMath::Vector3(0.0f, 0.0f, 0.0f), ReadWrite, GetSet, "Joint rotation in degree (joint space)", "")
00090 pl_attribute(RotationFrom, PLCore::String, "", ReadWrite, DirectValue, "Name of the scene node to take the rotation from (transformed into joint space)", "")
00091 pl_attribute(Min, PLMath::Vector3, PLMath::Vector3(0.0f, 0.0f, 0.0f), ReadWrite, GetSet, "Minimum joint rotation in in degree, if min = max -> no limitation, per component", "")
00092 pl_attribute(Max, PLMath::Vector3, PLMath::Vector3(0.0f, 0.0f, 0.0f), ReadWrite, GetSet, "Maximum joint rotation in in degree, if min = max -> no limitation, per component", "")
00093 pl_attribute(Speed, float, 5.0f, ReadWrite, DirectValue, "Rotation speed", "")
00094 pl_attribute(MaxDifference, float, 50.0f, ReadWrite, DirectValue, "Maximum rotation difference in degree, use it to void TO fast rotations", "")
00095 pl_attribute(FallbackRotation, PLMath::Vector3, PLMath::Vector3(0.0f, 0.0f, 0.0f), ReadWrite, DirectValue, "Rotation that is used if the target is 'out of rotation range'", "")
00096
00097 pl_attribute(Flags, pl_flag_type(EFlags), 0, ReadWrite, GetSet, "Flags", "")
00098
00099 pl_constructor_1(ParameterConstructor, SceneNode&, "Parameter constructor", "")
00100
00101 pl_slot_0(OnUpdate, "Called when the scene node modifier needs to be updated", "")
00102 pl_slot_2(OnDrawDebug, PLRenderer::Renderer&, const VisNode*, "Called on scene node debug draw, the used renderer as first parameter, the current visibility node of this scene node (can be a null pointer) as second parameter", "")
00103 pl_class_end
00104
00105
00106
00107
00108
00109 public:
00110 PLS_API PLCore::String GetName() const;
00111 PLS_API void SetName(const PLCore::String &sValue);
00112 PLS_API const PLMath::Vector3 &GetRotation() const;
00113 PLS_API void SetRotation(const PLMath::Vector3 &vValue);
00114 PLS_API const PLMath::Vector3 &GetMin() const;
00115 PLS_API void SetMin(const PLMath::Vector3 &vValue);
00116 PLS_API const PLMath::Vector3 &GetMax() const;
00117 PLS_API void SetMax(const PLMath::Vector3 &vValue);
00118
00119
00120
00121
00122
00123 public:
00124
00125
00126
00127
00128
00129
00130
00131 PLS_API SNMMeshJoint(SceneNode &cSceneNode);
00132
00133
00134
00135
00136
00137 PLS_API virtual ~SNMMeshJoint();
00138
00139
00140
00141
00142
00143 protected:
00144 PLS_API virtual void OnActivate(bool bActivate) override;
00145
00146
00147
00148
00149
00150 private:
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 bool GetTargetRotation(PLMath::Quaternion &qRot) const;
00162
00163
00164
00165
00166
00167 void UpdateJoint();
00168
00169
00170
00171
00172
00173 void OnUpdate();
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184 void OnDrawDebug(PLRenderer::Renderer &cRenderer, const VisNode *pVisNode);
00185
00186
00187
00188
00189
00190 private:
00191 PLCore::String m_sName;
00192 PLMath::Vector3 m_vRotation;
00193 PLMath::Vector3 m_vMin;
00194 PLMath::Vector3 m_vMax;
00195
00196
00197 };
00198
00199
00200
00201
00202
00203 }
00204
00205
00206 #endif // __PLSCENE_SCENENODEMODIFIER_MESHJOINT_H__