Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/OgreMain/src/OgreSimpleRenderable.cpp @ 29

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

=hoffentlich gehts jetzt

File size: 4.3 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(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#include "OgreStableHeaders.h"
30#include "OgreSimpleRenderable.h"
31#include "OgreException.h"
32#include "OgreSceneNode.h"
33
34#include "OgreMaterialManager.h"
35
36namespace Ogre {
37
38    uint SimpleRenderable::ms_uGenNameCount = 0;
39
40    SimpleRenderable::SimpleRenderable()
41    {
42        m_matWorldTransform = Matrix4::IDENTITY;
43
44        m_strMatName = "BaseWhite"; 
45        m_pMaterial = MaterialManager::getSingleton().getByName("BaseWhite");
46
47        m_pParentSceneManager = NULL;
48
49        mParentNode = NULL;
50        m_pCamera = NULL;
51
52        // Generate name
53                StringUtil::StrStreamType name;
54                name << "SimpleRenderable" << ms_uGenNameCount++;
55                mName = name.str();
56    }
57
58    void SimpleRenderable::setMaterial( const String& matName )
59    {
60        m_strMatName = matName;
61        m_pMaterial = MaterialManager::getSingleton().getByName(m_strMatName);
62                if (m_pMaterial.isNull())
63                        OGRE_EXCEPT( Exception::ERR_ITEM_NOT_FOUND, "Could not find material " + m_strMatName,
64                                "SimpleRenderable::setMaterial" );
65   
66        // Won't load twice anyway
67        m_pMaterial->load();
68    }
69
70    const MaterialPtr& SimpleRenderable::getMaterial(void) const
71    {
72        return m_pMaterial;
73    }
74
75    void SimpleRenderable::getRenderOperation(RenderOperation& op)
76    {
77        op = mRenderOp;
78    }
79
80    void SimpleRenderable::setRenderOperation( const RenderOperation& rend )
81    {
82        mRenderOp = rend;
83    }
84
85    void SimpleRenderable::setWorldTransform( const Matrix4& xform )
86    {
87        m_matWorldTransform = xform;
88    }
89
90    void SimpleRenderable::getWorldTransforms( Matrix4* xform ) const
91    {
92        *xform = m_matWorldTransform * mParentNode->_getFullTransform();
93    }
94    //-----------------------------------------------------------------------
95    const Quaternion& SimpleRenderable::getWorldOrientation(void) const
96    {
97        return mParentNode->_getDerivedOrientation();
98    }
99    //-----------------------------------------------------------------------
100    const Vector3& SimpleRenderable::getWorldPosition(void) const
101    {
102        return mParentNode->_getDerivedPosition();
103    }
104
105    void SimpleRenderable::_notifyCurrentCamera(Camera* cam)
106    {
107                MovableObject::_notifyCurrentCamera(cam);
108
109        m_pCamera = cam;
110    }
111
112    void SimpleRenderable::setBoundingBox( const AxisAlignedBox& box )
113    {
114        mBox = box;
115    }
116
117    const AxisAlignedBox& SimpleRenderable::getBoundingBox(void) const
118    {
119        return mBox;
120    }
121
122    void SimpleRenderable::_updateRenderQueue(RenderQueue* queue)
123    {
124        queue->addRenderable( this, mRenderQueueID, OGRE_RENDERABLE_DEFAULT_PRIORITY); 
125    }
126
127    SimpleRenderable::~SimpleRenderable()
128    {
129    }
130    //-----------------------------------------------------------------------
131    const String& SimpleRenderable::getMovableType(void) const
132    {
133        static String movType = "SimpleRenderable";
134        return movType;
135    }
136    //-----------------------------------------------------------------------
137    const LightList& SimpleRenderable::getLights(void) const
138    {
139        // Use movable query lights
140        return queryLights();
141    }
142
143}
Note: See TracBrowser for help on using the repository browser.