source: OGRE/trunk/ogrenew/OgreMain/src/OgreSimpleRenderable.cpp @ 657

Revision 657, 4.6 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

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