source: OGRE/trunk/ogrenew/ReferenceApplication/ReferenceAppLayer/src/OgreRefAppJointSubtypes.cpp @ 657

Revision 657, 5.8 KB checked in by mattausch, 18 years ago (diff)

added ogre dependencies and patched ogre sources

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