1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of the OGRE Reference Application, a layer built |
---|
4 | on top of OGRE(Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org/ |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #include "OgreRefAppJointSubtypes.h" |
---|
30 | #include "OgreRefAppWorld.h" |
---|
31 | |
---|
32 | namespace OgreRefApp { |
---|
33 | |
---|
34 | //------------------------------------------------------------------------- |
---|
35 | BallJoint::BallJoint(Joint::JointType jtype, ApplicationObject* obj1, ApplicationObject* obj2) |
---|
36 | : Joint(jtype) |
---|
37 | { |
---|
38 | mOdeJoint = new dBallJoint(World::getSingleton().getOdeWorld()->id()); |
---|
39 | setAttachments(obj1, obj2); |
---|
40 | } |
---|
41 | //------------------------------------------------------------------------- |
---|
42 | void BallJoint::setAnchorPosition(const Vector3& point) |
---|
43 | { |
---|
44 | dBallJoint* ballJoint = static_cast<dBallJoint*>(mOdeJoint); |
---|
45 | |
---|
46 | ballJoint->setAnchor(point.x, point.y, point.z); |
---|
47 | mAnchor = point; |
---|
48 | } |
---|
49 | //------------------------------------------------------------------------- |
---|
50 | //------------------------------------------------------------------------- |
---|
51 | SliderJoint::SliderJoint(Joint::JointType jtype, ApplicationObject* obj1, ApplicationObject* obj2) |
---|
52 | : Joint(jtype) |
---|
53 | { |
---|
54 | mOdeJoint = new dSliderJoint(World::getSingleton().getOdeWorld()->id()); |
---|
55 | setAttachments(obj1, obj2); |
---|
56 | |
---|
57 | } |
---|
58 | //------------------------------------------------------------------------- |
---|
59 | void SliderJoint::setAxes(const Vector3& a1, const Vector3& na) |
---|
60 | { |
---|
61 | dSliderJoint* sliderJoint = static_cast<dSliderJoint*>(mOdeJoint); |
---|
62 | sliderJoint->setAxis(a1.x, a1.y, a1.z); |
---|
63 | mAxes.first = a1; |
---|
64 | |
---|
65 | } |
---|
66 | //------------------------------------------------------------------------- |
---|
67 | //------------------------------------------------------------------------- |
---|
68 | HingeJoint::HingeJoint(Joint::JointType jtype, ApplicationObject* obj1, ApplicationObject* obj2) |
---|
69 | : Joint(jtype) |
---|
70 | { |
---|
71 | mOdeJoint = new dHingeJoint(World::getSingleton().getOdeWorld()->id()); |
---|
72 | setAttachments(obj1, obj2); |
---|
73 | } |
---|
74 | //------------------------------------------------------------------------- |
---|
75 | void HingeJoint::setAnchorPosition(const Vector3& point) |
---|
76 | { |
---|
77 | dHingeJoint* hinge = static_cast<dHingeJoint*>(mOdeJoint); |
---|
78 | hinge->setAnchor(point.x, point.y, point.z); |
---|
79 | mAnchor = point; |
---|
80 | } |
---|
81 | //------------------------------------------------------------------------- |
---|
82 | void HingeJoint::setAxes(const Vector3& a1, const Vector3& na) |
---|
83 | { |
---|
84 | dHingeJoint* hinge = static_cast<dHingeJoint*>(mOdeJoint); |
---|
85 | hinge->setAxis(a1.x, a1.y, a1.z); |
---|
86 | mAxes.first = a1; |
---|
87 | } |
---|
88 | //------------------------------------------------------------------------- |
---|
89 | //------------------------------------------------------------------------- |
---|
90 | UniversalJoint::UniversalJoint(Joint::JointType jtype, ApplicationObject* obj1, ApplicationObject* obj2) |
---|
91 | : Joint(jtype) |
---|
92 | { |
---|
93 | mOdeJoint = new dUniversalJoint(World::getSingleton().getOdeWorld()->id()); |
---|
94 | setAttachments(obj1, obj2); |
---|
95 | } |
---|
96 | //------------------------------------------------------------------------- |
---|
97 | void UniversalJoint::setAnchorPosition(const Vector3& point) |
---|
98 | { |
---|
99 | dUniversalJoint* univ = static_cast<dUniversalJoint*>(mOdeJoint); |
---|
100 | univ->setAnchor(point.x, point.y, point.z); |
---|
101 | mAnchor = point; |
---|
102 | } |
---|
103 | //------------------------------------------------------------------------- |
---|
104 | void UniversalJoint::setAxes(const Vector3& a1, const Vector3& a2) |
---|
105 | { |
---|
106 | dUniversalJoint* univ = static_cast<dUniversalJoint*>(mOdeJoint); |
---|
107 | univ->setAxis1(a1.x, a1.y, a1.z); |
---|
108 | univ->setAxis2(a2.x, a2.y, a2.z); |
---|
109 | mAxes.first = a1; |
---|
110 | mAxes.second = a2; |
---|
111 | } |
---|
112 | //------------------------------------------------------------------------- |
---|
113 | //------------------------------------------------------------------------- |
---|
114 | Hinge2Joint::Hinge2Joint(Joint::JointType jtype, ApplicationObject* obj1, ApplicationObject* obj2) |
---|
115 | : Joint(jtype) |
---|
116 | { |
---|
117 | mOdeJoint = new dHinge2Joint(World::getSingleton().getOdeWorld()->id()); |
---|
118 | setAttachments(obj1, obj2); |
---|
119 | } |
---|
120 | //------------------------------------------------------------------------- |
---|
121 | void Hinge2Joint::setAnchorPosition(const Vector3& point) |
---|
122 | { |
---|
123 | dHinge2Joint* hinge = static_cast<dHinge2Joint*>(mOdeJoint); |
---|
124 | hinge->setAnchor(point.x, point.y, point.z); |
---|
125 | mAnchor = point; |
---|
126 | } |
---|
127 | //------------------------------------------------------------------------- |
---|
128 | void Hinge2Joint::setAxes(const Vector3& a1, const Vector3& a2) |
---|
129 | { |
---|
130 | dHinge2Joint* hinge = static_cast<dHinge2Joint*>(mOdeJoint); |
---|
131 | hinge->setAxis1(a1.x, a1.y, a1.z); |
---|
132 | hinge->setAxis2(a2.x, a2.y, a2.z); |
---|
133 | mAxes.first = a1; |
---|
134 | mAxes.second = a2; |
---|
135 | } |
---|
136 | |
---|
137 | |
---|
138 | |
---|
139 | } |
---|