فهرست منبع

Updates to character sample.

Steve Grenier 14 سال پیش
والد
کامیت
031e959dde

+ 1 - 1
gameplay-encoder/src/FBXSceneEncoder.cpp

@@ -260,7 +260,7 @@ void FBXSceneEncoder::loadAnimationChannels(KFbxAnimLayer* animLayer, KFbxNode*
     // TODO: Ignore properties that are not animated (scale, rotation, translation)
     // This should result in only one animation channel per animated node.
 
-    float startTime = FLT_MAX, stopTime = -1.0f, frameRate = FLT_MIN;
+    float startTime = FLT_MAX, stopTime = -1.0f, frameRate = -FLT_MAX;
     bool tx = false, ty = false, tz = false, rx = false, ry = false, rz = false, sx = false, sy = false, sz = false;
     KFbxAnimCurve* animCurve = NULL;
     animCurve = fbxNode->LclTranslation.GetCurve<KFbxAnimCurve>(animLayer, KFCURVENODE_T_X);

+ 2 - 2
gameplay-encoder/src/Mesh.cpp

@@ -156,7 +156,7 @@ void Mesh::generateHeightmap(const char* filename)
     float* heights = new float[width * height];
     int index = 0;
     float minHeight = FLT_MAX;
-    float maxHeight = FLT_MIN;
+    float maxHeight = -FLT_MAX;
     for (int z = minZ; z <= maxZ; z++)
     {
         rayOrigin.z = (float)z;
@@ -392,7 +392,7 @@ void Mesh::computeBounds()
     }
 
     bounds.min.x = bounds.min.y = bounds.min.z = FLT_MAX;
-    bounds.max.x = bounds.max.y = bounds.max.z = FLT_MIN;
+    bounds.max.x = bounds.max.y = bounds.max.z = -FLT_MAX;
     bounds.center.x = bounds.center.y = bounds.center.z = 0.0f;
     bounds.radius = 0.0f;
 

+ 2 - 2
gameplay-encoder/src/MeshSkin.cpp

@@ -225,7 +225,7 @@ void MeshSkin::computeBounds()
         vertices.clear();
         BoundingVolume jointBounds;
         jointBounds.min.set(FLT_MAX, FLT_MAX, FLT_MAX);
-        jointBounds.max.set(FLT_MIN, FLT_MIN, FLT_MIN);
+        jointBounds.max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
         for (unsigned int j = 0; j < vertexCount; ++j)
         {
             const Vertex& v = _mesh->getVertex(j);
@@ -354,7 +354,7 @@ void MeshSkin::computeBounds()
     Matrix temp;
     Matrix* jointTransforms = new Matrix[jointCount];
     _mesh->bounds.min.set(FLT_MAX, FLT_MAX, FLT_MAX);
-    _mesh->bounds.max.set(FLT_MIN, FLT_MIN, FLT_MIN);
+    _mesh->bounds.max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX);
     _mesh->bounds.center.set(0, 0, 0);
     _mesh->bounds.radius = 0;
     Vector3 skinnedPos;

+ 2 - 2
gameplay/res/shaders/colored-specular.fsh

@@ -30,8 +30,8 @@ void lighting(vec3 normalVector, vec3 cameraDirection, vec3 lightDirection, floa
 
     // Diffuse
 	float ddot = abs(dot(normalVector, lightDirection));
-	//if (ddot < 0)
-		//ddot = abs(ddot) * 0.25f; // simulate light bounce at half intensity
+	if (ddot < 0)
+		ddot = abs(ddot) * 0.25f; // simulate light bounce at partial intensity
     float diffuseIntensity = attenuation * ddot;
     diffuseIntensity = max(0.0, diffuseIntensity);
     _diffuseColor = u_lightColor * _baseColor.rgb * diffuseIntensity;

+ 1 - 1
gameplay/res/shaders/diffuse-specular.fsh

@@ -27,7 +27,7 @@ void lighting(vec3 normalVector, vec3 cameraDirection, vec3 lightDirection, floa
     // Diffuse
 	float ddot = dot(normalVector, lightDirection);
 	if (ddot < 0)
-		ddot = abs(ddot) * 0.5f; // simulate light bounce at half intensity
+		ddot = abs(ddot) * 0.25f; // simulate light bounce at partial intensity
     float diffuseIntensity = attenuation * ddot;
     diffuseIntensity = max(0.0, diffuseIntensity);
     _diffuseColor = u_lightColor * _baseColor.rgb * diffuseIntensity;

+ 1 - 1
gameplay/src/PhysicsController.cpp

@@ -636,9 +636,9 @@ void PhysicsController::DebugDrawer::begin(const Matrix& viewProjection)
 
 void PhysicsController::DebugDrawer::end()
 {
+    _meshBatch->end();
     _meshBatch->getMaterial()->getParameter("u_viewProjectionMatrix")->setValue(_viewProjection);
     _meshBatch->draw();
-    _meshBatch->end();
 }
 
 void PhysicsController::DebugDrawer::drawLine(const btVector3& from, const btVector3& to, const btVector3& fromColor, const btVector3& toColor)

+ 40 - 20
gameplay/src/Properties.cpp

@@ -6,11 +6,30 @@
 namespace gameplay
 {
 
+Properties::Properties()
+{
+}
+
+Properties::Properties(const Properties& copy)
+{
+    _namespace = copy._namespace;
+    _id = copy._id;
+    _parentID = copy._parentID;
+    _properties = copy._properties;
+    
+    _namespaces = std::vector<Properties*>();
+    std::vector<Properties*>::const_iterator it;
+    for (it = copy._namespaces.begin(); it < copy._namespaces.end(); it++)
+    {
+        _namespaces.push_back(new Properties(**it));
+    }
+    rewind();
+}
+
 Properties::Properties(FILE* file)
 {
     readProperties(file);
-    _propertiesItr = _properties.end();
-    _namespacesItr = _namespaces.end();
+    rewind();
 }
 
 Properties::Properties(FILE* file, const char* name, const char* id, const char* parentID) : _namespace(name)
@@ -24,8 +43,7 @@ Properties::Properties(FILE* file, const char* name, const char* id, const char*
         _parentID = parentID;
     }
     readProperties(file);
-    _propertiesItr = _properties.end();
-    _namespacesItr = _namespaces.end();
+    rewind();
 }
 
 Properties* Properties::create(const char* filePath)
@@ -275,25 +293,29 @@ void Properties::resolveInheritance(const char* id)
 
                 // Copy the child.
                 Properties* overrides = new Properties(*derived);
-                overrides->_propertiesItr = overrides->_properties.end();
-                overrides->_namespacesItr = overrides->_namespaces.end();
+
+                // Delete the child's data.
+                unsigned int count = derived->_namespaces.size();
+                for (unsigned int i = 0; i < count; i++)
+                {
+                    SAFE_DELETE(derived->_namespaces[i]);
+                }
 
                 // Copy data from the parent into the child.
                 derived->_properties = parent->_properties;
-                derived->_propertiesItr = derived->_properties.end();
                 derived->_namespaces = std::vector<Properties*>();
-                std::vector<Properties*>::const_iterator it;
-                for (it = parent->_namespaces.begin(); it < parent->_namespaces.end(); it++)
+                std::vector<Properties*>::const_iterator itt;
+                for (itt = parent->_namespaces.begin(); itt < parent->_namespaces.end(); itt++)
                 {
-                    derived->_namespaces.push_back(new Properties(**it));
+                    derived->_namespaces.push_back(new Properties(**itt));
                 }
-                derived->_namespacesItr = derived->_namespaces.end();
+                derived->rewind();
 
                 // Take the original copy of the child and override the data copied from the parent.
                 derived->mergeWith(overrides);
 
                 // Delete the child copy.
-                delete overrides;
+                SAFE_DELETE(overrides);
             }
         }
 
@@ -316,12 +338,14 @@ void Properties::mergeWith(Properties* overrides)
 {
     // Overwrite or add each property found in child.
     char* value = new char[255];
+    overrides->rewind();
     const char* name = overrides->getNextProperty(&value);
     while (name)
     {
         this->_properties[name] = value;
         name = overrides->getNextProperty(&value);
     }
+    SAFE_DELETE(value);
     this->_propertiesItr = this->_properties.end();
 
     // Merge all common nested namespaces, add new ones.
@@ -336,7 +360,7 @@ void Properties::mergeWith(Properties* overrides)
         {
             if (strcmp(derivedNamespace->getNamespace(), overridesNamespace->getNamespace()) == 0 &&
                 strcmp(derivedNamespace->getId(), overridesNamespace->getId()) == 0)
-            {
+            {   
                 derivedNamespace->mergeWith(overridesNamespace);
                 merged = true;
             }
@@ -348,8 +372,6 @@ void Properties::mergeWith(Properties* overrides)
         {
             // Add this new namespace.
             Properties* newNamespace = new Properties(*overridesNamespace);
-            newNamespace->_propertiesItr = newNamespace->_properties.end();
-            newNamespace->_namespacesItr = newNamespace->_namespaces.end();
 
             this->_namespaces.push_back(newNamespace);
             this->_namespacesItr = this->_namespaces.end();
@@ -544,12 +566,10 @@ const char* Properties::getString(const char* name) const
 
 bool Properties::getBool(const char* name) const
 {
-    if (exists(name))
+    const char* valueString = getString(name);
+    if (valueString)
     {
-        if (_properties.find(name)->second == "true")
-        {
-            return true;
-        }
+        return (strcmp(valueString, "true") == 0);
     }
 
     return false;

+ 3 - 3
gameplay/src/Properties.h

@@ -371,17 +371,17 @@ public:
 private:
     
     /**
-     * Constructor.
+     * Constructors.
      */
+    Properties();
     Properties(FILE* file);
+    Properties(const Properties& copy);
 
     /**
      * Constructor. Read from the beginning of namespace specified
      */
     Properties(FILE* file, const char* name, const char* id = NULL, const char* parentID = NULL);
 
-    //Properties(const Properties& copy);
-
     void readProperties(FILE* file);
 
     void skipWhiteSpace(FILE* file);