Merge remote-tracking branch 'remotes/upstrem/master' into skiddingAI

This commit is contained in:
Guillaume P 2014-03-21 14:05:42 +01:00
commit c857bbaec0
33 changed files with 699 additions and 344 deletions

View File

@ -6,9 +6,7 @@
language: cpp
compiler:
- gcc
#- clang
git:
submodules: false
# - clang
#branches:
# only:
# - master
@ -16,10 +14,13 @@ before_install:
# UPDATE REPOS
- sudo apt-get update -qq
# INSTALL DEPENDENCIES
- sudo apt-get install autoconf automake build-essential cmake libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev libbluetooth-dev
- sudo apt-get install build-essential cmake libogg-dev libvorbis-dev libopenal-dev libxxf86vm-dev libgl1-mesa-dev libglu1-mesa-dev libcurl4-openssl-dev libfribidi-dev libbluetooth-dev
script:
# BUILD COMMANDS
- ./tools/build-linux-travis.sh
- mkdir build
- cd build
- cmake .. -DCMAKE_BUILD_TYPE=Debug
- make VERBOSE=1 -j 4
notifications:
irc:
channels:

View File

@ -3,7 +3,7 @@ project(SuperTuxKart)
set(PROJECT_VERSION "0.8.1")
cmake_minimum_required(VERSION 2.8.1)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
include(BuildTypeSTKRelease)
if (NOT CMAKE_BUILD_TYPE)

View File

@ -25,5 +25,20 @@
title="Marathoner" description="Make a race with 5 laps or more">
<laps goal="5"/>
</achievement>
<achievement id="5" check-type="all-at-least" reset-after-race="yes"
title="Skid-row" description="Make 5 skidding in a single race">
<skidding goal="5"/>
</achievement>
<achievement id="6" check-type="all-at-least" reset-after-race="no"
title="Gold driver" description="Win in all single player modes, against at least 3 opponents.">
<standard goal="1"/>
<std_timetrial goal="1"/>
<follow_leader goal="1"/>
<opponents goal="3"/>
</achievement>
<achievement id="7" check-type="all-at-least" reset-after-race="yes"
title="Powerup Love" description="Use 10 or more powerups in a race">
<poweruplover goal="10"/>
</achievement>
</achievements>

View File

@ -5,6 +5,7 @@ uniform vec2 screen;
in float lf;
in vec2 tc;
in vec3 pc;
out vec4 color;
@ -18,6 +19,6 @@ void main(void)
vec4 EnvPos = invproj * (2. * vec4(xy, EnvZ, 1.0) - 1.);
EnvPos /= EnvPos.w;
float alpha = clamp((EnvPos.z - FragmentPos.z) * 0.3, 0., 1.);
color = texture(tex, tc);
color = texture(tex, tc) * vec4(pc, 1.0);
color.a *= alpha * smoothstep(1., 0.8, lf);
}

View File

@ -1,5 +1,7 @@
uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;
uniform vec3 color_from;
uniform vec3 color_to;
in vec2 quadcorner;
in vec2 texcoord;
@ -9,11 +11,13 @@ in float size;
out float lf;
out vec2 tc;
out vec3 pc;
void main(void)
{
tc = texcoord;
lf = lifetime;
pc = color_from + (color_to - color_from) * lifetime;
vec3 newposition = position;
vec4 viewpos = ViewMatrix * vec4(newposition, 1.0);

View File

@ -2,6 +2,7 @@ uniform sampler2D tex;
#if __VERSION__ >= 130
in vec2 uv;
in vec4 color;
out vec4 FragColor;
#else
varying vec2 uv;
@ -11,5 +12,5 @@ varying vec2 uv;
void main()
{
FragColor = texture(tex, uv);
FragColor = texture(tex, uv) * color;
}

View File

@ -4,7 +4,9 @@ uniform mat4 TextureMatrix;
#if __VERSION__ >= 130
in vec3 Position;
in vec2 Texcoord;
in vec4 Color;
out vec2 uv;
out vec4 color;
#else
attribute vec3 Position;
attribute vec2 Texcoord;
@ -16,4 +18,5 @@ void main()
{
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
color = Color;
}

View File

@ -1,13 +1,13 @@
# CMakeLists.txt for Irrlicht in STK
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/
${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/jpeglib
${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/libpng
${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/zlib
${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/bzip2)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/jpeglib"
"${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/libpng"
"${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/zlib"
"${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/bzip2")
if(APPLE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/MacOSX ${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht/MacOSX" "${CMAKE_CURRENT_SOURCE_DIR}/source/Irrlicht")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch i386")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch i386 -F/Library/Frameworks")
endif()

View File

@ -2,6 +2,16 @@
cmake_minimum_required(VERSION 2.8.1)
# libbluetooth is required on Unix platforms
if(UNIX)
include(FindPkgConfig)
pkg_check_modules(BLUETOOTH bluez)
if(NOT BLUETOOTH_FOUND)
message(FATAL_ERROR "Bluetooth library not found. "
"Either install libbluetooth or disable wiiuse support with -DUSE_WIIUSE=0")
endif()
endif()
set(WIIUSE_SOURCES
classic.c
dynamics.c

View File

@ -33,27 +33,29 @@
class Achievement;
/** This is the base class for storing the definition of an achievement, e.g.
/** This is the base class for storing the definition of an achievement, e.g.
* title, description (which is common for all achievements), but also how
* to achieve this achievement.
* \ingroup achievements
*/
* \ingroup achievements
*/
class AchievementInfo
{
public:
/** Some handy names for the various achievements. */
enum { ACHIEVE_COLUMBUS = 1,
ACHIEVE_FIRST = ACHIEVE_COLUMBUS,
ACHIEVE_STRIKE = 2,
ACHIEVE_ARCH_ENEMY = 3,
ACHIEVE_MARATHONER = 4,
ACHIEVE_LAST = ACHIEVE_MARATHONER
enum { ACHIEVE_COLUMBUS = 1,
ACHIEVE_FIRST = ACHIEVE_COLUMBUS,
ACHIEVE_STRIKE = 2,
ACHIEVE_ARCH_ENEMY = 3,
ACHIEVE_MARATHONER = 4,
ACHIEVE_SKIDDING = 5,
ACHIEVE_GOLD_DRIVER = 6,
ACHIEVE_POWERUP_LOVER = 7
};
/** Achievement check type:
/** Achievement check type:
* ALL_AT_LEAST: All goal values must be reached (or exceeded).
* ONE_AT_LEAST: At least one current value reaches or exceedes the goal.
*/
enum AchievementCheckType
enum AchievementCheckType
{
AC_ALL_AT_LEAST,
AC_ONE_AT_LEAST

View File

@ -314,16 +314,6 @@ SFXBase* SFXManager::createSoundSource(SFXBuffer* buffer,
return sfx;
} // createSoundSource
//----------------------------------------------------------------------------
void SFXManager::dump()
{
for(int n=0; n<(int)m_all_sfx.size(); n++)
{
Log::debug("SFXManager", "Sound %i : %s \n", n, m_all_sfx[n]->getBuffer()->getFileName().c_str());
}
}
//----------------------------------------------------------------------------
SFXBase* SFXManager::createSoundSource(const std::string &name,
const bool addToSFXList)

View File

@ -63,69 +63,77 @@ PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
static bool is_gl_init = false;
//#define ARB_DEBUG_OUTPUT
#ifdef DEBUG
#define ARB_DEBUG_OUTPUT
#endif
#ifdef ARB_DEBUG_OUTPUT
static
void debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
static void
#ifdef WIN32
CALLBACK
#endif
debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length,
const GLchar* msg, const void *userparam)
{
switch(source)
{
case GL_DEBUG_SOURCE_API_ARB:
printf("[API]");
Log::warn("GLWrap", "OpenGL debug callback - API");
break;
case GL_DEBUG_SOURCE_WINDOW_SYSTEM_ARB:
printf("[WINDOW_SYSTEM]");
Log::warn("GLWrap", "OpenGL debug callback - WINDOW_SYSTEM");
break;
case GL_DEBUG_SOURCE_SHADER_COMPILER_ARB:
printf("[SHADER_COMPILER]");
Log::warn("GLWrap", "OpenGL debug callback - SHADER_COMPILER");
break;
case GL_DEBUG_SOURCE_THIRD_PARTY_ARB:
printf("[THIRD_PARTY]");
Log::warn("GLWrap", "OpenGL debug callback - THIRD_PARTY");
break;
case GL_DEBUG_SOURCE_APPLICATION_ARB:
printf("[APPLICATION]");
Log::warn("GLWrap", "OpenGL debug callback - APPLICATION");
break;
case GL_DEBUG_SOURCE_OTHER_ARB:
printf("[OTHER]");
Log::warn("GLWrap", "OpenGL debug callback - OTHER");
break;
}
switch(type)
{
case GL_DEBUG_TYPE_ERROR_ARB:
printf("[ERROR]");
Log::warn("GLWrap", " Error type : ERROR");
break;
case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
printf("[DEPRECATED_BEHAVIOR]");
Log::warn("GLWrap", " Error type : DEPRECATED_BEHAVIOR");
break;
case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
printf("[UNDEFINED_BEHAVIOR]");
Log::warn("GLWrap", " Error type : UNDEFINED_BEHAVIOR");
break;
case GL_DEBUG_TYPE_PORTABILITY_ARB:
printf("[PORTABILITY]");
Log::warn("GLWrap", " Error type : PORTABILITY");
break;
case GL_DEBUG_TYPE_PERFORMANCE_ARB:
printf("[PERFORMANCE]");
Log::warn("GLWrap", " Error type : PERFORMANCE");
break;
case GL_DEBUG_TYPE_OTHER_ARB:
printf("[OTHER]");
Log::warn("GLWrap", " Error type : OTHER");
break;
}
switch(severity)
{
case GL_DEBUG_SEVERITY_HIGH_ARB:
printf("[HIGH]");
Log::warn("GLWrap", " Severity : HIGH");
break;
case GL_DEBUG_SEVERITY_MEDIUM_ARB:
printf("[MEDIUM]");
Log::warn("GLWrap", " Severity : MEDIUM");
break;
case GL_DEBUG_SEVERITY_LOW_ARB:
printf("[LOW]");
Log::warn("GLWrap", " Severity : LOW");
break;
}
printf("%s\n", msg);
if (msg)
Log::warn("GLWrap", " Message : %s", msg);
}
#endif
@ -192,13 +200,13 @@ void initGL()
#endif
#endif
#ifdef ARB_DEBUG_OUTPUT
glDebugMessageCallbackARB((GLDEBUGPROCARB)debugCallback, NULL);
// FIXME!!! glDebugMessageCallbackARB((GLDEBUGPROCARB)debugCallback, NULL);
#endif
}
// Mostly from shader tutorial
static
GLuint LoadShader(const char * file, unsigned type) {
static GLuint LoadShader(const char * file, unsigned type)
{
GLuint Id = glCreateShader(type);
std::string Code = "#version 330\n";
std::ifstream Stream(file, std::ios::in);
@ -218,7 +226,8 @@ GLuint LoadShader(const char * file, unsigned type) {
glCompileShader(Id);
glGetShaderiv(Id, GL_COMPILE_STATUS, &Result);
if (Result == GL_FALSE) {
if (Result == GL_FALSE)
{
glGetShaderiv(Id, GL_INFO_LOG_LENGTH, &InfoLogLength);
char *ErrorMessage = new char[InfoLogLength];
glGetShaderInfoLog(Id, InfoLogLength, NULL, ErrorMessage);
@ -226,10 +235,17 @@ GLuint LoadShader(const char * file, unsigned type) {
delete[] ErrorMessage;
}
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return Id;
}
GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_path) {
GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_path)
{
GLuint VertexShaderID = LoadShader(vertex_file_path, GL_VERTEX_SHADER);
GLuint FragmentShaderID = LoadShader(fragment_file_path, GL_FRAGMENT_SHADER);
@ -252,10 +268,17 @@ GLuint LoadProgram(const char * vertex_file_path, const char * fragment_file_pat
glDeleteShader(VertexShaderID);
glDeleteShader(FragmentShaderID);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return ProgramID;
}
GLuint LoadProgram(const char * vertex_file_path, const char * geometry_file_path, const char * fragment_file_path) {
GLuint LoadProgram(const char * vertex_file_path, const char * geometry_file_path, const char * fragment_file_path)
{
GLuint VertexShaderID = LoadShader(vertex_file_path, GL_VERTEX_SHADER);
GLuint FragmentShaderID = LoadShader(fragment_file_path, GL_FRAGMENT_SHADER);
GLuint GeometryShaderID = LoadShader(geometry_file_path, GL_GEOMETRY_SHADER);
@ -280,11 +303,18 @@ GLuint LoadProgram(const char * vertex_file_path, const char * geometry_file_pat
glDeleteShader(VertexShaderID);
glDeleteShader(GeometryShaderID);
glDeleteShader(FragmentShaderID);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return ProgramID;
}
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount) {
GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsigned varyingscount)
{
GLuint Shader = LoadShader(vertex_file_path, GL_VERTEX_SHADER);
GLuint Program = glCreateProgram();
glAttachShader(Program, Shader);
@ -294,7 +324,8 @@ GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsi
GLint Result = GL_FALSE;
int InfoLogLength;
glGetProgramiv(Program, GL_LINK_STATUS, &Result);
if (Result == GL_FALSE) {
if (Result == GL_FALSE)
{
glGetProgramiv(Program, GL_INFO_LOG_LENGTH, &InfoLogLength);
char *ErrorMessage = new char[InfoLogLength];
glGetProgramInfoLog(Program, InfoLogLength, NULL, ErrorMessage);
@ -302,14 +333,23 @@ GLuint LoadTFBProgram(const char * vertex_file_path, const char **varyings, unsi
delete[] ErrorMessage;
}
glDeleteShader(Shader);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
return Program;
}
GLuint getTextureGLuint(irr::video::ITexture *tex) {
GLuint getTextureGLuint(irr::video::ITexture *tex)
{
return static_cast<irr::video::COpenGLTexture*>(tex)->getOpenGLTextureName();
}
GLuint getDepthTexture(irr::video::ITexture *tex) {
GLuint getDepthTexture(irr::video::ITexture *tex)
{
assert(tex->isRenderTarget());
return static_cast<irr::video::COpenGLFBOTexture*>(tex)->DepthBufferTexture;
}
@ -322,47 +362,68 @@ void setTexture(unsigned TextureUnit, GLuint TextureId, GLenum MagFilter, GLenum
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, MinFilter);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, allowAF ? UserConfigParams::m_anisotropic : 0);
int aniso = UserConfigParams::m_anisotropic;
if (aniso == 0) aniso = 1;
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, allowAF ? (float)aniso : 1.0f);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
static void drawTexColoredQuad(const video::ITexture *texture, const video::SColor *col, float width, float height,
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
float tex_width, float tex_height)
{
unsigned colors[] = {
col[0].getRed(), col[0].getGreen(), col[0].getBlue(), col[0].getAlpha(),
col[1].getRed(), col[1].getGreen(), col[1].getBlue(), col[1].getAlpha(),
col[2].getRed(), col[2].getGreen(), col[2].getBlue(), col[2].getAlpha(),
col[3].getRed(), col[3].getGreen(), col[3].getBlue(), col[3].getAlpha(),
};
unsigned colors[] = {
col[0].getRed(), col[0].getGreen(), col[0].getBlue(), col[0].getAlpha(),
col[1].getRed(), col[1].getGreen(), col[1].getBlue(), col[1].getAlpha(),
col[2].getRed(), col[2].getGreen(), col[2].getBlue(), col[2].getAlpha(),
col[3].getRed(), col[3].getGreen(), col[3].getBlue(), col[3].getAlpha(),
};
glBindBuffer(GL_ARRAY_BUFFER, UIShader::ColoredTextureRectShader::colorvbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, 16 * sizeof(unsigned), colors);
glBindBuffer(GL_ARRAY_BUFFER, UIShader::ColoredTextureRectShader::colorvbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, 16 * sizeof(unsigned), colors);
glUseProgram(UIShader::ColoredTextureRectShader::Program);
glBindVertexArray(UIShader::ColoredTextureRectShader::vao);
glUseProgram(UIShader::ColoredTextureRectShader::Program);
glBindVertexArray(UIShader::ColoredTextureRectShader::vao);
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
void drawTexQuad(const video::ITexture *texture, float width, float height,
float center_pos_x, float center_pos_y, float tex_center_pos_x, float tex_center_pos_y,
float tex_width, float tex_height)
{
glUseProgram(UIShader::TextureRectShader::Program);
glBindVertexArray(UIShader::TextureRectShader::vao);
glUseProgram(UIShader::TextureRectShader::Program);
glBindVertexArray(UIShader::TextureRectShader::vao);
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
setTexture(0, static_cast<const irr::video::COpenGLTexture*>(texture)->getOpenGLTextureName(), GL_LINEAR, GL_LINEAR);
UIShader::TextureRectShader::setUniforms(center_pos_x, center_pos_y, width, height, tex_center_pos_x, tex_center_pos_y, tex_width, tex_height, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
@ -403,7 +464,8 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
float tex_height = sourceRect.LowerRightCorner.Y - sourceRect.UpperLeftCorner.Y;
tex_height /= ss.Height * 2.;
if (texture->isRenderTarget()) {
if (texture->isRenderTarget())
{
tex_height = - tex_height;
}
@ -443,6 +505,12 @@ void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect
if (clipRect)
glDisable(GL_SCISSOR_TEST);
glUseProgram(0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}
void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
@ -501,4 +569,10 @@ void GL32_draw2DRectangle(video::SColor color, const core::rect<s32>& position,
if (clip)
glDisable(GL_SCISSOR_TEST);
glUseProgram(0);
GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
Log::warn("IrrDriver", "GLWrap : OpenGL error %i\n", glErr);
}
}

View File

@ -39,6 +39,10 @@ ParticleSystemProxy::ParticleSystemProxy(bool createDefaultEmitter,
glGenVertexArrays(1, &non_current_rendering_vao);
size_increase_factor = 0.;
m_color_from[0] = m_color_from[1] = m_color_from[2] = 1.0;
m_color_to[0] = m_color_to[1] = m_color_to[2] = 1.0;
// We set these later but avoid coverity report them
heighmapbuffer = 0;
heightmaptexture = 0;
@ -82,11 +86,8 @@ ParticleSystemProxy::~ParticleSystemProxy()
}
void ParticleSystemProxy::setAlphaAdditive(bool val) { m_alpha_additive = val; }
void ParticleSystemProxy::setIncreaseFactor(float val) { size_increase_factor = val; }
void ParticleSystemProxy::setFlip() {
void ParticleSystemProxy::setFlip()
{
flip = true;
float *quaternions = new float[4 * count];
for (unsigned i = 0; i < count; i++)
@ -114,7 +115,8 @@ void ParticleSystemProxy::setFlip() {
}
void ParticleSystemProxy::setHeightmap(const std::vector<std::vector<float> > &hm,
float f1, float f2, float f3, float f4) {
float f1, float f2, float f3, float f4)
{
track_x = f1, track_z = f2, track_x_len = f3, track_z_len = f4;
unsigned width = hm.size();
@ -189,7 +191,8 @@ void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePoin
{
ParticleData *particles = new ParticleData[count], *initialvalue = new ParticleData[count];
for (unsigned i = 0; i < count; i++) {
for (unsigned i = 0; i < count; i++)
{
particles[i].PositionX = 0;
particles[i].PositionY = 0;
particles[i].PositionZ = 0;
@ -300,6 +303,7 @@ void ParticleSystemProxy::FlipParticleVAOBind(GLuint PositionBuffer, GLuint Quat
glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_rotationvec);
glEnableVertexAttribArray(ParticleShader::FlipParticleRender::attrib_anglespeed);
glBindBuffer(GL_ARRAY_BUFFER, QuaternionBuffer);
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_rotationvec, 3, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_anglespeed, 1, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(3 * sizeof(float)));
@ -307,6 +311,7 @@ void ParticleSystemProxy::FlipParticleVAOBind(GLuint PositionBuffer, GLuint Quat
glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer);
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_quadcorner, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer);
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_pos, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0);
glVertexAttribPointer(ParticleShader::FlipParticleRender::attrib_lf, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float)));
@ -330,6 +335,7 @@ void ParticleSystemProxy::SimpleParticleVAOBind(GLuint PositionBuffer)
glBindBuffer(GL_ARRAY_BUFFER, quad_vertex_buffer);
glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_quadcorner, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_texcoord, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (GLvoid *)(2 * sizeof(float)));
glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer);
glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_pos, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), 0);
glVertexAttribPointer(ParticleShader::SimpleParticleRender::attrib_lf, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid *)(3 * sizeof(float)));
@ -364,19 +370,22 @@ void ParticleSystemProxy::SimpleSimulationBind(GLuint PositionBuffer, GLuint Ini
void ParticleSystemProxy::HeightmapSimulationBind(GLuint PositionBuffer, GLuint InitialValuesBuffer)
{
// Position buffer
glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_position);
glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_lifetime);
glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_velocity);
// glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_size);
glBindBuffer(GL_ARRAY_BUFFER, PositionBuffer);
glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0);
glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float)));
glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_velocity, 4, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(4 * sizeof(float)));
//glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_size, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(7 * sizeof(float)));
// Initial values buffer
glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_position);
glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_lifetime);
glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_velocity);
glEnableVertexAttribArray(ParticleShader::HeightmapSimulationShader::attrib_initial_size);
glBindBuffer(GL_ARRAY_BUFFER, InitialValuesBuffer);
glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_position, 3, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)0);
glVertexAttribPointer(ParticleShader::HeightmapSimulationShader::attrib_initial_lifetime, 1, GL_FLOAT, GL_FALSE, sizeof(ParticleData), (GLvoid*)(3 * sizeof(float)));
@ -534,7 +543,8 @@ void ParticleSystemProxy::drawNotFlip()
setTexture(0, texture, GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR);
setTexture(1, static_cast<video::COpenGLFBOTexture *>(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH))->DepthBufferTexture, GL_NEAREST, GL_NEAREST);
ParticleShader::SimpleParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1);
ParticleShader::SimpleParticleRender::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(),
irr_driver->getInvProjMatrix(), screen[0], screen[1], 0, 1, this);
glBindVertexArray(current_rendering_vao);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);

View File

@ -19,6 +19,8 @@ protected:
GLuint current_rendering_flip_vao, non_current_rendering_flip_vao;
bool m_alpha_additive, has_height_map, flip;
float size_increase_factor, track_x, track_z, track_x_len, track_z_len;
float m_color_from[3];
float m_color_to[3];
static GLuint quad_vertex_buffer;
@ -55,8 +57,12 @@ public:
virtual void setEmitter(scene::IParticleEmitter* emitter);
virtual void render();
virtual void OnRegisterSceneNode();
void setAlphaAdditive(bool);
void setIncreaseFactor(float);
void setAlphaAdditive(bool val) { m_alpha_additive = val; }
void setIncreaseFactor(float val) { size_increase_factor = val; }
void setColorFrom(float r, float g, float b) { m_color_from[0] = r; m_color_from[1] = g; m_color_from[2] = b; }
void setColorTo(float r, float g, float b) { m_color_to[0] = r; m_color_to[1] = g; m_color_to[2] = b; }
const float* getColorFrom() const { return m_color_from; }
const float* getColorTo() const { return m_color_to; }
void setHeightmap(const std::vector<std::vector<float> >&, float, float, float, float);
void setFlip();
};

View File

@ -248,6 +248,40 @@ protected:
core::vector2df ScaleFactor;
};
// ============================================================================
class ColorAffector : public scene::IParticleAffector
{
protected:
core::vector3df m_color_from;
core::vector3df m_color_to;
public:
ColorAffector(const core::vector3df& colorFrom, const core::vector3df& colorTo) :
m_color_from(colorFrom), m_color_to(colorTo)
{
}
virtual void affect(u32 now, scene::SParticle *particlearray, u32 count)
{
for (u32 i = 0; i<count; i++)
{
const u32 maxdiff = particlearray[i].endTime - particlearray[i].startTime;
const u32 curdiff = now - particlearray[i].startTime;
const f32 timefraction = (f32)curdiff / maxdiff;
core::vector3df curr_color = m_color_from + (m_color_to - m_color_from)* timefraction;
particlearray[i].color = video::SColor(255, (int)curr_color.X, (int)curr_color.Y, (int)curr_color.Z);
}
}
virtual scene::E_PARTICLE_AFFECTOR_TYPE getType() const
{
return scene::EPAT_SCALE;
}
};
// ============================================================================
@ -487,7 +521,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
{
m_emitter = m_node->createPointEmitter(velocity,
type->getMinRate(), type->getMaxRate(),
type->getMinColor(), type->getMaxColor(),
type->getMinColor(), type->getMinColor(),
lifeTimeMin, lifeTimeMax,
m_particle_type->getAngleSpread() /* angle */
);
@ -503,7 +537,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
box_size_x, box_size_y, -0.6f - type->getBoxSizeZ()),
velocity,
type->getMinRate(), type->getMaxRate(),
type->getMinColor(), type->getMaxColor(),
type->getMinColor(), type->getMinColor(),
lifeTimeMin, lifeTimeMax,
m_particle_type->getAngleSpread()
);
@ -536,7 +570,7 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
m_particle_type->getSphereRadius(),
velocity,
type->getMinRate(), type->getMaxRate(),
type->getMinColor(), type->getMaxColor(),
type->getMinColor(), type->getMinColor(),
lifeTimeMin, lifeTimeMax,
m_particle_type->getAngleSpread()
);
@ -600,6 +634,38 @@ void ParticleEmitter::setParticleType(const ParticleKind* type)
}
}
if (type->getMinColor() != type->getMaxColor())
{
if (m_is_glsl)
{
video::SColor color_from = type->getMinColor();
static_cast<ParticleSystemProxy *>(m_node)->setColorFrom(color_from.getRed() / 255.0f,
color_from.getGreen() / 255.0f,
color_from.getBlue() / 255.0f);
video::SColor color_to = type->getMaxColor();
static_cast<ParticleSystemProxy *>(m_node)->setColorTo(color_to.getRed() / 255.0f,
color_to.getGreen() / 255.0f,
color_to.getBlue() / 255.0f);
}
else
{
video::SColor color_from = type->getMinColor();
core::vector3df color_from_v = core::vector3df(color_from.getRed(),
color_from.getGreen(),
color_from.getBlue());
video::SColor color_to = type->getMaxColor();
core::vector3df color_to_v = core::vector3df(color_to.getRed(),
color_to.getGreen(),
color_to.getBlue());
ColorAffector* affector = new ColorAffector(color_from_v, color_to_v);
m_node->addAffector(affector);
affector->drop();
}
}
const float windspeed = type->getWindSpeed();
if (windspeed > 0.01f)
{

View File

@ -743,50 +743,11 @@ void IrrDriver::renderGlow(video::SOverrideMaterial &overridemat,
}
// ----------------------------------------------------------------------------
#define MAXLIGHT 16 // to be adjusted in pointlight.frag too
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
static LightShader::PointLightInfo PointLightsInfo[MAXLIGHT];
static GLuint pointlightvbo = 0;
static GLuint pointlightsvao = 0;
struct PointLightInfo
{
float posX;
float posY;
float posZ;
float energy;
float red;
float green;
float blue;
float padding;
};
void createPointLightVAO()
{
glGenVertexArrays(1, &pointlightsvao);
glBindVertexArray(pointlightsvao);
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Corner);
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glGenBuffers(1, &pointlightvbo);
glBindBuffer(GL_ARRAY_BUFFER, pointlightvbo);
glBufferData(GL_ARRAY_BUFFER, MAXLIGHT * sizeof(PointLightInfo), 0, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Position);
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Position, 3, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), 0);
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Energy);
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Energy, 1, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), (GLvoid*)(3 * sizeof(float)));
glEnableVertexAttribArray(MeshShader::PointLightShader::attrib_Color);
glVertexAttribPointer(MeshShader::PointLightShader::attrib_Color, 3, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), (GLvoid*)(4 * sizeof(float)));
glVertexAttribDivisor(MeshShader::PointLightShader::attrib_Position, 1);
glVertexAttribDivisor(MeshShader::PointLightShader::attrib_Energy, 1);
glVertexAttribDivisor(MeshShader::PointLightShader::attrib_Color, 1);
}
static void renderPointLights()
static void renderPointLights(unsigned count)
{
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
@ -794,23 +755,18 @@ static void renderPointLights()
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glUseProgram(MeshShader::PointLightShader::Program);
glBindVertexArray(pointlightsvao);
glUseProgram(LightShader::PointLightShader::Program);
glBindVertexArray(LightShader::PointLightShader::vao);
glBindBuffer(GL_ARRAY_BUFFER, LightShader::PointLightShader::vbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, count * sizeof(LightShader::PointLightInfo), PointLightsInfo);
setTexture(0, getTextureGLuint(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
setTexture(1, getDepthTexture(irr_driver->getRTT(RTT_NORMAL_AND_DEPTH)), GL_NEAREST, GL_NEAREST);
MeshShader::PointLightShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 200, 0, 1);
LightShader::PointLightShader::setUniforms(irr_driver->getViewMatrix(), irr_driver->getProjMatrix(), irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 200, 0, 1);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, MAXLIGHT);
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, count);
}
PointLightInfo PointLightsInfo[MAXLIGHT];
void IrrDriver::renderLights(const core::aabbox3df& cambox,
scene::ICameraSceneNode * const camnode,
video::SOverrideMaterial &overridemat,
@ -848,7 +804,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
const core::vector3df &lightpos = (m_lights[i]->getAbsolutePosition() - campos);
unsigned idx = (unsigned)(lightpos.getLength() / 10);
if (idx > 14)
continue;
idx = 14;
BucketedLN[idx].push_back(m_lights[i]);
}
@ -895,17 +851,7 @@ void IrrDriver::renderLights(const core::aabbox3df& cambox,
lightnum++;
// Fill lights
for (; lightnum < MAXLIGHT; lightnum++) {
PointLightsInfo[lightnum].energy = 0;
}
if (!pointlightsvao)
createPointLightVAO();
glBindVertexArray(pointlightsvao);
glBindBuffer(GL_ARRAY_BUFFER, pointlightvbo);
glBufferSubData(GL_ARRAY_BUFFER, 0, MAXLIGHT * sizeof(PointLightInfo), PointLightsInfo);
renderPointLights();
renderPointLights(MIN2(lightnum, MAXLIGHT));
if (SkyboxCubeMap)
m_post_processing->renderDiffuseEnvMap(blueSHCoeff, greenSHCoeff, redSHCoeff);
// Handle SSAO
@ -992,9 +938,6 @@ static void createcubevao()
glBufferData(GL_ELEMENT_ARRAY_BUFFER, 6 * 6 * sizeof(int), indices, GL_STATIC_DRAW);
}
#define MAX2(a, b) ((a) > (b) ? (a) : (b))
#define MIN2(a, b) ((a) > (b) ? (b) : (a))
static void getXYZ(GLenum face, float i, float j, float &x, float &y, float &z)
{
switch (face)

View File

@ -18,6 +18,7 @@
#include "graphics/callbacks.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/gpuparticles.hpp"
#include "graphics/shaders.hpp"
#include "io/file_manager.hpp"
#include "utils/log.hpp"
@ -269,7 +270,7 @@ void Shaders::loadShaders()
MeshShader::TransparentShader::init();
MeshShader::TransparentFogShader::init();
MeshShader::BillboardShader::init();
MeshShader::PointLightShader::init();
LightShader::PointLightShader::init();
MeshShader::DisplaceShader::init();
MeshShader::DisplaceMaskShader::init();
MeshShader::ShadowShader::init();
@ -872,6 +873,7 @@ namespace MeshShader
GLuint TransparentShader::Program;
GLuint TransparentShader::attrib_position;
GLuint TransparentShader::attrib_texcoord;
GLuint TransparentShader::attrib_color;
GLuint TransparentShader::uniform_MVP;
GLuint TransparentShader::uniform_TM;
GLuint TransparentShader::uniform_tex;
@ -881,6 +883,7 @@ namespace MeshShader
Program = LoadProgram(file_manager->getAsset("shaders/transparent.vert").c_str(), file_manager->getAsset("shaders/transparent.frag").c_str());
attrib_position = glGetAttribLocation(Program, "Position");
attrib_texcoord = glGetAttribLocation(Program, "Texcoord");
attrib_color = glGetAttribLocation(Program, "Color");
uniform_MVP = glGetUniformLocation(Program, "ModelViewProjectionMatrix");
uniform_TM = glGetUniformLocation(Program, "TextureMatrix");
uniform_tex = glGetUniformLocation(Program, "tex");
@ -940,47 +943,6 @@ namespace MeshShader
glUniformMatrix4fv(uniform_ipvmat, 1, GL_FALSE, ipvmat.pointer());
glUniform1i(uniform_tex, TU_tex);
}
GLuint PointLightShader::Program;
GLuint PointLightShader::attrib_Position;
GLuint PointLightShader::attrib_Color;
GLuint PointLightShader::attrib_Energy;
GLuint PointLightShader::attrib_Corner;
GLuint PointLightShader::uniform_ntex;
GLuint PointLightShader::uniform_dtex;
GLuint PointLightShader::uniform_spec;
GLuint PointLightShader::uniform_screen;
GLuint PointLightShader::uniform_invproj;
GLuint PointLightShader::uniform_VM;
GLuint PointLightShader::uniform_PM;
void PointLightShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/pointlight.vert").c_str(), file_manager->getAsset("shaders/pointlight.frag").c_str());
attrib_Position = glGetAttribLocation(Program, "Position");
attrib_Color = glGetAttribLocation(Program, "Color");
attrib_Energy = glGetAttribLocation(Program, "Energy");
attrib_Corner = glGetAttribLocation(Program, "Corner");
uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_spec = glGetUniformLocation(Program, "spec");
uniform_invproj = glGetUniformLocation(Program, "invproj");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_VM = glGetUniformLocation(Program, "ViewMatrix");
uniform_PM = glGetUniformLocation(Program, "ProjectionMatrix");
}
void PointLightShader::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 &InvProjMatrix, const core::vector2df &screen, unsigned spec, unsigned TU_ntex, unsigned TU_dtex)
{
glUniform1f(uniform_spec, 200);
glUniform2f(uniform_screen, screen.X, screen.Y);
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniformMatrix4fv(uniform_VM, 1, GL_FALSE, ViewMatrix.pointer());
glUniformMatrix4fv(uniform_PM, 1, GL_FALSE, ProjMatrix.pointer());
glUniform1i(uniform_ntex, TU_ntex);
glUniform1i(uniform_dtex, TU_dtex);
}
GLuint BillboardShader::Program;
GLuint BillboardShader::attrib_corner;
@ -1189,6 +1151,76 @@ namespace MeshShader
}
}
namespace LightShader
{
GLuint PointLightShader::Program;
GLuint PointLightShader::attrib_Position;
GLuint PointLightShader::attrib_Color;
GLuint PointLightShader::attrib_Energy;
GLuint PointLightShader::attrib_Corner;
GLuint PointLightShader::uniform_ntex;
GLuint PointLightShader::uniform_dtex;
GLuint PointLightShader::uniform_spec;
GLuint PointLightShader::uniform_screen;
GLuint PointLightShader::uniform_invproj;
GLuint PointLightShader::uniform_VM;
GLuint PointLightShader::uniform_PM;
GLuint PointLightShader::vbo;
GLuint PointLightShader::vao;
void PointLightShader::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/pointlight.vert").c_str(), file_manager->getAsset("shaders/pointlight.frag").c_str());
attrib_Position = glGetAttribLocation(Program, "Position");
attrib_Color = glGetAttribLocation(Program, "Color");
attrib_Energy = glGetAttribLocation(Program, "Energy");
attrib_Corner = glGetAttribLocation(Program, "Corner");
uniform_ntex = glGetUniformLocation(Program, "ntex");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_spec = glGetUniformLocation(Program, "spec");
uniform_invproj = glGetUniformLocation(Program, "invproj");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_VM = glGetUniformLocation(Program, "ViewMatrix");
uniform_PM = glGetUniformLocation(Program, "ProjectionMatrix");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, SharedObject::billboardvbo);
glEnableVertexAttribArray(attrib_Corner);
glVertexAttribPointer(attrib_Corner, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), 0);
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glBufferData(GL_ARRAY_BUFFER, MAXLIGHT * sizeof(PointLightInfo), 0, GL_DYNAMIC_DRAW);
glEnableVertexAttribArray(attrib_Position);
glVertexAttribPointer(attrib_Position, 3, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), 0);
glEnableVertexAttribArray(attrib_Energy);
glVertexAttribPointer(attrib_Energy, 1, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), (GLvoid*)(3 * sizeof(float)));
glEnableVertexAttribArray(attrib_Color);
glVertexAttribPointer(attrib_Color, 3, GL_FLOAT, GL_FALSE, sizeof(PointLightInfo), (GLvoid*)(4 * sizeof(float)));
glVertexAttribDivisor(attrib_Position, 1);
glVertexAttribDivisor(attrib_Energy, 1);
glVertexAttribDivisor(attrib_Color, 1);
}
void PointLightShader::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 &InvProjMatrix, const core::vector2df &screen, unsigned spec, unsigned TU_ntex, unsigned TU_dtex)
{
glUniform1f(uniform_spec, 200);
glUniform2f(uniform_screen, screen.X, screen.Y);
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniformMatrix4fv(uniform_VM, 1, GL_FALSE, ViewMatrix.pointer());
glUniformMatrix4fv(uniform_PM, 1, GL_FALSE, ProjMatrix.pointer());
glUniform1i(uniform_ntex, TU_ntex);
glUniform1i(uniform_dtex, TU_dtex);
}
}
namespace ParticleShader
{
@ -1293,7 +1325,9 @@ namespace ParticleShader
GLuint SimpleParticleRender::uniform_dtex;
GLuint SimpleParticleRender::uniform_screen;
GLuint SimpleParticleRender::uniform_invproj;
GLuint SimpleParticleRender::uniform_color_from;
GLuint SimpleParticleRender::uniform_color_to;
void SimpleParticleRender::init()
{
Program = LoadProgram(file_manager->getAsset("shaders/particle.vert").c_str(), file_manager->getAsset("shaders/particle.frag").c_str());
@ -1310,9 +1344,15 @@ namespace ParticleShader
uniform_invproj = glGetUniformLocation(Program, "invproj");
uniform_screen = glGetUniformLocation(Program, "screen");
uniform_dtex = glGetUniformLocation(Program, "dtex");
uniform_color_from = glGetUniformLocation(Program, "color_from");
assert(uniform_color_from != -1);
uniform_color_to = glGetUniformLocation(Program, "color_to");
assert(uniform_color_to != -1);
}
void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex)
void SimpleParticleRender::setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_dtex,
const ParticleSystemProxy* particle_system)
{
glUniformMatrix4fv(uniform_invproj, 1, GL_FALSE, InvProjMatrix.pointer());
glUniform2f(uniform_screen, width, height);
@ -1320,6 +1360,11 @@ namespace ParticleShader
glUniformMatrix4fv(uniform_viewmatrix, 1, GL_FALSE, irr_driver->getViewMatrix().pointer());
glUniform1i(uniform_tex, TU_tex);
glUniform1i(uniform_dtex, TU_dtex);
const float* color_from = particle_system->getColorFrom();
const float* color_to = particle_system->getColorTo();
glUniform3f(uniform_color_from, color_from[0], color_from[1], color_from[2]);
glUniform3f(uniform_color_to, color_to[0], color_to[1], color_to[2]);
}
GLuint FlipParticleRender::Program;

View File

@ -23,6 +23,7 @@
typedef unsigned int GLuint;
using namespace irr;
class ParticleSystemProxy;
class SharedObject
{
@ -209,7 +210,7 @@ class TransparentShader
{
public:
static GLuint Program;
static GLuint attrib_position, attrib_texcoord;
static GLuint attrib_position, attrib_texcoord, attrib_color;
static GLuint uniform_MVP, uniform_TM, uniform_tex;
static void init();
@ -227,18 +228,6 @@ public:
static void setUniforms(const core::matrix4 &ModelViewProjectionMatrix, const core::matrix4 &TextureMatrix, const core::matrix4 &ipvmat, float fogmax, float startH, float endH, float start, float end, const core::vector3df &col, const core::vector3df &campos, unsigned TU_tex);
};
class PointLightShader
{
public:
static GLuint Program;
static GLuint attrib_Position, attrib_Energy, attrib_Color;
static GLuint attrib_Corner;
static GLuint uniform_ntex, uniform_dtex, uniform_spec, uniform_screen, uniform_invproj, uniform_VM, uniform_PM;
static void init();
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 &InvProjMatrix, const core::vector2df &screen, unsigned spec, unsigned TU_ntex, unsigned TU_dtex);
};
class BillboardShader
{
public:
@ -330,6 +319,38 @@ public:
}
#define MAXLIGHT 16
namespace LightShader
{
struct PointLightInfo
{
float posX;
float posY;
float posZ;
float energy;
float red;
float green;
float blue;
float padding;
};
class PointLightShader
{
public:
static GLuint Program;
static GLuint attrib_Position, attrib_Energy, attrib_Color;
static GLuint attrib_Corner;
static GLuint uniform_ntex, uniform_dtex, uniform_spec, uniform_screen, uniform_invproj, uniform_VM, uniform_PM;
static GLuint vbo;
static GLuint vao;
static void init();
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 &InvProjMatrix, const core::vector2df &screen, unsigned spec, unsigned TU_ntex, unsigned TU_dtex);
};
}
namespace ParticleShader
{
@ -361,10 +382,12 @@ class SimpleParticleRender
public:
static GLuint Program;
static GLuint attrib_pos, attrib_lf, attrib_quadcorner, attrib_texcoord, attrib_sz;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj;
static GLuint uniform_matrix, uniform_viewmatrix, uniform_tex, uniform_dtex, uniform_screen, uniform_invproj, uniform_color_from, uniform_color_to;
static void init();
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix, const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex, unsigned TU_normal_and_depth);
static void setUniforms(const core::matrix4 &ViewMatrix, const core::matrix4 &ProjMatrix,
const core::matrix4 InvProjMatrix, float width, float height, unsigned TU_tex,
unsigned TU_normal_and_depth, const ParticleSystemProxy* particle_system);
};
class FlipParticleRender

View File

@ -25,6 +25,7 @@
#include "karts/abstract_kart.hpp"
#include "karts/skidding.hpp"
#include "physics/btKart.hpp"
#include "graphics/stkmeshscenenode.hpp"
#include <IMeshSceneNode.h>
#include <SMesh.h>
@ -134,6 +135,8 @@ void SkidMarks::update(float dt, bool force_skid_marks,
// (till these skid mark quads are deleted)
m_left[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
m_right[m_current]->setHardwareMappingHint(scene::EHM_STATIC);
if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(m_nodes[m_current]))
stkm->setReloadEachFrame(false);
return;
}
@ -188,6 +191,8 @@ void SkidMarks::update(float dt, bool force_skid_marks,
m_material, m_avoid_z_fighting, custom_color);
new_mesh->addMeshBuffer(smq_right);
scene::IMeshSceneNode *new_node = irr_driver->addMesh(new_mesh);
if (STKMeshSceneNode* stkm = dynamic_cast<STKMeshSceneNode*>(new_node))
stkm->setReloadEachFrame(true);
#ifdef DEBUG
std::string debug_name = m_kart.getIdent()+" (skid-mark)";
new_node->setName(debug_name.c_str());

View File

@ -171,11 +171,13 @@ void STKAnimatedMesh::render()
computeMVP(ModelViewProjectionMatrix);
computeTIMV(TransposeInverseModelView);
glUseProgram(MeshShader::ObjectPass1Shader::Program);
if (!GeometricMesh[FPSM_DEFAULT].empty())
glUseProgram(MeshShader::ObjectPass1Shader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
drawSolidPass1(*GeometricMesh[FPSM_DEFAULT][i], FPSM_DEFAULT);
glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty())
glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
drawSolidPass1(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i], FPSM_ALPHA_REF_TEXTURE);
@ -184,36 +186,43 @@ void STKAnimatedMesh::render()
if (irr_driver->getPhase() == SOLID_LIT_PASS)
{
glUseProgram(MeshShader::ObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DEFAULT][i], SM_DEFAULT);
if (!ShadedMesh[SM_DEFAULT].empty())
glUseProgram(MeshShader::ObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DEFAULT][i], SM_DEFAULT);
glUseProgram(MeshShader::ObjectRefPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
drawSolidPass2(*ShadedMesh[SM_ALPHA_REF_TEXTURE][i], SM_ALPHA_REF_TEXTURE);
if (!ShadedMesh[SM_ALPHA_REF_TEXTURE].empty())
glUseProgram(MeshShader::ObjectRefPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
drawSolidPass2(*ShadedMesh[SM_ALPHA_REF_TEXTURE][i], SM_ALPHA_REF_TEXTURE);
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_RIMLIT][i], SM_RIMLIT);
if (!ShadedMesh[SM_RIMLIT].empty())
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_RIMLIT][i], SM_RIMLIT);
glUseProgram(MeshShader::ObjectUnlitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_UNLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_UNLIT][i], SM_UNLIT);
if (!ShadedMesh[SM_UNLIT].empty())
glUseProgram(MeshShader::ObjectUnlitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_UNLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_UNLIT][i], SM_UNLIT);
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DETAILS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DETAILS][i], SM_DETAILS);
if (!ShadedMesh[SM_DETAILS].empty())
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DETAILS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DETAILS][i], SM_DETAILS);
return;
return;
}
if (irr_driver->getPhase() == SHADOW_PASS)
{
glUseProgram(MeshShader::ShadowShader::Program);
if (!GeometricMesh[FPSM_DEFAULT].empty())
glUseProgram(MeshShader::ShadowShader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
drawShadow(*GeometricMesh[FPSM_DEFAULT][i]);
glUseProgram(MeshShader::RefShadowShader::Program);
if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty())
glUseProgram(MeshShader::RefShadowShader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
drawShadowRef(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]);
return;
@ -223,11 +232,13 @@ void STKAnimatedMesh::render()
{
computeMVP(ModelViewProjectionMatrix);
glUseProgram(MeshShader::BubbleShader::Program);
if (!TransparentMesh[TM_BUBBLE].empty())
glUseProgram(MeshShader::BubbleShader::Program);
for (unsigned i = 0; i < TransparentMesh[TM_BUBBLE].size(); i++)
drawBubble(*TransparentMesh[TM_BUBBLE][i], ModelViewProjectionMatrix);
glUseProgram(MeshShader::TransparentShader::Program);
if (!TransparentMesh[TM_DEFAULT].empty())
glUseProgram(MeshShader::TransparentShader::Program);
for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++)
drawTransparentObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix);
return;

View File

@ -213,6 +213,7 @@ void drawObjectPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjecti
MeshShader::ObjectPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -229,6 +230,7 @@ void drawObjectRefPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProje
MeshShader::ObjectRefPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix, 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -244,6 +246,7 @@ void drawGrassPass1(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
MeshShader::GrassPass1Shader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, windDir, 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -260,6 +263,7 @@ void drawNormalPass(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
MeshShader::NormalMapShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -286,6 +290,7 @@ void drawSphereMap(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
MeshShader::SphereMapShader::setUniforms(ModelViewProjectionMatrix, irr_driver->getViewMatrix().getTransposed(), TransposeInverseModelView, irr_driver->getInvProjMatrix(), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height));
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
if (!irr_driver->SkyboxCubeMap)
@ -365,6 +370,7 @@ void drawSplatting(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionM
MeshShader::SplattingShader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -390,6 +396,7 @@ void drawObjectRefPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
MeshShader::ObjectRefPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -416,6 +423,7 @@ void drawCaustics(const GLMesh &mesh, const core::matrix4 & ModelViewProjectionM
MeshShader::CausticsShader::setUniforms(ModelViewProjectionMatrix, dir, dir2, core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height));
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -441,6 +449,7 @@ void drawGrassPass2(const GLMesh &mesh, const core::matrix4 & ModelViewProjectio
MeshShader::GrassPass2Shader::setUniforms(ModelViewProjectionMatrix, windDir);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -454,6 +463,7 @@ void drawUntexturedObject(const GLMesh &mesh, const core::matrix4 &ModelViewProj
MeshShader::UntexturedObjectShader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -479,6 +489,7 @@ void drawObjectRimLimit(const GLMesh &mesh, const core::matrix4 &ModelViewProjec
MeshShader::ObjectRimLimitShader::setUniforms(ModelViewProjectionMatrix, TransposeInverseModelView, TextureMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -504,6 +515,7 @@ void drawObjectUnlit(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
MeshShader::ObjectUnlitShader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -531,6 +543,7 @@ void drawDetailledObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelView
MeshShader::DetailledObjectPass2Shader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -556,6 +569,7 @@ void drawObjectPass2(const GLMesh &mesh, const core::matrix4 &ModelViewProjectio
MeshShader::ObjectPass2Shader::setUniforms(ModelViewProjectionMatrix, TextureMatrix);
assert(mesh.vao_second_pass);
glBindVertexArray(mesh.vao_second_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -571,6 +585,7 @@ void drawTransparentObject(const GLMesh &mesh, const core::matrix4 &ModelViewPro
MeshShader::TransparentShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -601,6 +616,7 @@ void drawTransparentFogObject(const GLMesh &mesh, const core::matrix4 &ModelView
glUseProgram(MeshShader::TransparentFogShader::Program);
MeshShader::TransparentFogShader::setUniforms(ModelViewProjectionMatrix, TextureMatrix, irr_driver->getInvProjMatrix(), fogmax, startH, endH, start, end, col, Camera::getCamera(0)->getCameraSceneNode()->getAbsolutePosition(), 0);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -619,6 +635,7 @@ void drawBubble(const GLMesh &mesh, const core::matrix4 &ModelViewProjectionMatr
MeshShader::BubbleShader::setUniforms(ModelViewProjectionMatrix, 0, time, transparency);
assert(mesh.vao_first_pass);
glBindVertexArray(mesh.vao_first_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -637,6 +654,7 @@ void drawShadowRef(const GLMesh &mesh)
setTexture(0, mesh.textures[0], GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, true);
MeshShader::RefShadowShader::setUniforms(ShadowMVP, 0);
assert(mesh.vao_shadow_pass);
glBindVertexArray(mesh.vao_shadow_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -661,6 +679,7 @@ void drawShadow(const GLMesh &mesh)
MeshShader::ShadowShader::setUniforms(ShadowMVP);
assert(mesh.vao_shadow_pass);
glBindVertexArray(mesh.vao_shadow_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -796,9 +815,10 @@ void initvaostate(GLMesh &mesh, TransparentMaterial TranspMat)
break;
case TM_DEFAULT:
mesh.vao_first_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer,
MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, -1, mesh.Stride);
MeshShader::TransparentShader::attrib_position, MeshShader::TransparentShader::attrib_texcoord, -1, -1, -1, -1, MeshShader::TransparentShader::attrib_color, mesh.Stride);
break;
}
mesh.vao_glow_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::ColorizeShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
mesh.vao_displace_mask_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, -1, -1, -1, -1, -1, -1, mesh.Stride);
if (mesh.Stride >= 44)
mesh.vao_displace_pass = createVAO(mesh.vertex_buffer, mesh.index_buffer, MeshShader::DisplaceShader::attrib_position, MeshShader::DisplaceShader::attrib_texcoord, MeshShader::DisplaceShader::attrib_second_texcoord, -1, -1, -1, -1, mesh.Stride);

View File

@ -32,9 +32,15 @@ STKMeshSceneNode::STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent,
const irr::core::vector3df& scale) :
CMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale)
{
reload_each_frame = false;
createGLMeshes();
}
void STKMeshSceneNode::setReloadEachFrame(bool val)
{
reload_each_frame = val;
}
void STKMeshSceneNode::createGLMeshes()
{
for (u32 i = 0; i<Mesh->getMeshBufferCount(); ++i)
@ -132,11 +138,9 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
computeMVP(ModelViewProjectionMatrix);
MeshShader::ColorizeShader::setUniforms(ModelViewProjectionMatrix, cb->getRed(), cb->getGreen(), cb->getBlue());
if (mesh.vao_glow_pass != 0)
{
glBindVertexArray(mesh.vao_glow_pass);
glDrawElements(ptype, count, itype, 0);
}
assert(mesh.vao_glow_pass);
glBindVertexArray(mesh.vao_glow_pass);
glDrawElements(ptype, count, itype, 0);
}
void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
@ -158,6 +162,7 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
glUseProgram(MeshShader::DisplaceMaskShader::Program);
MeshShader::DisplaceMaskShader::setUniforms(ModelViewProjectionMatrix);
assert(mesh.vao_displace_mask_pass);
glBindVertexArray(mesh.vao_displace_mask_pass);
glDrawElements(ptype, count, itype, 0);
@ -169,6 +174,7 @@ void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
glUseProgram(MeshShader::DisplaceShader::Program);
MeshShader::DisplaceShader::setUniforms(ModelViewProjectionMatrix, ModelViewMatrix, core::vector2df(cb->getDirX(), cb->getDirY()), core::vector2df(cb->getDir2X(), cb->getDir2Y()), core::vector2df(UserConfigParams::m_width, UserConfigParams::m_height), 0, 1, 2);
assert(mesh.vao_displace_pass);
glBindVertexArray(mesh.vao_displace_pass);
glDrawElements(ptype, count, itype, 0);
}
@ -270,6 +276,41 @@ void STKMeshSceneNode::drawSolidPass2(const GLMesh &mesh, ShadedMaterial type)
}
}
void STKMeshSceneNode::updatevbo()
{
for (unsigned i = 0; i < Mesh->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = Mesh->getMeshBuffer(i);
if (!mb)
continue;
GLMesh &mesh = GLmeshes[i];
glBindVertexArray(0);
glBindBuffer(GL_ARRAY_BUFFER, mesh.vertex_buffer);
const void* vertices = mb->getVertices();
const u32 vertexCount = mb->getVertexCount();
const c8* vbuf = static_cast<const c8*>(vertices);
glBufferData(GL_ARRAY_BUFFER, vertexCount * mesh.Stride, vbuf, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh.index_buffer);
const void* indices = mb->getIndices();
mesh.IndexCount = mb->getIndexCount();
GLenum indexSize;
switch (mb->getIndexType())
{
case irr::video::EIT_16BIT:
indexSize = sizeof(u16);
break;
case irr::video::EIT_32BIT:
indexSize = sizeof(u32);
break;
default:
assert(0 && "Wrong index size");
}
glBufferData(GL_ELEMENT_ARRAY_BUFFER, mesh.IndexCount * indexSize, indices, GL_STATIC_DRAW);
}
}
void STKMeshSceneNode::render()
{
irr::video::IVideoDriver* driver = irr_driver->getVideoDriver();
@ -277,6 +318,9 @@ void STKMeshSceneNode::render()
if (!Mesh || !driver)
return;
if (reload_each_frame)
updatevbo();
bool isTransparentPass =
SceneManager->getSceneNodeRenderPass() == scene::ESNRP_TRANSPARENT;
@ -300,19 +344,23 @@ void STKMeshSceneNode::render()
computeMVP(ModelViewProjectionMatrix);
computeTIMV(TransposeInverseModelView);
glUseProgram(MeshShader::ObjectPass1Shader::Program);
if (!GeometricMesh[FPSM_DEFAULT].empty())
glUseProgram(MeshShader::ObjectPass1Shader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
drawSolidPass1(*GeometricMesh[FPSM_DEFAULT][i], FPSM_DEFAULT);
glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty())
glUseProgram(MeshShader::ObjectRefPass1Shader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
drawSolidPass1(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i], FPSM_ALPHA_REF_TEXTURE);
glUseProgram(MeshShader::NormalMapShader::Program);
if (!GeometricMesh[FPSM_NORMAL_MAP].empty())
glUseProgram(MeshShader::NormalMapShader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_NORMAL_MAP].size(); i++)
drawSolidPass1(*GeometricMesh[FPSM_NORMAL_MAP][i], FPSM_NORMAL_MAP);
glUseProgram(MeshShader::GrassPass1Shader::Program);
if (!GeometricMesh[FPSM_GRASS].empty())
glUseProgram(MeshShader::GrassPass1Shader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_GRASS].size(); i++)
drawSolidPass1(*GeometricMesh[FPSM_GRASS][i], FPSM_GRASS);
@ -321,56 +369,68 @@ void STKMeshSceneNode::render()
if (irr_driver->getPhase() == SOLID_LIT_PASS)
{
glUseProgram(MeshShader::ObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DEFAULT][i], SM_DEFAULT);
if (!ShadedMesh[SM_DEFAULT].empty())
glUseProgram(MeshShader::ObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DEFAULT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DEFAULT][i], SM_DEFAULT);
glUseProgram(MeshShader::ObjectRefPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
drawSolidPass2(*ShadedMesh[SM_ALPHA_REF_TEXTURE][i], SM_ALPHA_REF_TEXTURE);
if (!ShadedMesh[SM_ALPHA_REF_TEXTURE].empty())
glUseProgram(MeshShader::ObjectRefPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_ALPHA_REF_TEXTURE].size(); i++)
drawSolidPass2(*ShadedMesh[SM_ALPHA_REF_TEXTURE][i], SM_ALPHA_REF_TEXTURE);
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_RIMLIT][i], SM_RIMLIT);
if (!ShadedMesh[SM_RIMLIT].empty())
glUseProgram(MeshShader::ObjectRimLimitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_RIMLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_RIMLIT][i], SM_RIMLIT);
glUseProgram(MeshShader::SphereMapShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_SPHEREMAP].size(); i++)
drawSolidPass2(*ShadedMesh[SM_SPHEREMAP][i], SM_SPHEREMAP);
if (!ShadedMesh[SM_SPHEREMAP].empty())
glUseProgram(MeshShader::SphereMapShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_SPHEREMAP].size(); i++)
drawSolidPass2(*ShadedMesh[SM_SPHEREMAP][i], SM_SPHEREMAP);
glUseProgram(MeshShader::SplattingShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_SPLATTING].size(); i++)
drawSolidPass2(*ShadedMesh[SM_SPLATTING][i], SM_SPLATTING);
if (!ShadedMesh[SM_SPLATTING].empty())
glUseProgram(MeshShader::SplattingShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_SPLATTING].size(); i++)
drawSolidPass2(*ShadedMesh[SM_SPLATTING][i], SM_SPLATTING);
glUseProgram(MeshShader::GrassPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_GRASS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_GRASS][i], SM_GRASS);
if (!ShadedMesh[SM_GRASS].empty())
glUseProgram(MeshShader::GrassPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_GRASS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_GRASS][i], SM_GRASS);
glUseProgram(MeshShader::ObjectUnlitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_UNLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_UNLIT][i], SM_UNLIT);
if (!ShadedMesh[SM_UNLIT].empty())
glUseProgram(MeshShader::ObjectUnlitShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_UNLIT].size(); i++)
drawSolidPass2(*ShadedMesh[SM_UNLIT][i], SM_UNLIT);
glUseProgram(MeshShader::CausticsShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_CAUSTICS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_CAUSTICS][i], SM_CAUSTICS);
if (!ShadedMesh[SM_CAUSTICS].empty())
glUseProgram(MeshShader::CausticsShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_CAUSTICS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_CAUSTICS][i], SM_CAUSTICS);
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DETAILS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DETAILS][i], SM_DETAILS);
if (!ShadedMesh[SM_DETAILS].empty())
glUseProgram(MeshShader::DetailledObjectPass2Shader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_DETAILS].size(); i++)
drawSolidPass2(*ShadedMesh[SM_DETAILS][i], SM_DETAILS);
glUseProgram(MeshShader::UntexturedObjectShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_UNTEXTURED].size(); i++)
drawSolidPass2(*ShadedMesh[SM_UNTEXTURED][i], SM_UNTEXTURED);
if (!ShadedMesh[SM_UNTEXTURED].empty())
glUseProgram(MeshShader::UntexturedObjectShader::Program);
for (unsigned i = 0; i < ShadedMesh[SM_UNTEXTURED].size(); i++)
drawSolidPass2(*ShadedMesh[SM_UNTEXTURED][i], SM_UNTEXTURED);
return;
return;
}
if (irr_driver->getPhase() == SHADOW_PASS)
{
glUseProgram(MeshShader::ShadowShader::Program);
if (!GeometricMesh[FPSM_DEFAULT].empty())
glUseProgram(MeshShader::ShadowShader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_DEFAULT].size(); i++)
drawShadow(*GeometricMesh[FPSM_DEFAULT][i]);
glUseProgram(MeshShader::RefShadowShader::Program);
if (!GeometricMesh[FPSM_ALPHA_REF_TEXTURE].empty())
glUseProgram(MeshShader::RefShadowShader::Program);
for (unsigned i = 0; i < GeometricMesh[FPSM_ALPHA_REF_TEXTURE].size(); i++)
drawShadowRef(*GeometricMesh[FPSM_ALPHA_REF_TEXTURE][i]);
return;
@ -392,11 +452,13 @@ void STKMeshSceneNode::render()
{
computeMVP(ModelViewProjectionMatrix);
glUseProgram(MeshShader::BubbleShader::Program);
if (!TransparentMesh[TM_BUBBLE].empty())
glUseProgram(MeshShader::BubbleShader::Program);
for (unsigned i = 0; i < TransparentMesh[TM_BUBBLE].size(); i++)
drawBubble(*TransparentMesh[TM_BUBBLE][i], ModelViewProjectionMatrix);
glUseProgram(MeshShader::TransparentShader::Program);
if (!TransparentMesh[TM_DEFAULT].empty())
glUseProgram(MeshShader::TransparentShader::Program);
for (unsigned i = 0; i < TransparentMesh[TM_DEFAULT].size(); i++)
drawTransparentObject(*TransparentMesh[TM_DEFAULT][i], ModelViewProjectionMatrix, (*TransparentMesh[TM_DEFAULT][i]).TextureMatrix);
return;

View File

@ -23,15 +23,17 @@ protected:
void createGLMeshes();
void cleanGLMeshes();
void setFirstTimeMaterial();
void updatevbo();
bool isMaterialInitialized;
bool reload_each_frame;
public:
void setReloadEachFrame(bool);
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
const irr::core::vector3df& rotation = irr::core::vector3df(0, 0, 0),
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f));
virtual void render();
virtual void setMesh(irr::scene::IMesh* mesh);
void MovingTexture(unsigned, unsigned);
~STKMeshSceneNode();
};

View File

@ -723,20 +723,6 @@ namespace GUIEngine
std::vector<MenuMessage> gui_messages;
// ------------------------------------------------------------------------
Screen* getScreenNamed(const char* name)
{
const int screenCount = g_loaded_screens.size();
for (int n=0; n<screenCount; n++)
{
if (g_loaded_screens[n].getName() == name)
{
return g_loaded_screens.get(n);
}
}
return NULL;
} // getScreenNamed
// ------------------------------------------------------------------------
void showMessage(const wchar_t* message, const float time)
{
@ -800,13 +786,14 @@ namespace GUIEngine
{
return Private::small_font_height;
} // getSmallFontHeight
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
int getLargeFontHeight()
{
{
return Private::large_font_height;
} // getSmallFontHeight
// ------------------------------------------------------------------------
void clear()
{

View File

@ -170,7 +170,7 @@ namespace GUIEngine
inline Skin* getSkin() { return Private::g_skin; }
Screen* getScreenNamed(const char* name);
/** \return the height of the title font in pixels */
int getTitleFontHeight();

View File

@ -18,6 +18,9 @@
#include "items/powerup.hpp"
#include "achievements/achievement_info.hpp"
#include "config/player_manager.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_manager.hpp"
#include "config/stk_config.hpp"
@ -170,6 +173,14 @@ void Powerup::adjustSound()
*/
void Powerup::use()
{
// The player gets an achievement point for using a powerup
StateManager::ActivePlayer * player = m_owner->getController()->getPlayer();
if (m_type != PowerupManager::POWERUP_NOTHING &&
player != NULL && player->getConstProfile() == PlayerManager::get()->getCurrentPlayer())
{
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_POWERUP_LOVER, "poweruplover");
}
// Play custom kart sound when collectible is used //TODO: what about the bubble gum?
if (m_type != PowerupManager::POWERUP_NOTHING &&
m_type != PowerupManager::POWERUP_SWATTER &&
@ -237,7 +248,7 @@ void Powerup::use()
m_sound_use->play();
pos.setY(hit_point.getY()-0.05f);
ItemManager::get()->newItem(Item::ITEM_BUBBLEGUM, pos, normal, m_owner);
}
else // if the kart is looking forward, use the bubblegum as a shield

View File

@ -560,9 +560,17 @@ void KartProperties::getAllData(const XMLNode * root)
else if (s == "small") m_engine_sfx_type = "engine_small";
else
{
Log::warn("[KartProperties]", "Kart '%s' has invalid engine '%s'.",
m_name.c_str(), s.c_str());
m_engine_sfx_type = "engine_small";
if (sfx_manager->soundExist(s))
{
m_engine_sfx_type = s;
}
else
{
Log::error("[KartProperties]",
"Kart '%s' has an invalid engine '%s'.",
m_name.c_str(), s.c_str());
m_engine_sfx_type = "engine_small";
}
}
#ifdef WILL_BE_ENABLED_ONCE_DONE_PROPERLY

View File

@ -21,6 +21,8 @@
#ifdef SKID_DEBUG
# include "graphics/show_curve.hpp"
#endif
#include "achievements/achievement_info.hpp"
#include "config/player_manager.hpp"
#include "karts/kart.hpp"
#include "karts/kart_gfx.hpp"
#include "karts/kart_properties.hpp"
@ -412,6 +414,12 @@ void Skidding::update(float dt, bool is_on_ground,
bonus_speed, bonus_speed,
bonus_force, bonus_time,
/*fade-out-time*/ 1.0f);
StateManager::ActivePlayer *c = m_kart->getController()->getPlayer();
if (c && c->getConstProfile() == PlayerManager::get()->getCurrentPlayer())
{
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_SKIDDING, "skidding");
}
}
else {
m_kart->getKartGFX()

View File

@ -445,6 +445,7 @@ void World::terminateRace()
&best_player);
}
// Check achievements
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_COLUMBUS,
getTrack()->getIdent(), 1);
if (raceHasLaps())
@ -452,6 +453,39 @@ void World::terminateRace()
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_MARATHONER,
"laps", race_manager->getNumLaps());
}
Achievement *achiev = PlayerManager::getCurrentAchievementsStatus()->getAchievement(AchievementInfo::ACHIEVE_GOLD_DRIVER);
if (achiev)
{
std::string mode_name = getIdent(); // Get the race mode name
int winner_position = 1;
int opponents = achiev->getInfo()->getGoalValue("opponents"); // Get the required opponents number
if (mode_name == IDENT_FTL)
{
winner_position = 2;
opponents++;
}
for(unsigned int i = 0; i < kart_amount; i++)
{
// Retrieve the current player
StateManager::ActivePlayer* p = m_karts[i]->getController()->getPlayer();
if (p && p->getConstProfile() == PlayerManager::get()->getCurrentPlayer())
{
// Check if the player has won
if (m_karts[i]->getPosition() == winner_position && kart_amount > opponents )
{
// Update the achievement
mode_name = StringUtils::toLowerCase(mode_name);
if (achiev->getValue("opponents") <= 0)
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_GOLD_DRIVER,
"opponents", opponents);
PlayerManager::increaseAchievement(AchievementInfo::ACHIEVE_GOLD_DRIVER,
mode_name, 1);
}
}
} // for i < kart_amount
} // if (achiev)
PlayerManager::get()->getCurrentPlayer()->raceFinished();
if (m_race_gui) m_race_gui->clearAllMessages();

View File

@ -278,6 +278,24 @@ void UserInfoDialog::declineFriendRequest()
} // declineFriendRequest
// -----------------------------------------------------------------------------
/** Removes an existing friend.
*/
void UserInfoDialog::removeExistingFriend()
{
CurrentUser::get()->requestRemoveFriend(m_profile->getID());
} // removeExistingFriend
// -----------------------------------------------------------------------------
/** Removes a pending friend request.
*/
void UserInfoDialog::removePendingFriend()
{
CurrentUser::get()->requestCancelFriend(m_profile->getID());
} // removePendingFriend
// -----------------------------------------------------------------------------
GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& eventSource)
{
@ -304,10 +322,12 @@ GUIEngine::EventPropagation UserInfoDialog::processEvent(const std::string& even
}
else if(selection == m_remove_widget->m_properties[PROP_ID])
{
if(m_profile->getRelationInfo()->isPending())
CurrentUser::get()->requestCancelFriend(m_profile->getID());
if (m_profile->getRelationInfo() &&
m_profile->getRelationInfo()->isPending() )
removePendingFriend();
else
CurrentUser::get()->requestRemoveFriend(m_profile->getID());
removeExistingFriend();
m_processing = true;
m_options_widget->setDeactivated();
return GUIEngine::EVENT_BLOCK;

View File

@ -63,6 +63,8 @@ private:
void sendFriendRequest();
void acceptFriendRequest();
void declineFriendRequest();
void removeExistingFriend();
void removePendingFriend();
public:
UserInfoDialog(uint32_t showing_id, const core::stringw info = "", bool error = false, bool from_queue = false);

View File

@ -1056,25 +1056,6 @@ video::ITexture *QuadGraph::makeMiniMap(const core::dimension2du &origdimension,
return NULL;
}
if (!irr_driver->isGLSL())
return texture;
GaussianBlurProvider * const gacb = (GaussianBlurProvider *) irr_driver->getCallback(ES_GAUSSIAN3H);
gacb->setResolution(UserConfigParams::m_width, UserConfigParams::m_height);
ScreenQuad sq(irr_driver->getVideoDriver());
sq.getMaterial().MaterialType = irr_driver->getShader(ES_GAUSSIAN3H);
sq.setTexture(texture);
// Horizontal pass
sq.render(irr_driver->getRTT(RTT_TMP1));
// Vertical pass
sq.getMaterial().MaterialType = irr_driver->getShader(ES_GAUSSIAN3V);
sq.setTexture(irr_driver->getRTT(RTT_TMP1));
sq.render(texture);
return texture;
} // makeMiniMap

View File

@ -726,6 +726,16 @@ void TrackObjectPresentationActionTrigger::onTriggerItemApproached(Item* who)
new TutorialMessageDialog(_("Collect gift boxes, and fire the weapon with <%s> to blow away these boxes!", fire),
true);
}
else if (m_action == "tutorial_backgiftboxes")
{
m_action_active = false;
InputDevice* device = input_manager->getDeviceList()->getLatestUsedDevice();
DeviceConfig* config = device->getConfiguration();
irr::core::stringw fire = config->getBindingAsString(PA_FIRE);
new TutorialMessageDialog(_("Press <B> to look behind, to fire the weapon with <%s> while pressing <B> to to fire behind!", fire),
true);
}
else if (m_action == "tutorial_nitro_collect")
{
m_action_active = false;