[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53577] branches/ge_harmony/source/ gameengine/Rasterizer/RAS_OpenGLRasterizer: Accidentally broke point lights with the spot light commit.
Daniel Stokes
kupomail at gmail.com
Sat Jan 5 10:15:22 CET 2013
Revision: 53577
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53577
Author: kupoman
Date: 2013-01-05 09:15:14 +0000 (Sat, 05 Jan 2013)
Log Message:
-----------
Accidentally broke point lights with the spot light commit. They should be scaling again now. Also the spot lights were missing a couple of faces. That problem has now been fixed as well.
Modified Paths:
--------------
branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
Modified: branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
===================================================================
--- branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp 2013-01-05 08:53:39 UTC (rev 53576)
+++ branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp 2013-01-05 09:15:14 UTC (rev 53577)
@@ -276,10 +276,10 @@
std::copy(i_tmp, i_tmp+60, &m_sphere_indices[0]);
}
-void RAS_OpenGLRasterizer::init_cone(float angle)
+void RAS_OpenGLRasterizer::init_cone(float angle, float distance)
{
int edges = 8;
- int distance = 1.1;
+ distance *= 1.1;
/* Only need half the angle */
float theta = M_PI * angle / 360;
@@ -301,26 +301,28 @@
m_cone_vertices[5] = -distance;
for (int i = 2; i < edges+2; i++){
- m_cone_vertices[3 * i + 0] = r * cosf(i*s);
- m_cone_vertices[3 * i + 1] = r * sinf(i*s);
+ m_cone_vertices[3 * i + 0] = r * cosf((i-1)*s);
+ m_cone_vertices[3 * i + 1] = r * sinf((i-1)*s);
m_cone_vertices[3 * i + 2] = -d;
}
- m_cone_indices[0] = 0;
- m_cone_indices[1] = edges;
- m_cone_indices[2] = 2;
- m_cone_indices[3] = 1;
- m_cone_indices[4] = 2;
- m_cone_indices[5] = edges;
-
+ int j = 0;
for (int i = 0; i < edges-1; i++) {
- m_cone_indices[6 * i + 0] = 0;
- m_cone_indices[6 * i + 1] = 2+i;
- m_cone_indices[6 * i + 2] = 3+i;
- m_cone_indices[6 * i + 3] = 1;
- m_cone_indices[6 * i + 4] = 3+i;
- m_cone_indices[6 * i + 5] = 2+i;
+ j = 6*i;
+ m_cone_indices[j++] = 0;
+ m_cone_indices[j++] = 2+i;
+ m_cone_indices[j++] = 3+i;
+ m_cone_indices[j++] = 1;
+ m_cone_indices[j++] = 3+i;
+ m_cone_indices[j++] = 2+i;
}
+
+ m_cone_indices[j++] = 0;
+ m_cone_indices[j++] = edges+1;
+ m_cone_indices[j++] = 2;
+ m_cone_indices[j++] = 1;
+ m_cone_indices[j++] = 2;
+ m_cone_indices[j++] = edges+1;
}
void RAS_OpenGLRasterizer::SetAmbientColor(float red, float green, float blue)
@@ -808,7 +810,7 @@
// Update light target
glBindTexture(GL_TEXTURE_2D, GPU_texture_opengl_bindcode(m_light_target));
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, m_width, m_height, 0, GL_RGBA, GL_UNSIGNED_SHORT, NULL);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_width, m_height, 0, GL_RGBA, GL_HALF_FLOAT, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
@@ -1490,9 +1492,12 @@
if (light->m_type == RAS_LightObject::LIGHT_NORMAL) {
glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glMultMatrixf((GLfloat*)light->m_obmat);
+ glLoadIdentity();
+
+ glTranslatef(fpos[0], fpos[1], fpos[2]);
+ glScalef(light->m_distance, light->m_distance, light->m_distance);
+
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, m_sphere_vertices);
glDrawElements(GL_TRIANGLES, m_sphere_size, GL_UNSIGNED_SHORT, m_sphere_indices);
@@ -1504,7 +1509,7 @@
glPushMatrix();
glMultMatrixf((GLfloat*)light->m_obmat);
- this->init_cone(light->m_spotsize);
+ this->init_cone(light->m_spotsize, light->m_distance);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, m_cone_vertices);
glDrawElements(GL_TRIANGLES, m_cone_size, GL_UNSIGNED_SHORT, m_cone_indices);
Modified: branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
===================================================================
--- branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h 2013-01-05 08:53:39 UTC (rev 53576)
+++ branches/ge_harmony/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h 2013-01-05 09:15:14 UTC (rev 53577)
@@ -145,7 +145,7 @@
float* m_sphere_vertices;
unsigned short* m_sphere_indices;
int m_sphere_size;
- void init_cone(float angle);
+ void init_cone(float angle, float distance);
float* m_cone_vertices;
unsigned short* m_cone_indices;
int m_cone_size;
More information about the Bf-blender-cvs
mailing list