2
0
Эх сурвалжийг харах

- Fixed bug in vert weights export
- Fixed bug in TGA loading
- Added sanity check in MeshNode
- Other fixes

Panagiotis Christopoulos Charitos 15 жил өмнө
parent
commit
5daf7e870e

+ 2 - 2
blenderscripts/mesh.py

@@ -142,8 +142,8 @@ def updateAnkiVertsWithBoneWeights(mesh, skeleton, ankiVerts):
 		while nid != -1:
 			# copy vert weight data
 			ankiVerts[nid].bonesNum = ankiVerts[cid].bonesNum
-			ankiVerts[nid].boneIds = copy.copy(ankiVerts[cid].boneIds)
-			ankiVerts[nid].weights = copy.copy(ankiVerts[cid].weights)
+			ankiVerts[nid].boneIds = deepcopy(ankiVerts[cid].boneIds)
+			ankiVerts[nid].weights = deepcopy(ankiVerts[cid].weights)
 			
 			cid = nid
 			nid = ankiVerts[nid].nextId

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 400 - 402
build/debug/Makefile


+ 39 - 37
shaders/MsMpGeneric.glsl

@@ -5,14 +5,14 @@
  * in all the buffers
  */
  
-#if defined( DIFFUSE_MAPPING ) || defined( NORMAL_MAPPING ) || defined( SPECULAR_MAPPING )
+#if defined(DIFFUSE_MAPPING) || defined(NORMAL_MAPPING) || defined(SPECULAR_MAPPING)
 	#define NEEDS_TEX_MAPPING 1
 #else
 	#define NEEDS_TEX_MAPPING 0
 #endif
 
 
-#if defined( NORMAL_MAPPING ) || defined( PARALLAX_MAPPING )
+#if defined(NORMAL_MAPPING) || defined(PARALLAX_MAPPING)
 	#define NEEDS_TANGENT 1
 #else
 	#define NEEDS_TANGENT 0
@@ -21,7 +21,9 @@
 
 #pragma anki vertShaderBegins
 
-#pragma anki include "shaders/hw_skinning.glsl"
+#if defined(HARDWARE_SKINNING)
+	#pragma anki include "shaders/hw_skinning.glsl"
+#endif
 
 // attributes
 attribute vec3 position;
@@ -54,19 +56,19 @@ void main()
 	// calculate the vert pos, normal and tangent
 
 	// if we have hardware skinning then:
-	#if defined( HARDWARE_SKINNING )
+	#if defined(HARDWARE_SKINNING)
 		mat3 _rot;
 		vec3 _tsl;
 
-		HWSkinning( _rot, _tsl );
+		HWSkinning(_rot, _tsl);
 
-		normal_v2f = normalMat * ( _rot * normal );
+		normal_v2f = normalMat * (_rot * normal);
 
 		#if NEEDS_TANGENT
-			tangent_v2f = normalMat * ( _rot * vec3(tangent) );
+			tangent_v2f = normalMat * (_rot * vec3(tangent));
 		#endif
 
-		vec3 pos_lspace = ( _rot * position) + _tsl;
+		vec3 pos_lspace = (_rot * position) + _tsl;
 		gl_Position =  modelViewProjectionMat * vec4(pos_lspace, 1.0);
 
 	// if DONT have hardware skinning
@@ -93,8 +95,8 @@ void main()
 	#endif
 
 
-	#if defined( ENVIRONMENT_MAPPING ) || defined( PARALLAX_MAPPING )
-		vertPosEyeSpace_v2f = vec3( modelViewMat * vec4(position, 1.0) );
+	#if defined(ENVIRONMENT_MAPPING) || defined(PARALLAX_MAPPING)
+		vertPosEyeSpace_v2f = vec3(modelViewMat * vec4(position, 1.0));
 	#endif
 }
 
@@ -118,8 +120,8 @@ uniform sampler2D normalMap;
 uniform sampler2D specularMap;
 uniform sampler2D heightMap;
 uniform sampler2D environmentMap;
-uniform vec3 diffuseCol = vec3( 1.0, 1.0, 1.0 );
-uniform vec3 specularCol = vec3( 1.0, 1.0, 1.0 );
+uniform vec3 diffuseCol = vec3(1.0, 1.0, 1.0);
+uniform vec3 specularCol = vec3(1.0, 1.0, 1.0);
 uniform float shininess = 50.0;
 
 varying vec3 normal_v2f;
@@ -141,13 +143,13 @@ void main()
 	// Paralax Mapping Calculations                                                                                      =
 	// The code below reads the height map, makes some calculations and returns a new texCoords                          =
 	//====================================================================================================================
-	#if defined( PARALLAX_MAPPING )
+	#if defined(PARALLAX_MAPPING)
 		/*const float _scale = 0.04;
 		const float _bias = scale * 0.4;
 
-		vec3 _norm_eye = normalize( eye );
+		vec3 _norm_eye = normalize(eye);
 
-		float _h = texture2D( heightMap, texCoords_v2f ).r;
+		float _h = texture2D(heightMap, texCoords_v2f).r;
 		float _height = _scale * _h - _bias;
 
 		vec2 superTexCoords_v2f = _height * _norm_eye.xy + texCoords_v2f;*/
@@ -160,16 +162,16 @@ void main()
 		dir.xy /= 8.0;
 		dir /= -nSteps * dir.z;
 
-		float diff0, diff1 = 1.0 - texture2D( heightMap, superTexCoords ).a;
-		if( diff1 > 0.0 )
+		float diff0, diff1 = 1.0 - texture2D(heightMap, superTexCoords).a;
+		if(diff1 > 0.0)
 		{
 			do 
 			{
 				superTexCoords += dir.xy;
 
 				diff0 = diff1;
-				diff1 = texture2D(heightMap, superTexCoords ).w;
-			} while( diff1 > 0.0 );
+				diff1 = texture2D(heightMap, superTexCoords).w;
+			} while(diff1 > 0.0);
 
 			superTexCoords.xy += (diff1 / (diff0 - diff1)) * dir.xy;
 		}
@@ -183,14 +185,14 @@ void main()
 	// Get the color from the diffuse map and discard if grass                                                           =
 	//====================================================================================================================
 	vec3 _diff_color;
-	#if defined( DIFFUSE_MAPPING )
+	#if defined(DIFFUSE_MAPPING)
 
-		#if defined( ALPHA_TESTING )
-			vec4 _diff_color4 = texture2D( diffuseMap, superTexCoords );
-			if( _diff_color4.a == 0.0 ) discard;
+		#if defined(ALPHA_TESTING)
+			vec4 _diff_color4 = texture2D(diffuseMap, superTexCoords);
+			if(_diff_color4.a == 0.0) discard;
 			_diff_color = _diff_color4.rgb;
 		#else
-			_diff_color = texture2D( diffuseMap, superTexCoords ).rgb;
+			_diff_color = texture2D(diffuseMap, superTexCoords).rgb;
 		#endif
 
 		_diff_color *= diffuseCol.rgb;
@@ -203,16 +205,16 @@ void main()
 	// Normal Calculations                                                                                               =
 	// Either use a normap map and make some calculations or use the vertex normal                                       =
 	//====================================================================================================================
-	#if defined( NORMAL_MAPPING )
-		vec3 _n = normalize( normal_v2f );
-		vec3 _t = normalize( tangent_v2f );
+	#if defined(NORMAL_MAPPING)
+		vec3 _n = normalize(normal_v2f);
+		vec3 _t = normalize(tangent_v2f);
 		vec3 _b = cross(_n, _t) * w_v2f;
 
 		mat3 tbnMat = mat3(_t,_b,_n);
 
-		vec3 nAtTangentspace = ( texture2D( normalMap, superTexCoords ).rgb - 0.5 ) * 2.0;
+		vec3 nAtTangentspace = (texture2D(normalMap, superTexCoords).rgb - 0.5) * 2.0;
 
-		vec3 newNormal = normalize( tbnMat * nAtTangentspace );
+		vec3 newNormal = normalize(tbnMat * nAtTangentspace);
 	#else
 		vec3 newNormal = normalize(normal_v2f);
 	#endif
@@ -224,20 +226,20 @@ void main()
 	//====================================================================================================================
 
 	// if SEM enabled make some aditional calculations using the vertPosEyeSpace_v2f, environmentMap and the newNormal
-	#if defined( ENVIRONMENT_MAPPING )
-		vec3 _u = normalize( vertPosEyeSpace_v2f );
+	#if defined(ENVIRONMENT_MAPPING)
+		vec3 _u = normalize(vertPosEyeSpace_v2f);
 		
 		/**
 		 * In case of normal mapping I could play with vertex's normal but this gives better results and its allready
 		 * computed
 		 */
-		vec3 _r = reflect( _u, newNormal ); 
+		vec3 _r = reflect(_u, newNormal); 
 		
 		_r.z += 1.0;
 		float _m = 2.0 * length(_r);
 		vec2 _sem_texCoords = _r.xy/_m + 0.5;
 
-		vec3 _sem_col = texture2D( environmentMap, _sem_texCoords ).rgb;
+		vec3 _sem_col = texture2D(environmentMap, _sem_texCoords).rgb;
 		_diff_color = _diff_color + _sem_col; // blend existing color with the SEM texture map
 	#endif
 
@@ -247,8 +249,8 @@ void main()
 	//====================================================================================================================
 
 	// has specular map
-	#if defined( SPECULAR_MAPPING )
-		vec4 _specular = vec4(texture2D( specularMap, superTexCoords ).rgb * specularCol, shininess);
+	#if defined(SPECULAR_MAPPING)
+		vec4 _specular = vec4(texture2D(specularMap, superTexCoords).rgb * specularCol, shininess);
 	// no specular map
 	#else
 		vec4 _specular = vec4(specularCol, shininess);
@@ -258,11 +260,11 @@ void main()
 	//====================================================================================================================
 	// Final Stage. Write all data                                                                                       =
 	//====================================================================================================================
-	gl_FragData[0].rg = PackNormal( newNormal );
+	gl_FragData[0].rg = PackNormal(newNormal);
 	gl_FragData[1].rgb = _diff_color;
 	gl_FragData[2] = _specular;
 
-	/*#if defined( HARDWARE_SKINNING )
+	/*#if defined(HARDWARE_SKINNING)
 		gl_FragData[1] = gl_Color;
 	#endif*/
 }

+ 1 - 0
src/Main.cpp

@@ -74,6 +74,7 @@ void initPhysics()
 	RigidBody::Initializer init;
 	init.mass = 0.0;
 	init.shape = groundShape;
+	init.startTrf = groundTransform;
 
 	new RigidBody(*app->getScene()->getPhysics(), init);
 

+ 1 - 1
src/Renderer/Is.cpp

@@ -140,7 +140,7 @@ void Renderer::Is::init()
 
 	// spot light w/t shadow
 	string pps = string("\n#define SPOT_LIGHT_ENABLED\n#define SHADOW_ENABLED\n") +
-	             "#define SHADOWMAP_SIZE " + lexical_cast<string>(sm.resolution) + "\n";
+	                    "#define SHADOWMAP_SIZE " + lexical_cast<string>(sm.resolution) + "\n";
 	string prefix = "SpotShadowSms" + lexical_cast<string>(sm.resolution);
 	if(sm.pcfEnabled)
 	{

+ 2 - 2
src/Renderer/Ssao.cpp

@@ -48,7 +48,6 @@ void Renderer::Pps::Ssao::init()
 	bwidth = height * bluringQuality;
 	bheight = height * bluringQuality;
 
-
 	//
 	// init FBOs
 	//
@@ -111,6 +110,7 @@ void Renderer::Pps::Ssao::init()
 
 	/// @todo fix this crap
 	// load noise map and disable temporally the texture compression and enable mipmapping
+	GL_OK();
 	bool texCompr = Texture::compressionEnabled;
 	bool mipmaping = Texture::mipmappingEnabled;
 	Texture::compressionEnabled = false;
@@ -122,7 +122,7 @@ void Renderer::Pps::Ssao::init()
 	//noise_map->setTexParameter(GL_TEXTURE_MIN_FILTER, GL_NEAREST);
 	Texture::compressionEnabled = texCompr;
 	Texture::mipmappingEnabled = mipmaping;
-
+	GL_OK();
 }
 
 

+ 2 - 2
src/Resources/Helpers/Image.cpp

@@ -214,9 +214,9 @@ bool Image::loadTga(const char* filename)
 	}
 
 	if(bpp == 32)
-		type == T_RGBA;
+		type = T_RGBA;
 	else
-		type == T_RGB;
+		type = T_RGB;
 
 	fs.close();
 	return funcsReturn;

+ 3 - 0
src/Resources/Texture.cpp

@@ -82,6 +82,9 @@ bool Texture::load(const char* filename)
 			format = GL_RGBA;
 			type = GL_UNSIGNED_BYTE;
 			break;
+
+		default:
+			FATAL("See file");
 	}
 
 	glTexImage2D(target, 0, internalFormat, img.getWidth(), img.getHeight(), 0, format, type, &img.getData()[0]);

+ 8 - 1
src/Scene/MeshNode.cpp

@@ -19,12 +19,19 @@ void MeshNode::init(const char* filename)
 	material.loadRsrc(mesh->materialName.c_str());
 
 	// sanity checks
-	if(material->stdAttribVars[Material::SAV_TEX_COORDS]!=NULL && mesh->vbos.texCoords.getGlId()==0)
+	if(material->stdAttribVars[Material::SAV_TEX_COORDS]!=NULL && !mesh->vbos.texCoords.isCreated())
 	{
 		ERROR("The shader program (\"" << material->shaderProg->getRsrcName() <<
 		       "\") needs texture coord information that the mesh (\"" <<
 		       mesh->getRsrcName() << "\") doesn't have");
 	}
+
+	if(material->hasHWSkinning() && !mesh->vbos.vertWeights.isCreated())
+	{
+		ERROR("The shader program (\"" << material->shaderProg->getRsrcName() <<
+		       "\") needs vertex weights that the mesh (\"" <<
+		       mesh->getRsrcName() << "\") doesn't have");
+	}
 }
 
 

+ 0 - 1
src/Util/App.cpp

@@ -1,7 +1,6 @@
 #include <GL/glew.h>
 #include <sstream>
 #include <SDL/SDL.h>
-#include <SDL/SDL_image.h>
 #include "App.h"
 #include "Scene.h"
 #include "MainRenderer.h"

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно