ThingLight.cpp

Go to the documentation of this file.
00001 /*
00002 SagaEngine library
00003 Copyright (c) 2002-2006 Skalden Studio AS
00004 
00005 This software is provided 'as-is', without any express or implied 
00006 warranty. In no event will the authors be held liable for any 
00007 damages arising from the use of this software.
00008 
00009 Permission is granted to distribute the library under the terms of the 
00010 Q Public License version 1.0. Be sure to read and understand the license
00011 before using the library. It should be included here, or you may read it
00012 at http://www.trolltech.com/products/qt/licenses/licensing/qpl
00013 
00014 The original version of this library can be located at:
00015 http://www.sagaengine.com/
00016 
00017 Rune Myrland
00018 rune@skalden.com
00019 */
00020 
00021 
00022 #include "ThingLight.hpp"
00023 #include "ThingMOInfo.hpp"
00024 #include "all.hpp"
00025 #include "O3dPre.hpp"
00026 #include "../config/o3d_config.hpp"
00027 #include "../schema/O3dSchema.hpp"
00028 #include "o3d/schema/O3dSchema.hpp"
00029 #include "o3d/thing/all.hpp"
00030 #include <OgreSceneManager.h>
00031 
00032 
00033 using namespace se_core;
00034 
00035 
00036 namespace se_ogre {
00037     ThingLight
00038     ::ThingLight(se_core::PosComponent& thing, const ThingMOInfo& info, const ThingMOFactory& factory)
00039         : ThingMO(thing, info, factory), light_(0) {
00040 
00041         // Create a unique entity name
00042         char name[128];
00043         static int pool = 1000;
00044         //sprintf(name, "%d-%s", thing_.id(), thing_.name());
00045         sprintf(name, "%d-%s", ++pool, thing_.name());
00046 
00047         // Create entity
00048         light_ =  O3dSchema::sceneManager->createLight(name);
00049         light_->setType(Ogre::Light::LT_POINT);
00050         light_->setCastShadows(info.isShadowCaster_);
00051         light_->setDiffuseColour(info.specular_);
00052         light_->setSpecularColour(info.diffuse_);
00053         node_->attachObject(light_);
00054 
00055         float range = 128;
00056         float constant = 1;
00057         float linear = 0.001;
00058         float quadratic =  0.001;
00059         light_->setAttenuation(range, constant, linear, quadratic);
00060 
00061         hasAnimation_ = false;
00062     }
00063 
00064 
00065     ThingLight
00066     ::~ThingLight() {
00067         O3dSchema::sceneManager->destroyMovableObject(light_);
00068         light_ = 0;
00069     }
00070 
00071 
00072 
00073 }

Home Page | SagaEngine trunk (updated nightly) reference generated Sun Dec 2 20:06:09 2007 by Doxygen version 1.3.9.1.

SourceForge.net Logo