Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics_new/src/ogrebullet/Collisions/Debug/OgreBulletCollisionsDebugShape.cpp @ 2119

Last change on this file since 2119 was 2119, checked in by rgrieder, 15 years ago

Merged physics branch into physics_new branch.

  • Property svn:eol-style set to native
File size: 3.8 KB
Line 
1/***************************************************************************
2
3This source file is part of OGREBULLET
4(Object-oriented Graphics Rendering Engine Bullet Wrapper)
5For the latest info, see http://www.ogre3d.org/phpBB2addons/viewforum.php?f=10
6
7Copyright (c) 2007 tuan.kuranes@gmail.com (Use it Freely, even Statically, but have to contribute any changes)
8
9
10
11This program is free software; you can redistribute it and/or modify it under
12the terms of the GPL General Public License with runtime exception as published by the Free Software
13Foundation; either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GPL General Public License with runtime exception for more details.
19
20You should have received a copy of the GPL General Public License with runtime exception along with
21this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://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
33using namespace OgreBulletCollisions;
34using namespace Ogre;
35
36//------------------------------------------------------------------------------------------------
37DebugCollisionShape::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//------------------------------------------------------------------------------------------------
49void 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//------------------------------------------------------------------------------------------------
72DebugCollisionShape::~DebugCollisionShape() 
73{
74}
75//------------------------------------------------------------------------------------------------
76bool DebugCollisionShape::getIsVisual() const
77{
78    return mIsVisual;
79}
80//------------------------------------------------------------------------------------------------
81void DebugCollisionShape::setIsVisual( bool val )
82{
83    mIsVisual = val;
84}
85//------------------------------------------------------------------------------------------------
86RayDebugShape::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//------------------------------------------------------------------------------------------------
96void 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//------------------------------------------------------------------------------------------------
108RayDebugShape::~RayDebugShape()
109{
110}
Note: See TracBrowser for help on using the repository browser.