Add example 20 to C::B and VC7/VC9 projects. Fix some build issues with the light manager and example.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2065 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
94a1346a5c
commit
ee5942f4c1
|
@ -2,7 +2,7 @@
|
|||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="Irrlicht Example 19 ManagedLights" />
|
||||
<Option title="Irrlicht Example 20 ManagedLights" />
|
||||
<Option pch_mode="0" />
|
||||
<Option compiler="gcc" />
|
||||
<Build>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
// Written by Colin MacDonald
|
||||
// Written by Colin MacDonald
|
||||
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
@ -14,34 +14,36 @@ using namespace video;
|
|||
using namespace io;
|
||||
using namespace gui;
|
||||
|
||||
#if defined(MSC_VER)
|
||||
#pragma comment(lib, "Irrlicht.lib")
|
||||
#endif // MSC_VER
|
||||
|
||||
/*
|
||||
Normally, you are limited to 8 dynamic lights per scene: this is a hardware limit. If you
|
||||
want to use more dynamic lights in your scene, then you can register an optional light
|
||||
want to use more dynamic lights in your scene, then you can register an optional light
|
||||
manager that allows you to to turn lights on and off at specific point during rendering.
|
||||
You are still limited to 8 lights, but the limit is per scene node.
|
||||
|
||||
This is completely optional: if you do not register a light manager, then a default
|
||||
distance-based scheme will be used to prioritise hardware lights based on their distance
|
||||
This is completely optional: if you do not register a light manager, then a default
|
||||
distance-based scheme will be used to prioritise hardware lights based on their distance
|
||||
from the active camera.
|
||||
|
||||
NO_MANAGEMENT disables the light manager and shows Irrlicht's default light behaviour.
|
||||
The 8 lights nearest to the camera will be turned on, and other lights will be turned off.
|
||||
In this example, this produces a funky looking but incoherent light display.
|
||||
|
||||
LIGHTS_NEAREST_NODE shows an implementation that turns on a limited number of lights
|
||||
per mesh scene node. If finds the 3 lights that are nearest to the node being rendered,
|
||||
and turns them on, turning all other lights off. This works, but as it operates on every
|
||||
LIGHTS_NEAREST_NODE shows an implementation that turns on a limited number of lights
|
||||
per mesh scene node. If finds the 3 lights that are nearest to the node being rendered,
|
||||
and turns them on, turning all other lights off. This works, but as it operates on every
|
||||
light for every node, it does not scale well with many lights. The flickering you can see
|
||||
in this demo is due to the lights swapping their relative positions from the cubes
|
||||
(a deliberate demonstration of the limitations of this technique).
|
||||
|
||||
LIGHTS_IN_ZONE shows a technique for turning on lights based on a 'zone'. Each empty scene
|
||||
node is considered to be the parent of a zone. When nodes are rendered, they turn off all
|
||||
node is considered to be the parent of a zone. When nodes are rendered, they turn off all
|
||||
lights, then find their parent 'zone' and turn on all lights that are inside that zone, i.e.
|
||||
are descendents of it in the scene graph. This produces true 'local' lighting for each cube
|
||||
in this example. You could use a similar technique to locally light all meshes in (e.g.)
|
||||
are descendents of it in the scene graph. This produces true 'local' lighting for each cube
|
||||
in this example. You could use a similar technique to locally light all meshes in (e.g.)
|
||||
a room, without the lights spilling out to other rooms.
|
||||
|
||||
This light manager is also an event receiver; this is purely for simplicity in this example,
|
||||
|
@ -69,9 +71,9 @@ class CMyLightManager : public ILightManager, public IEventReceiver
|
|||
|
||||
public:
|
||||
CMyLightManager(ISceneManager* sceneManager)
|
||||
: SceneManager(sceneManager), SceneLightList(0),
|
||||
CurrentRenderPass(ESNRP_COUNT), CurrentSceneNode(0),
|
||||
Mode(NO_MANAGEMENT), RequestedMode(NO_MANAGEMENT)
|
||||
: Mode(NO_MANAGEMENT), RequestedMode(NO_MANAGEMENT),
|
||||
SceneManager(sceneManager), SceneLightList(0),
|
||||
CurrentRenderPass(ESNRP_COUNT), CurrentSceneNode(0)
|
||||
{ }
|
||||
|
||||
virtual ~CMyLightManager(void) { }
|
||||
|
@ -108,7 +110,7 @@ public:
|
|||
|
||||
return handled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// This is called before the first scene node is rendered.
|
||||
virtual void OnPreRender(core::array<ILightSceneNode*> & lightList)
|
||||
|
@ -123,9 +125,9 @@ public:
|
|||
// Called after the last scene node is rendered.
|
||||
virtual void OnPostRender()
|
||||
{
|
||||
// Since light management might be switched off in the event handler, we'll turn all
|
||||
// lights on to ensure that they are in a consistent state. You wouldn't normally have
|
||||
// to do this when using a light manager, since you'd continue to do light management
|
||||
// Since light management might be switched off in the event handler, we'll turn all
|
||||
// lights on to ensure that they are in a consistent state. You wouldn't normally have
|
||||
// to do this when using a light manager, since you'd continue to do light management
|
||||
// yourself.
|
||||
for(u32 i = 0; i < SceneLightList->size(); i++)
|
||||
(*SceneLightList)[i]->setVisible(true);
|
||||
|
@ -158,7 +160,7 @@ public:
|
|||
return;
|
||||
|
||||
// And in fact for this example, I only want to consider lighting for cube scene
|
||||
// nodes. You will probably want to deal with lighting for (at least) mesh /
|
||||
// nodes. You will probably want to deal with lighting for (at least) mesh /
|
||||
// animated mesh scene nodes as well.
|
||||
if(node->getType() != ESNT_CUBE)
|
||||
return;
|
||||
|
@ -166,7 +168,7 @@ public:
|
|||
if(LIGHTS_NEAREST_NODE == Mode)
|
||||
{
|
||||
// This is a naive implementation that prioritises every light in the scene
|
||||
// by its proximity to the node being rendered. This produces some flickering
|
||||
// by its proximity to the node being rendered. This produces some flickering
|
||||
// when lights orbit closer to a cube than its 'zone' lights.
|
||||
const vector3df nodePosition = node->getAbsolutePosition();
|
||||
|
||||
|
@ -179,8 +181,6 @@ public:
|
|||
for(i = 0; i < SceneLightList->size(); ++i)
|
||||
{
|
||||
ILightSceneNode* lightNode = (*SceneLightList)[i];
|
||||
SLight & lightData = lightNode->getLightData();
|
||||
|
||||
f64 distance = lightNode->getAbsolutePosition().getDistanceFromSQ(nodePosition);
|
||||
sortingArray.push_back(LightDistanceElement(lightNode, distance));
|
||||
}
|
||||
|
@ -196,9 +196,9 @@ public:
|
|||
else if(LIGHTS_IN_ZONE == Mode)
|
||||
{
|
||||
// Empty scene nodes are used to represent 'zones'. For each solid mesh that
|
||||
// is being rendered, turn off all lights, then find its 'zone' parent, and turn
|
||||
// is being rendered, turn off all lights, then find its 'zone' parent, and turn
|
||||
// on all lights that are found under that node in the scene graph.
|
||||
// This is a general purpose algorithm that doesn't use any special
|
||||
// This is a general purpose algorithm that doesn't use any special
|
||||
// knowledge of how this particular scene graph is organised.
|
||||
for(u32 i = 0; i < SceneLightList->size(); ++i)
|
||||
{
|
||||
|
@ -338,7 +338,7 @@ int main(int argumentCount, char * argumentValues[])
|
|||
rotation->drop();
|
||||
|
||||
// And each cube has three lights attached to it. The lights are attached to billboards so
|
||||
// that we can see where they are. The billboards are attached to the cube, so that the
|
||||
// that we can see where they are. The billboards are attached to the cube, so that the
|
||||
// lights are indirect descendents of the same empty scene node as the cube.
|
||||
IBillboardSceneNode * billboard = smgr->addBillboardSceneNode(node);
|
||||
billboard->setPosition(vector3df(0, -14, 30));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_workspace_file>
|
||||
<Workspace title="Build all examples">
|
||||
<Project filename="01.HelloWorld\HelloWorld.cbp" active="1" />
|
||||
<Project filename="01.HelloWorld\HelloWorld.cbp" />
|
||||
<Project filename="02.Quake3Map\Quake3Map.cbp" />
|
||||
<Project filename="03.CustomSceneNode\CustomSceneNode.cbp" />
|
||||
<Project filename="04.Movement\Movement.cbp" />
|
||||
|
@ -19,6 +19,7 @@
|
|||
<Project filename="16.Quake3MapShader\Quake3MapShader.cbp" />
|
||||
<Project filename="18.SplitScreen\SplitScreen.cbp" />
|
||||
<Project filename="19.MouseAndJoystick\MouseAndJoystick.cbp" />
|
||||
<Project filename="20.ManagedLights\ManagedLights.cbp" active="1" />
|
||||
<Project filename="Demo\demo.cbp" />
|
||||
<Project filename="..\source\Irrlicht\Irrlicht-gcc.cbp" />
|
||||
</Workspace>
|
||||
|
|
|
@ -76,6 +76,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "16.Quake3MapShader", "16.Qu
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.MouseAndJoystick", "19.MouseAndJoystick\MouseAndJoystick.vcproj", "{1AB9413E-4F53-42A3-8CB2-CB4BE22336D0}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "20.ManagedLights_vc8", "20.ManagedLights\ManagedLights_vc8.vcproj", "{16007FE2-142B-47F8-93E1-519BA3F39E71}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
|
|
|
@ -92,6 +92,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "18.SplitScreen_vc9", "18.Sp
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "19.MouseAndJoystick_vc9", "19.MouseAndJoystick\MouseAndJoystick_vc9.vcproj", "{FE853A36-E0D1-4AC5-A792-B643E70D2953}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "20.ManagedLights_vc8", "20.ManagedLights\ManagedLights_vc8.vcproj", "{16007FE2-142B-47F8-93E1-519BA3F39E71}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Written by Colin MacDonald - all rights assigned to Nikolaus Gebhardt
|
||||
// Copyright (C) 2008-2009 Nikolaus Gebhardt
|
||||
// Copyright (C) 2008 Nikolaus Gebhardt
|
||||
// This file is part of the "Irrlicht Engine".
|
||||
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
||||
|
||||
|
@ -15,17 +15,13 @@ namespace scene
|
|||
{
|
||||
class ILightSceneNode;
|
||||
|
||||
//! Provides callbacks to when the the scene graph is rendered.
|
||||
/** ILightManager is an optional manager that the user application can
|
||||
register in order to receive callbacks as the scene is rendered.
|
||||
The OnPreRender() callback provides the user application with a list of the
|
||||
lights in the scene. This list can be stored and used to turn lights
|
||||
on and off as each scene node is rendered in order to provide per-node
|
||||
or 'local' lights.
|
||||
It is assumed that the ILightManager implementation will store any
|
||||
data that it wishes to retain, i.e. the ISceneManager to which it is assigned,
|
||||
the lightList, the current render pass, and the current scene node.
|
||||
*/
|
||||
//! ILightManager provides an interface for user applications to manipulate the list
|
||||
//! of lights in the scene. The light list can be trimmed or re-ordered before device/
|
||||
//! hardware lights are created, and/or individual lights can be switched on and off
|
||||
//! before or after each scene node is rendered.
|
||||
//! It is assumed that the ILightManager implementation will store any data that it wishes
|
||||
//! to retain, i.e. the ISceneManager to which it is assigned, the lightList, the current
|
||||
//! render pass, and the current scene node.
|
||||
class ILightManager : public IReferenceCounted
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue