ソースを参照

Add on_init script entry point, don't spew errors if "idle" animation can't be found. Fix various naming issues in the converted data, currently converted models seem to have some issue where they appear huge, loops hang scripts and more :)

Paul 11 年 前
コミット
228c645ae0

+ 5 - 1
QGearsMain/src/core/EntityModel.cpp

@@ -75,7 +75,11 @@ EntityModel::PlayAnimation(const Ogre::String& animation, Entity::AnimationState
     }
     }
     else
     else
     {
     {
-        LOG_ERROR("Animation '" + animation + "' doesn't exist in model '" + m_Model->getName() + "'.");
+        // Idle is hard coded to the default animation, so don't spam crazy amounts of errors if its not found.
+        if (animation != "Idle")
+        {
+            LOG_ERROR("Animation '" + animation + "' doesn't exist in model '" + m_Model->getName() + "'.");
+        }
     }
     }
 }
 }
 
 

+ 16 - 1
QGearsMain/src/core/ScriptManager.cpp

@@ -338,12 +338,27 @@ ScriptManager::AddEntity(const ScriptManager::Type type, const Ogre::String& ent
             table["entity"] = boost::ref(*entity);
             table["entity"] = boost::ref(*entity);
         }
         }
 
 
+        // check "on_init" script
+        if (luabind::type(table["on_init"]) == LUA_TFUNCTION)
+        {
+            QueueScript script;
+            script.function = "on_init";
+            script.priority = 0;
+            script.state = lua_newthread(m_LuaState);
+            // we dont want thread to be garbage collected so we store it
+            script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
+            script.seconds_to_wait = 0;
+            script.wait = false;
+            script.yield = false;
+            script_entity.queue.push_back(script);
+        }
+
         // check "on_start" script
         // check "on_start" script
         if(luabind::type(table["on_start"]) == LUA_TFUNCTION)
         if(luabind::type(table["on_start"]) == LUA_TFUNCTION)
         {
         {
             QueueScript script;
             QueueScript script;
             script.function = "on_start";
             script.function = "on_start";
-            script.priority = 0;
+            script.priority = 1;
             script.state = lua_newthread(m_LuaState);
             script.state = lua_newthread(m_LuaState);
             // we dont want thread to be garbage collected so we store it
             // we dont want thread to be garbage collected so we store it
             script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);
             script.state_id = luaL_ref(m_LuaState, LUA_REGISTRYINDEX);

+ 19 - 14
utilities/q-gears-launcher/src/ff7DataInstaller.cpp

@@ -79,6 +79,7 @@ static void exportMesh(std::string outdir, const Ogre::MeshPtr &mesh)
     sk_ser.exportSkeleton(skeleton.getPointer(), outdir +  skeleton->getName());
     sk_ser.exportSkeleton(skeleton.getPointer(), outdir +  skeleton->getName());
 
 
     mesh->setSkeletonName(FieldModelDir() + "/" + mesh->getSkeletonName());
     mesh->setSkeletonName(FieldModelDir() + "/" + mesh->getSkeletonName());
+
     mesh_ser.exportMesh(mesh.getPointer(), outdir + mesh->getName());
     mesh_ser.exportMesh(mesh.getPointer(), outdir + mesh->getName());
 
 
 
 
@@ -162,7 +163,6 @@ static std::string FieldMapDir()
     return "maps/ffvii/field";
     return "maps/ffvii/field";
 }
 }
 
 
-
 class FF7FieldScriptFormatter : public SUDM::IScriptFormatter
 class FF7FieldScriptFormatter : public SUDM::IScriptFormatter
 {
 {
 public:
 public:
@@ -188,7 +188,15 @@ public:
     virtual std::string AnimationName(int charId, int id) override
     virtual std::string AnimationName(int charId, int id) override
     {
     {
         // Get the animation file name, then look up the friendly name of the "raw" animation
         // Get the animation file name, then look up the friendly name of the "raw" animation
-        return QGears::FF7::NameLookup::animation(mModelLoader->getModels().at(charId).animations.at(id).name);
+        const auto& modelInfo = mModelLoader->getModels().at(charId);
+        const auto rawName = modelInfo.animations.at(id).name;
+
+        // Trim off ".yos" or whatever other crazy extension the model loader adds in
+        Ogre::String baseName;
+        QGears::StringUtil::splitBase(rawName, baseName);
+
+        QGears::StringUtil::toLowerCase(baseName);
+        return QGears::FF7::NameLookup::animation(baseName);
     }
     }
 
 
     // Get name of char from its id, can't return empty
     // Get name of char from its id, can't return empty
@@ -281,19 +289,10 @@ public:
 
 
     std::string ModelMetaDataName(const std::string& modelName)
     std::string ModelMetaDataName(const std::string& modelName)
     {
     {
-        // TODO: Convert to name thats in the meta data
-
         // If not in meta data then just replace .hrc with .mesh
         // If not in meta data then just replace .hrc with .mesh
         Ogre::String baseName;
         Ogre::String baseName;
         QGears::StringUtil::splitBase(modelName, baseName);
         QGears::StringUtil::splitBase(modelName, baseName);
-
-        return baseName + ".mesh";
-    }
-
-    std::string AnimationMetaDataName(const std::string& /*modelName*/, const std::string& animationName)
-    {
-        // TODO: Same as above
-        return animationName;
+        return QGears::FF7::NameLookup::model(baseName) + ".mesh";
     }
     }
 
 
 //private:
 //private:
@@ -406,7 +405,9 @@ static void FF7PcFieldToQGearsField(
                 xmlEntityScript->SetAttribute("name", it.first);
                 xmlEntityScript->SetAttribute("name", it.first);
 
 
                 // TODO: Add to list of HRC's to convert, obtain name of target converted .mesh file
                 // TODO: Add to list of HRC's to convert, obtain name of target converted .mesh file
-                xmlEntityScript->SetAttribute("file_name", FieldModelDir() + "/" + modelAnimationDb.ModelMetaDataName(desc.hrc_name));
+                auto lowerCaseHrcName = desc.hrc_name;
+                QGears::StringUtil::toLowerCase(lowerCaseHrcName);
+                xmlEntityScript->SetAttribute("file_name", FieldModelDir() + "/" + modelAnimationDb.ModelMetaDataName(lowerCaseHrcName));
 
 
                 // TODO: entity_model - name, file_name,  position, direction
                 // TODO: entity_model - name, file_name,  position, direction
                 // We set char 1 position to be position of first entity_point so player is spawned in sane
                 // We set char 1 position to be position of first entity_point so player is spawned in sane
@@ -762,7 +763,11 @@ void FF7DataInstaller::ConvertFields(std::string archive, std::string inputDir,
         {
         {
             QGears::AFileManager       &afl_mgr(QGears::AFileManager::getSingleton());
             QGears::AFileManager       &afl_mgr(QGears::AFileManager::getSingleton());
             QGears::AFilePtr  a = afl_mgr.load(anim, "FFVII").staticCast<QGears::AFile>();
             QGears::AFilePtr  a = afl_mgr.load(anim, "FFVII").staticCast<QGears::AFile>();
-            a->addTo(skeleton, anim); // TODO: Set "friendly" name, also update this name in the scripts
+
+            // Convert the FF7 name to a more readble name set in the meta data
+            Ogre::String baseName;
+            QGears::StringUtil::splitBase(anim, baseName);
+            a->addTo(skeleton, QGears::FF7::NameLookup::animation(baseName));
         }
         }
 
 
         exportMesh(outDir + "/" + FieldModelDir() + "/", mesh);
         exportMesh(outDir + "/" + FieldModelDir() + "/", mesh);