1 | /*************************************************************************** |
---|
2 | |
---|
3 | This source file is part of OGREBULLET |
---|
4 | (Object-oriented Graphics Rendering Engine Bullet Wrapper) |
---|
5 | For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10 |
---|
6 | |
---|
7 | Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes) |
---|
8 | |
---|
9 | |
---|
10 | |
---|
11 | This program is free software; you can redistribute it and/or modify it under |
---|
12 | the terms of the GPL General Public License with runtime exception as published by the Free Software |
---|
13 | Foundation; either version 2 of the License, or (at your option) any later |
---|
14 | version. |
---|
15 | |
---|
16 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
18 | FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GPL General Public License with runtime exception along with |
---|
21 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
22 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
23 | http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
24 | ----------------------------------------------------------------------------- |
---|
25 | */ |
---|
26 | |
---|
27 | #include "OgreBulletCollisions.h" |
---|
28 | |
---|
29 | #include "OgreBulletCollisionsShape.h" |
---|
30 | #include "Debug/OgreBulletCollisionsDebugShape.h" |
---|
31 | #include "Utils/OgreBulletConverter.h" |
---|
32 | |
---|
33 | using namespace OgreBulletCollisions; |
---|
34 | using namespace Ogre; |
---|
35 | |
---|
36 | //------------------------------------------------------------------------------------------------ |
---|
37 | DebugCollisionShape::DebugCollisionShape(CollisionShape *shape, DebugCollisionShape::Mode mode) |
---|
38 | { |
---|
39 | setStatemode(mode); |
---|
40 | // try to draw debug wire frame of the shape |
---|
41 | mIsVisual = shape->drawWireFrame (this); |
---|
42 | |
---|
43 | // if no success (not possible or not implemented |
---|
44 | // does not draw, hence saving a segfault |
---|
45 | if (mIsVisual) |
---|
46 | DebugLines::draw (); |
---|
47 | } |
---|
48 | //------------------------------------------------------------------------------------------------ |
---|
49 | void DebugCollisionShape::setStatemode(DebugCollisionShape::Mode mode) |
---|
50 | { |
---|
51 | if (mode != mStatemode) |
---|
52 | { |
---|
53 | mStatemode = mode; |
---|
54 | switch(mStatemode) |
---|
55 | { |
---|
56 | case DebugCollisionShape::Mode_Enabled: |
---|
57 | setMaterial("OgreBulletCollisionsDebugLines/Enabled"); |
---|
58 | break; |
---|
59 | |
---|
60 | case DebugCollisionShape::Mode_Disabled: |
---|
61 | setMaterial("OgreBulletCollisionsDebugLines/Disabled"); |
---|
62 | |
---|
63 | break; |
---|
64 | |
---|
65 | case DebugCollisionShape::Mode_Static: |
---|
66 | setMaterial("OgreBulletCollisionsDebugLines/Static"); |
---|
67 | break; |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | //------------------------------------------------------------------------------------------------ |
---|
72 | DebugCollisionShape::~DebugCollisionShape() |
---|
73 | { |
---|
74 | } |
---|
75 | //------------------------------------------------------------------------------------------------ |
---|
76 | bool DebugCollisionShape::getIsVisual() const |
---|
77 | { |
---|
78 | return mIsVisual; |
---|
79 | } |
---|
80 | //------------------------------------------------------------------------------------------------ |
---|
81 | void DebugCollisionShape::setIsVisual( bool val ) |
---|
82 | { |
---|
83 | mIsVisual = val; |
---|
84 | } |
---|
85 | //------------------------------------------------------------------------------------------------ |
---|
86 | RayDebugShape::RayDebugShape(const Ogre::Vector3& start, |
---|
87 | const Ogre::Vector3& direction, |
---|
88 | const Ogre::Real length) |
---|
89 | { |
---|
90 | const Ogre::Vector3 end (start + (direction.normalisedCopy() * length)); |
---|
91 | addLine(start, end); |
---|
92 | |
---|
93 | draw(); |
---|
94 | } |
---|
95 | //------------------------------------------------------------------------------------------------ |
---|
96 | void RayDebugShape::setDefinition(const Ogre::Vector3& start, |
---|
97 | const Ogre::Vector3& direction, |
---|
98 | const Ogre::Real length) |
---|
99 | { |
---|
100 | clear(); |
---|
101 | |
---|
102 | const Ogre::Vector3 end (start + (direction.normalisedCopy() * length)); |
---|
103 | addLine(start, end); |
---|
104 | |
---|
105 | draw(); |
---|
106 | } |
---|
107 | //------------------------------------------------------------------------------------------------ |
---|
108 | RayDebugShape::~RayDebugShape() |
---|
109 | { |
---|
110 | } |
---|