annotate engine/core/view/renderers/lightrenderer.cpp @ 661:e3140f01749d

* Merged the light branch back into trunk. * Modified the demos so they work with the new loaders and setting.
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 05 Nov 2010 15:21:10 +0000
parents
children 60621d858548
rev   line source
661
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 * License as published by the Free Software Foundation; either *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 * This library is distributed in the hope that it will be useful, *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 * Lesser General Public License for more details. *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 * License along with this library; if not, write to the *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23 #include <SDL.h>
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 // 3rd party library includes
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // FIFE includes
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // These includes are split up in two parts, separated by one empty line
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // First block: files included from the FIFE root src directory
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 // Second block: files included from the same folder
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 #include "video/renderbackend.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 #include "video/imagepool.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 #include "video/animation.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 #include "video/animationpool.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 #include "video/fonts/abstractfont.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 #include "video/image.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37 #include "video/opengl/glimage.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 #include "util/math/fife_math.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 #include "util/log/logger.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40 #include "util/time/timemanager.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41 #include "model/metamodel/grids/cellgrid.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 #include "model/metamodel/timeprovider.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 #include "model/structures/instance.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44 #include "model/structures/layer.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 #include "model/structures/location.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 #include "view/camera.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 #include "lightrenderer.h"
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 namespace FIFE {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 static Logger _log(LM_VIEWVIEW);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 LightRendererNode::LightRendererNode(Instance* attached_instance, const Location &relative_location, Layer* relative_layer, const Point &relative_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 m_instance(attached_instance),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 m_location(relative_location),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 m_layer(relative_layer),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 m_point(relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 LightRendererNode::LightRendererNode(Instance* attached_instance, const Location &relative_location, const Point &relative_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 m_instance(attached_instance),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 m_location(relative_location),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 m_layer(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 m_point(relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 LightRendererNode::LightRendererNode(Instance* attached_instance, Layer* relative_layer, const Point &relative_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67 m_instance(attached_instance),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 m_location(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
69 m_layer(relative_layer),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
70 m_point(relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 LightRendererNode::LightRendererNode(Instance* attached_instance, const Point &relative_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 m_instance(attached_instance),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 m_location(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 m_layer(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 m_point(relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 LightRendererNode::LightRendererNode(const Location &attached_location, Layer* relative_layer, const Point &relative_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 m_instance(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 m_location(attached_location),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 m_layer(relative_layer),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 m_point(relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 LightRendererNode::LightRendererNode(const Location &attached_location, const Point &relative_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 m_instance(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 m_location(attached_location),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 m_layer(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 m_point(relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 LightRendererNode::LightRendererNode(Layer* attached_layer, const Point &relative_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
91 m_instance(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 m_location(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 m_layer(attached_layer),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
94 m_point(relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
95 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
96 LightRendererNode::LightRendererNode(const Point &attached_point):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 m_instance(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 m_location(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 m_layer(NULL),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 m_point(attached_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
102 LightRendererNode::~LightRendererNode() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 void LightRendererNode::setAttached(Instance* attached_instance, const Location &relative_location, const Point &relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 m_instance = attached_instance;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 m_location = relative_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
108 m_point = relative_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
110 void LightRendererNode::setAttached(Instance* attached_instance, const Location &relative_location) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 m_instance = attached_instance;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 m_location = relative_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
113 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
114 void LightRendererNode::setAttached(Instance* attached_instance, const Point &relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
115 m_instance = attached_instance;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
116 m_point = relative_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 void LightRendererNode::setAttached(Instance* attached_instance) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 m_instance = attached_instance;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
121 void LightRendererNode::setAttached(const Location &attached_location, const Point &relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 m_instance = NULL;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 m_location = attached_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 m_point = relative_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 void LightRendererNode::setAttached(const Location &attached_location) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
127 m_instance = NULL;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 m_location = attached_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 void LightRendererNode::setAttached(Layer* attached_layer) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 m_layer = attached_layer;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 void LightRendererNode::setAttached(const Point &attached_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 m_instance = NULL;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 m_location = NULL;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 m_point = attached_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 void LightRendererNode::setRelative(const Location &relative_location) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
140 if(m_instance == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 throw NotSupported("No instance attached.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 m_location = relative_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 void LightRendererNode::setRelative(const Location &relative_location, Point relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 if(m_instance == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 throw NotSupported("No instance attached.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 m_location = relative_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 m_point = relative_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 void LightRendererNode::setRelative(const Point &relative_point) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 if(m_instance == NULL || m_location == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 throw NotSupported("No instance or location attached.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 m_point = relative_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 Instance* LightRendererNode::getAttachedInstance() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 if(m_instance == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 throw NotSupported("No instance attached.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 return m_instance;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 Location LightRendererNode::getAttachedLocation() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 if(m_instance != NULL || m_location == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 throw NotSupported("No location attached.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 return m_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 Layer* LightRendererNode::getAttachedLayer() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 if(m_layer == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 throw NotSupported("No layer attached.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 return m_layer;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 Point LightRendererNode::getAttachedPoint() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
178 if(m_instance != NULL || m_location != NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 throw NotSupported("No point attached.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 return m_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 Location LightRendererNode::getOffsetLocation() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 if(m_instance == NULL || m_location == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 throw NotSupported("No location as offset used.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 return m_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 Point LightRendererNode::getOffsetPoint() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 if(m_instance == NULL && m_location == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 throw NotSupported("No point as offset used.");
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 return m_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 Instance* LightRendererNode::getInstance() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 return m_instance;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 Location LightRendererNode::getLocation() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 return m_location;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 Layer* LightRendererNode::getLayer() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204 return m_layer;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 Point LightRendererNode::getPoint() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 return m_point;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 Point LightRendererNode::getCalculatedPoint(Camera* cam, Layer* layer) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 ScreenPoint p;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 if(m_instance != NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 if(m_layer == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214 m_layer = m_instance->getLocation().getLayer();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 if(m_location != NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 p = cam->toScreenCoordinates(m_instance->getLocationRef().getMapCoordinates() + m_location.getMapCoordinates());
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 } else {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 p = cam->toScreenCoordinates(m_instance->getLocation().getMapCoordinates());
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 } else if(m_location != NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222 if(m_layer == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 m_layer = m_location.getLayer();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 p = cam->toScreenCoordinates(m_location.getMapCoordinates());
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 } else if(m_layer == NULL) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 const std::list<Layer*>& layers = cam->getRenderer("LightRenderer")->getActiveLayers();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 std::list<Layer*>::const_reverse_iterator layer_it = layers.rbegin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 setAttached(*layer_it);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231 return Point(m_point.x + p.x, m_point.y + p.y);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 LightRendererImageInfo::LightRendererImageInfo(LightRendererNode anchor, int image, int src, int dst):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 LightRendererElementInfo(),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 m_anchor(anchor),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 m_image(image),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 m_src(src),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 m_dst(dst),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 m_stencil(false),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 m_stencil_ref(0),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 m_alpha_ref(0.0) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244 void LightRendererImageInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
245 Point p = m_anchor.getCalculatedPoint(cam, layer);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
246 if(m_anchor.getLayer() == layer) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 Image* img = &imagepool->getImage(m_image);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 Rect r;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 Rect viewport = cam->getViewPort();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 r.x = p.x-img->getWidth()/2;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 r.y = p.y-img->getHeight()/2;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 r.w = img->getWidth();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 r.h = img->getHeight();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254 renderbackend->changeBlending(m_src, m_dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 if(r.intersects(viewport))
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 img->render(r);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 void LightRendererImageInfo::setStencil(uint8_t stencil_ref, float alpha_ref) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260 m_stencil = true;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 m_stencil_ref = stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 m_alpha_ref = alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 int LightRendererImageInfo::getStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265 if(!m_stencil) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 return -1;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 return m_stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 float LightRendererImageInfo::getAlpha() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 return m_alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 void LightRendererImageInfo::removeStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 m_stencil = false;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 m_stencil_ref = 0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 m_alpha_ref = 0.0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 LightRendererAnimationInfo::LightRendererAnimationInfo(LightRendererNode anchor, int animation, int src, int dst):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 LightRendererElementInfo(),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 m_anchor(anchor),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282 m_animation(animation),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 m_src(src),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 m_dst(dst),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 m_start_time(TimeManager::instance()->getTime()),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286 m_time_scale(1.0),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
287 m_stencil(false),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
288 m_stencil_ref(0),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
289 m_alpha_ref(0.0) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 void LightRendererAnimationInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
292 Point p = m_anchor.getCalculatedPoint(cam, layer);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 if(m_anchor.getLayer() == layer) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 Animation& animation = animpool->getAnimation(m_animation);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295 int animtime = scaleTime(m_time_scale, TimeManager::instance()->getTime() - m_start_time) % animation.getDuration();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296 Image* img = animation.getFrameByTimestamp(animtime);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
297 Rect r;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
298 Rect viewport = cam->getViewPort();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
299 r.x = p.x-img->getWidth()/2;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
300 r.y = p.y-img->getHeight()/2;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
301 r.w = img->getWidth();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302 r.h = img->getHeight();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303 renderbackend->changeBlending(m_src, m_dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
304 if(r.intersects(viewport))
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 img->render(r);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
306 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
307 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
308 void LightRendererAnimationInfo::setStencil(uint8_t stencil_ref, float alpha_ref) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
309 m_stencil = true;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
310 m_stencil_ref = stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 m_alpha_ref = alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
312 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
313 int LightRendererAnimationInfo::getStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 if(!m_stencil) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
315 return -1;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 return m_stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
318 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 float LightRendererAnimationInfo::getAlpha() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
320 return m_alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
321 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
322 void LightRendererAnimationInfo::removeStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 m_stencil = false;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
324 m_stencil_ref = 0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 m_alpha_ref = 0.0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
326 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328 LightRendererResizeInfo::LightRendererResizeInfo(LightRendererNode anchor, int image, int width, int height, int src, int dst):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 LightRendererElementInfo(),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330 m_anchor(anchor),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 m_image(image),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332 m_width(width),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 m_height(height),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 m_src(src),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
335 m_dst(dst),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 m_stencil(false),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337 m_stencil_ref(0),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
338 m_alpha_ref(0.0) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
339 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
340 void LightRendererResizeInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
341 Point p = m_anchor.getCalculatedPoint(cam, layer);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342 if(m_anchor.getLayer() == layer) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
343 Image* img = &imagepool->getImage(m_image);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
344 Rect r;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
345 Rect viewport = cam->getViewPort();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346 r.x = p.x-m_width/2;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
347 r.y = p.y-m_height/2;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
348 r.w = m_width;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
349 r.h = m_height;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
350 renderbackend->changeBlending(m_src, m_dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
351 if(r.intersects(viewport))
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
352 img->render(r);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
353 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
354 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
355 void LightRendererResizeInfo::setStencil(uint8_t stencil_ref, float alpha_ref) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
356 m_stencil = true;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
357 m_stencil_ref = stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
358 m_alpha_ref = alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
359 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
360 int LightRendererResizeInfo::getStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
361 if(!m_stencil) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
362 return -1;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
363 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
364 return m_stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
365 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
366 float LightRendererResizeInfo::getAlpha() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
367 return m_alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
368 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
369 void LightRendererResizeInfo::removeStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
370 m_stencil = false;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
371 m_stencil_ref = 0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
372 m_alpha_ref = 0.0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
373 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
374
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
375 LightRendererSimpleLightInfo::LightRendererSimpleLightInfo(LightRendererNode anchor, uint8_t intensity, float radius, int subdivisions, float xstretch, float ystretch, uint8_t r, uint8_t g, uint8_t b, int src, int dst):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
376 LightRendererElementInfo(),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
377 m_anchor(anchor),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
378 m_intensity(intensity),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
379 m_radius(radius),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
380 m_subdivisions(subdivisions),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
381 m_xstretch(xstretch),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
382 m_ystretch(ystretch),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
383 m_red(r),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
384 m_green(g),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
385 m_blue(b),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
386 m_src(src),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
387 m_dst(dst),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
388 m_stencil(false),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
389 m_stencil_ref(0),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
390 m_alpha_ref(0.0) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
391 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
392 void LightRendererSimpleLightInfo::render(Camera* cam, Layer* layer, RenderList& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
393 Point p = m_anchor.getCalculatedPoint(cam, layer);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
394 if(m_anchor.getLayer() == layer) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
395 renderbackend->changeBlending(m_src, m_dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
396 renderbackend->drawLightPrimitive(p, m_intensity, m_radius, m_subdivisions, m_xstretch, m_ystretch, m_red, m_green, m_blue);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
397 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
398 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
399 void LightRendererSimpleLightInfo::setStencil(uint8_t stencil_ref, float alpha_ref) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
400 m_stencil = true;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
401 m_stencil_ref = stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
402 m_alpha_ref = alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
403 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
404 int LightRendererSimpleLightInfo::getStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
405 if(!m_stencil) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
406 return -1;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
407 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
408 return m_stencil_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
409 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
410 float LightRendererSimpleLightInfo::getAlpha() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
411 return m_alpha_ref;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
412 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
413 void LightRendererSimpleLightInfo::removeStencil() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
414 m_stencil = false;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
415 m_stencil_ref = 0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
416 m_alpha_ref = 0.0;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
417 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
418 std::vector<uint8_t> LightRendererSimpleLightInfo::getColor() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
419 std::vector<uint8_t> colors;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
420 colors.push_back(m_red);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
421 colors.push_back(m_green);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
422 colors.push_back(m_blue);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
423 colors.push_back(m_intensity);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
424 return colors;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
425 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
426
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
427 LightRenderer* LightRenderer::getInstance(IRendererContainer* cnt) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
428 return dynamic_cast<LightRenderer*>(cnt->getRenderer("LightRenderer"));
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
429 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
430
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
431 LightRenderer::LightRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
432 RendererBase(renderbackend, position),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
433 m_imagepool(imagepool),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
434 m_animationpool(animpool),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
435 m_groups() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
436 setEnabled(false);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
437 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
438
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
439 LightRenderer::LightRenderer(const LightRenderer& old):
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
440 RendererBase(old),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
441 m_imagepool(old.m_imagepool),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
442 m_animationpool(old.m_animationpool),
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
443 m_groups() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
444 setEnabled(false);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
445 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
446
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
447 RendererBase* LightRenderer::clone() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
448 return new LightRenderer(*this);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
449 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
450
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
451 LightRenderer::~LightRenderer() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
452 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
453 // Add a static lightmap
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
454 void LightRenderer::addImage(const std::string &group, LightRendererNode n, int image, int src, int dst) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
455 LightRendererElementInfo* info = new LightRendererImageInfo(n, image, src, dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
456 m_groups[group].push_back(info);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
457 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
458 // Add a animation lightmap
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
459 void LightRenderer::addAnimation(const std::string &group, LightRendererNode n, int animation, int src, int dst) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
460 LightRendererElementInfo* info = new LightRendererAnimationInfo(n, animation, src, dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
461 m_groups[group].push_back(info);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
462 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
463 // Add a simple light
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
464 void LightRenderer::addSimpleLight(const std::string &group, LightRendererNode n, uint8_t intensity, float radius, int subdivisions, float xstretch, float ystretch, uint8_t r, uint8_t g, uint8_t b, int src, int dst) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
465 LightRendererElementInfo* info = new LightRendererSimpleLightInfo(n, intensity, radius, subdivisions, xstretch, ystretch, r, g, b, src, dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
466 m_groups[group].push_back(info);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
467 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
468 // Resize an Image
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
469 void LightRenderer::resizeImage(const std::string &group, LightRendererNode n, int image, int width, int height, int src, int dst) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
470 LightRendererElementInfo* info = new LightRendererResizeInfo(n, image, width, height, src, dst);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
471 m_groups[group].push_back(info);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
472 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
473 // Enable stencil test for the group
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
474 void LightRenderer::addStencilTest(const std::string &group, uint8_t stencil_ref, float alpha_ref) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
475 std::vector<LightRendererElementInfo*>::const_iterator info_it = m_groups[group].begin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
476 for (;info_it != m_groups[group].end(); ++info_it) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
477 (*info_it)->setStencil(stencil_ref, alpha_ref);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
478 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
479 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
480 // Disable stencil test for the group
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
481 void LightRenderer::removeStencilTest(const std::string &group) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
482 std::vector<LightRendererElementInfo*>::const_iterator info_it = m_groups[group].begin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
483 for (;info_it != m_groups[group].end(); ++info_it) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
484 (*info_it)->removeStencil();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
485 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
486 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
487 // Return a list of all groups
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
488 std::list<std::string> LightRenderer::getGroups() {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
489 std::list<std::string> groups;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
490 std::map<std::string, std::vector<LightRendererElementInfo*> >::iterator group_it = m_groups.begin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
491 for(; group_it != m_groups.end(); ++group_it) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
492 groups.push_back(group_it->first);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
493 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
494 groups.sort();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
495 groups.unique();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
496 return groups;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
497 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
498 // Return a vector of all LightElementInfos
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
499 std::vector<LightRendererElementInfo*> LightRenderer::getLightInfo(const std::string &group) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
500 std::vector<LightRendererElementInfo*> info;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
501 std::vector<LightRendererElementInfo*>::const_iterator info_it = m_groups[group].begin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
502 for (;info_it != m_groups[group].end(); ++info_it) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
503 info.push_back(*info_it);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
504 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
505 return info;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
506 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
507 // Remove the group
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
508 void LightRenderer::removeAll(const std::string &group) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
509 std::vector<LightRendererElementInfo*>::const_iterator info_it = m_groups[group].begin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
510 for (;info_it != m_groups[group].end(); ++info_it) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
511 delete *info_it;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
512 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
513 m_groups[group].clear();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
514 m_groups.erase(group);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
515 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
516 // Render
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
517 void LightRenderer::render(Camera* cam, Layer* layer, RenderList& instances) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
518 uint8_t lm = m_renderbackend->getLightingModel();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
519
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
520 if (!layer->areInstancesVisible()) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
521 return;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
522 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
523 m_renderbackend->disableLighting();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
524 std::map<std::string, std::vector<LightRendererElementInfo*> >::iterator group_it = m_groups.begin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
525 for (; group_it != m_groups.end(); ++group_it) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
526 std::vector<LightRendererElementInfo*>::const_iterator info_it = group_it->second.begin();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
527 for (;info_it != group_it->second.end(); ++info_it) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
528 if (lm != 0) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
529 if ((*info_it)->getStencil() != -1) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
530 uint8_t sref = (*info_it)->getStencil();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
531 float aref = (*info_it)->getAlpha();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
532 if(info_it != group_it->second.begin())
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
533 sref += 1;
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
534 m_renderbackend->setStencilTest(sref, 3, 4);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
535 m_renderbackend->setAlphaTest(aref);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
536 } else if(lm == 1) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
537 m_renderbackend->setStencilTest(255, 0, 6);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
538 m_renderbackend->setAlphaTest(0);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
539 } else if(lm == 2) {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
540 m_renderbackend->setStencilTest(1, 2, 4);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
541 m_renderbackend->setAlphaTest(0);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
542 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
543 (*info_it)->render(cam, layer, instances, m_renderbackend, m_imagepool, m_animationpool);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
544 m_renderbackend->disableAlphaTest();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
545 m_renderbackend->disableStencilTest();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
546 } else {
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
547 (*info_it)->render(cam, layer, instances, m_renderbackend, m_imagepool, m_animationpool);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
548 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
549 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
550 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
551 m_renderbackend->changeBlending(4, 5);
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
552 m_renderbackend->enableLighting();
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
553 }
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
554
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
555 }