Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ReferenceApplication/ReferenceAppLayer/include/OgreRefAppJoint.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 4.9 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __REFAPP_JOINT_H__
30#define __REFAPP_JOINT_H__
31
32#include "OgreRefAppPrerequisites.h"
33
34namespace OgreRefApp {
35
36    /** Represents a linkage between application objects or between them and the world, enforcing
37        certain constraints.
38    @remarks
39        Joints can be used to link application objects together, or to link them to a static point
40        in the world according to certain constraints. You should create joints using
41        World::createJoint. You should then set certain global options, like it's world
42        anchor position, before attaching it to application objects. You application objects
43        should already be positioned how you would like relative to the joint anchor, since once
44        they are attached, they will be constrained by it.
45    */
46    class _OgreRefAppExport Joint
47    {
48    public:
49        /// The type of joint
50        enum JointType {
51            /// Ball & socket joint, has 3 degrees of freedom
52            JT_BALL,
53            /// Sliding joint, 1 degree of freedom (in-out)
54            JT_SLIDER,
55            /// Hinge joint, 1 degree of freedom
56            JT_HINGE,
57            /// Universal joint, like a double-hinge, 2 degrees of freedom
58            JT_UNIVERSAL,
59            /// 2 hinges in series, like the axel of a car
60            JT_HINGE2
61        };
62        /** Constructor, however you should use World::createJoint(type, obj1, obj2). */
63        Joint(JointType jtype);
64        virtual ~Joint() { if (mOdeJoint) delete mOdeJoint; }
65
66
67        /** Returns the type of this joint. */
68        JointType getType(void);
69        /** Set the anchor point of this joint.
70        @remarks
71            Sets the location, in world space, of the anchor point of this joint, which is usually
72            the hinge point or just the origin of joint. It has no meaning for JT_SLIDER and thus
73            you don't need to call it for that.
74        */
75        virtual void setAnchorPosition(const Vector3& point) = 0;
76
77        /** Gets the anchor position of this joint. */
78        virtual const Vector3& getAnchorPosition(void);
79
80
81        /** Gets the attached objects, a NULL means no object ie a static attachment. */
82        virtual const std::pair<ApplicationObject*, ApplicationObject*>& getAttachments(void);
83
84        /** Sets the axes for this joint.
85        @remarks
86            The meaning of axes for a joint depends on it's type:
87            <ul>
88            <li>For JT_BALL, it has no meaning and you don't need to call it.</li>
89            <li>For JT_SLIDER, only one is applicable and it's the axis along which the slide occurs. </li>
90            <li>For JT_HINGE, only one is applicable and it's the hinge axis. </li>
91            <li>For JT_UNIVERSAL, and JT_HINGE2 it's the 2 hinge axes.</li>
92            </ul>
93        */
94        virtual void setAxes(const Vector3& primaryAxis, const Vector3& secondaryAxis = Vector3::ZERO) = 0;
95
96        /** Gets the axes of this joint. */
97        virtual const std::pair<Vector3, Vector3>& getAxes(void);
98
99    protected:
100
101        /** Sets the objects attached to this joint.
102        @remarks
103            It appears that this has to be set before other joint params like
104            anchor etc, otherwise the joint does not behave. Therefore it is internal
105            and is called during construction.
106        */
107        void setAttachments(ApplicationObject* obj1, ApplicationObject* obj2);
108
109        JointType mType;
110        Vector3 mAnchor;
111        std::pair<ApplicationObject*, ApplicationObject*> mAttachedObjects;
112        std::pair<Vector3, Vector3> mAxes;
113
114        // ODE object
115        dJoint* mOdeJoint;
116
117
118
119
120
121
122
123
124
125    };
126}
127
128#endif
Note: See TracBrowser for help on using the repository browser.