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

Revision 692, 4.5 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

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                mName = 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                MovableObject::_notifyCurrentCamera(cam);
104
105        m_pCamera = cam;
106    }
107
108    void SimpleRenderable::setBoundingBox( const AxisAlignedBox& box )
109    {
110        mBox = box;
111    }
112
113    const AxisAlignedBox& SimpleRenderable::getBoundingBox(void) const
114    {
115        return mBox;
116    }
117
118    void SimpleRenderable::_updateRenderQueue(RenderQueue* queue)
119    {
120        queue->addRenderable( this, mRenderQueueID, OGRE_RENDERABLE_DEFAULT_PRIORITY);
121    }
122
123    SimpleRenderable::~SimpleRenderable()
124    {
125    }
126    //-----------------------------------------------------------------------
127    const String& SimpleRenderable::getMovableType(void) const
128    {
129        static String movType = "SimpleRenderable";
130        return movType;
131    }
132    //-----------------------------------------------------------------------
133    const LightList& SimpleRenderable::getLights(void) const
134    {
135        static LightList dummyLightList;
136        // Use parent node
137        SceneNode* n = getParentSceneNode();
138        if (n)
139            return n->findLights(this->getBoundingRadius());
140        else
141            return dummyLightList;
142    }
143
144}
Note: See TracBrowser for help on using the repository browser.