예제 #1
0
        public ParameterDatabase()
        {
            myVm = new LuaState();

            //add complex data type encoder/decoders
            LuaExt.extendLua(myVm);
        }
예제 #2
0
            public bool loadFile(string filename)
            {
                LuaState vm = new LuaState();

                LuaExt.extendLua(vm);

                try
                {
                    if (vm.doFile(filename) == false)
                    {
                        Warn.print("Unable to open BOB file {0}", filename);
                        return(false);
                    }

                    LuaObject data = vm.findObject("BOB");
                    if (data == null)
                    {
                        Warn.print("Unable to find BOB data in file {0}", filename);
                        return(false);
                    }

                    myVersion = data.get <UInt32>("version");

                    //read the registry
                    LuaObject registry = data.get <LuaObject>("registry");
                    parseRegistry(registry);

                    //read the chunks
                    LuaObject chunks = data.get <LuaObject>("chunks");
                    for (int i = 1; i <= chunks.count(); i++)
                    {
                        LuaObject chunkData = chunks[i];
                        switch (chunkData.get <String>("type"))
                        {
                        case "model":
                            ModelChunk model = new ModelChunk();
                            parseModel(model, chunkData);
                            myChunks.Add(model);
                            break;

                        case "skeleton":
                            SkeletonChunk skeleton = new SkeletonChunk();
                            parseSkeleton(skeleton, chunkData);
                            myChunks.Add(skeleton);
                            break;

                        case "animation":
                            AnimationChunk animation = new AnimationChunk();
                            parseAnimation(animation, chunkData);
                            myChunks.Add(animation);
                            break;

                        case "texture":
                            Warn.print("Skipping .BOB texture");
                            break;

                        case "particle":
                            Warn.print("Skipping .BOB particle system");
                            break;

                        case "audio":
                            Warn.print("Skipping .BOB audio");
                            break;

                        default:
                            Warn.print("Unknown type: {0}", chunkData.get <String>("type"));
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Error while loading BOB model from definition file ( " + filename + " ).", ex);
                }
                return(true);
            }