static int Main(string[] args) { { TestBench.StartLogging(ELogType.Warning); Level level = TestBench.LoadAndTrackLVL(args[0]); if (level == null) { TestBench.StopLogging(); return(-1); } var classes = level.GetEntityClasses(); int k = 0; foreach (var ec in classes) { Console.WriteLine("\n" + ec.name + " of base class: " + ec.GetBaseName()); ec.GetOverriddenProperties(out uint[] hashes, out string[] values); Console.WriteLine("Properties: "); for (int i = 0; i < values.Length; i++) { Console.WriteLine("\t0x{0:x}: {1}", hashes[i], values[i]); } } TestBench.StopLogging(); return(1); } }
static void Main(string[] args) { TestBench.StartLogging(ELogType.Warning); var lvls = TestBench.LoadAndTrackLVLs(new List <string>(args)); TestBench.StopLogging(); }
public static int Main(string[] args) { TestBench.StartLogging(ELogType.Warning); Level level = TestBench.LoadAndTrackLVL(args[0]); if (level == null) { return(-1); } Terrain terrain = level.GetTerrains()[0]; foreach (var str in terrain.layerTextures) { if (str == "") { continue; } Console.Write("Texture name: " + str); Texture tex = level.GetTexture(str); if (tex != null) { byte[] data = tex.GetBytesRGBA(); Console.WriteLine(" width: " + tex.width + " height: " + tex.height + " bytes length: " + data.Length); } else { Console.WriteLine(" lookup failed."); } } terrain.GetHeightMap(out uint dim, out uint dimScale, out float[] heightMapData); terrain.GetBlendMap(out dim, out uint numLayers, out byte[] blendMapData); uint[] iBuf = terrain.GetIndexBuffer(); Vector2[] uvBuf = terrain.GetUVBuffer <Vector2>(); Vector3[] vertBuf = terrain.GetPositionsBuffer <Vector3>(); Vector3[] normsBuf = terrain.GetNormalsBuffer <Vector3>(); Console.WriteLine("Num uvs: {0}, num normals: {1}, num verts: {2}, num indices: {3}", uvBuf.Length, normsBuf.Length, vertBuf.Length, iBuf.Length); TestBench.StopLogging(); return(1); }
static int Main(string[] args) { TestBench.StartLogging(ELogType.Warning); var lvls = TestBench.LoadAndTrackLVLs(new List <string>(args)); for (int i = 0; i < lvls.Count; i++) { Console.WriteLine("Level {0}'s collision meshes: ", i); var level = lvls[i]; Model[] models = level.GetModels(); foreach (Model model in models) { Console.WriteLine("\n\tModel: " + model.name); CollisionMesh mesh = model.GetCollisionMesh(); if (mesh == null) { continue; } Console.WriteLine("\t\tCollision mask flags: {0}", mesh.maskFlags); Console.WriteLine("\t\tNum collision indices: {0}", mesh.GetIndices().Length); Console.WriteLine("\t\tNum collision verticies: {0}", mesh.GetVertices <Vector3>().Length); CollisionPrimitive[] prims = model.GetPrimitivesMasked(16); Console.WriteLine("\t\t{0} Primitives: ", prims.Length); foreach (var prim in prims) { Console.WriteLine("\t\t\tName: {0} Parent: {1}", prim.name, prim.parentName); } } } TestBench.StopLogging(); return(0); }
/* * public static uint GetUIntRep(string name) * { * uint result = 0; * byte i = 0; * foreach (char c in name) * { * result |= (((uint) c) << (8 * i)); * i++; * } * return result; * } * * * public static void PrintUIntChars(uint enc) * { * for (int i = 0; i < 4; i++) * { * char c = (char) ((0x000000ff) & (enc >> (i * 8))); * Console.Write("{0}", c); * } * Console.Write("\n"); * } */ public static int Main(string[] args) { TestBench testBench = new TestBench(); Container container = testBench.LoadAndTrackContainer(new List <string>(args), out List <Level> levels); /* * string tstFX = "com_sfx_ord_flame"; * var fxConfig = container.FindConfig(ConfigType.Effect, tstFX); * * Field lEmitter = fxConfig.GetField("ParticleEmitter"); * * * Console.WriteLine("Num particles: {0}", (int) lEmitter.scope.GetField("MaxParticles").GetVec2().Y); * * Field lTransformer = lEmitter.scope.GetField("Transformer"); * Field lSpawner = lEmitter.scope.GetField("Spawner"); * * if (lTransformer == null) * { * Console.WriteLine("Transformer is null!"); //return 0; * } * * if (lSpawner == null) * { * Console.WriteLine("Spawner is null!"); //return 0; * } * * Console.WriteLine("Start size: {0}", lSpawner.scope.GetField("Size").GetVec3().Z); * //Console.WriteLine("Lifetime: {0}", lTransformer.GetChildConfig("Position").GetFloat("LifeTime")); * * //return 1; */ Level level = levels[0]; if (level == null) { return(-1); } World[] worlds = level.GetWrappers <World>(); foreach (World world in worlds) { Console.WriteLine("\nWorld: {0}", world.name); //Test for crash... Config skydome = container.FindConfig(ConfigType.Skydome, world.skydomeName); if (skydome != null) { Console.WriteLine("Skydome: {0} (0x{1:x})", world.skydomeName, HashUtils.GetFNV(world.name)); Field domeInfo = skydome.GetField("DomeInfo"); if (domeInfo != null) { List <Field> domeModelConfigs = domeInfo.scope.GetFields("DomeModel"); foreach (Field domeModelConfig in domeModelConfigs) { string geometryName = domeModelConfig.scope.GetField("Geometry").GetString(); Console.WriteLine(" Dome geometry: " + geometryName); } } } Config lighting = level.GetConfig(world.name, ConfigType.Lighting); if (lighting == null) { continue; } Console.WriteLine("Lighting: "); uint lightHash = HashUtils.GetFNV("Light"); List <Field> lights = lighting.GetFields(lightHash); Console.WriteLine("\n Lights: "); int i = 0; foreach (Field light in lights) { Console.WriteLine("\n\tName: " + light.GetString()); Console.WriteLine("\tColor: " + light.scope.GetField("Color").GetVec3().ToString()); Console.WriteLine("\tType: " + light.scope.GetField("Type").GetFloat().ToString()); } Field globalLighting = lighting.GetField("GlobalLights"); if (globalLighting == null) { continue; } Console.WriteLine("\n Global lighting config: "); Console.WriteLine("\tLight 1: " + globalLighting.scope.GetField("Light1").GetString()); Console.WriteLine("\tLight 2: " + globalLighting.scope.GetField("Light2").GetString()); Console.WriteLine("\tTop Ambient Color: " + globalLighting.scope.GetField("Top").GetVec3().ToString()); Console.WriteLine("\tBottom Ambient Color: " + globalLighting.scope.GetField("Bottom").GetVec3().ToString()); } List <Config> effects = level.GetConfigs(ConfigType.Effect); Console.WriteLine("\nEffects: "); foreach (Config effect in effects) { Console.WriteLine(" Effect name hash: 0x{0:x}", effect.name); //Console.WriteLine("\tEmitter name: {0}", (effect.IsPropertySet("ParticleEmitter") ? effect.GetString("ParticleEmitter") : "No emitter set!")); } List <Config> paths = level.GetConfigs(ConfigType.Path); Console.WriteLine("\nPath configs: "); foreach (Config path in paths) { Console.WriteLine(" Path config: 0x{0:x}", path.name); int i = 0; List <Field> pathNames = path.GetFields("Path"); foreach (Field pathName in pathNames) { Console.WriteLine("\tPath {0} has {1} nodes.", pathName.GetString(), pathName.scope.GetField("Node").GetFloat()); } } container.Delete(); return(1); }
static int Main(string[] args) { TestBench testBench = new TestBench(); Container container = testBench.LoadAndTrackContainer(new List <string>(args), out List <Level> lvls); Level level = lvls[0]; if (level == null) { return(-1); } World[] worlds = level.GetWrappers <World>(); foreach (World world in worlds) { Console.WriteLine("\n" + world.name); Console.WriteLine(" Instances: "); foreach (Instance instance in world.GetInstances()) { var ec = container.FindWrapper <EntityClass>(instance.entityClassName); if (ec == null) { continue; } string baseName = ec.GetBaseName(); string instName = instance.name; Vector4 rot = instance.rotation; Vector3 pos = instance.position; Console.WriteLine("\n\tInstance: " + instName); Console.WriteLine("\t Class: " + ec.name); Console.WriteLine("\t Parent: " + baseName); Console.WriteLine("\t Rotation: " + rot.ToString()); Console.WriteLine("\t Position: " + pos.ToString()); Console.WriteLine("\t Overridden properties: "); if (instance.GetOverriddenProperties(out uint[] props, out string[] values)) { for (int j = 0; j < props.Length; j++) { Console.WriteLine("\t Hash: {0}, Value: {1}", props[j], values[j]); } } } Console.WriteLine(" Regions:"); foreach (Region region in world.GetRegions()) { Console.WriteLine("\n\tRegion: " + region.name); Console.WriteLine("\t Size: " + region.size.ToString()); Console.WriteLine("\t Rotation: " + region.rotation.ToString()); Console.WriteLine("\t Type: " + region.type); } } return(1); }
static int Main(string[] args) { if (args.Length < 3) { return(-1); } TestBench.StartLogging(ELogType.Warning); Level level = TestBench.LoadAndTrackLVL(args[0]); if (level == null) { TestBench.StopLogging(); return(-1); } string animSetName = args[1]; string animationName = args[2]; List <uint> boneCRCs = new List <uint>(); for (int i = 0; i < args.Length - 3; i++) { boneCRCs.Add(HashUtils.GetCRC(args[3 + i])); } AnimationBank bank = level.GetAnimationBank(animSetName); if (bank == null) { Console.WriteLine("Animation bank not found!"); TestBench.StopLogging(); return(-1); } uint[] animHashes = bank.GetAnimationCRCs(); foreach (uint hash in animHashes) { if (hash == HashUtils.GetCRC(animationName)) { bank.GetAnimationMetadata(hash, out int numFrames, out int numBones); Console.WriteLine("Printing bone curves for {0}(0x{1:X})", animationName, hash); Console.WriteLine("{0} transforms {1} bones over {2} frames...", animationName, numBones, numFrames); for (int i = 0; i < boneCRCs.Count; i++) { string boneName = args[3 + i]; uint boneHash = boneCRCs[i]; Console.WriteLine("\tBone #{0}: {1} (0x{2:X})", i, boneName, boneHash); bool status = bank.GetCurve(hash, boneHash, 0, out ushort[] inds, out float[] values); if (!status) { Console.WriteLine("\t\tFailed to fetch curve!"); TestBench.StopLogging(); return(-1); } Console.WriteLine("\t\tRotation X component: "); for (int j = 0; j < inds.Length && j < 5; j++) { Console.WriteLine("\t\t\t{0}: {1}", inds[j], values[j]); } } TestBench.StopLogging(); return(0); } } Console.WriteLine("Animation not found!"); TestBench.StopLogging(); return(-1); }
static int Main(string[] args) { TestBench testBench = new TestBench(); Container container = testBench.LoadAndTrackContainer(new List <string>(args), out List <Level> levels); Level level = levels[0]; if (level == null) { return(-1); } Model[] models = level.Get <Model>(); foreach (Model model in models) { Console.WriteLine("\n" + model.Name + ": "); /* * if (model.isSkeletonBroken) * { * Console.WriteLine("\tSkeleton is broken!!"); * } * * Console.WriteLine("\tSkeleton: "); * * Bone[] bones = model.skeleton; * * for (int k = 0; k < bones.Length; k++) * { * Console.WriteLine("\t\tName: {0} Parent: {1}", bones[k].name, bones[k].parentName); * } */ Segment[] segments = model.GetSegments(); int i = 0; foreach (Segment seg in segments) { Console.WriteLine("\tSegment " + i++ + ": "); float[] vBuf = seg.GetVertexBuffer <float>(); //string texName = seg.GetMaterialTexName(); VertexWeight[] weights = seg.GetVertexWeights(); Console.WriteLine("\t\tTopology: {0}", seg.Topology); float[] buffer = seg.GetNormalsBuffer <float>(); Console.WriteLine("\t\tNum positions: {0}, Num normals: {1}", vBuf.Length / 3, buffer.Length / 3); if (model.IsSkinned) { Console.WriteLine("\t\t{0} weights ---- {1} vertices.", weights.Length, seg.GetVertexBufferLength()); Console.WriteLine("\t\tIs pretransformed: {0}", seg.IsPretransformed); } else { Console.WriteLine("\t\tSegment belongs to bone: {0}", seg.BoneName); } Material mat = seg.Material; Console.WriteLine("\n\t\tMaterial textures used: "); foreach (string texName in mat.Textures) { if (texName == "") { continue; } Console.Write("\t\t\t" + texName); Texture tex = level.Get <Texture>(texName); if (tex != null) { Console.WriteLine(" Height: {0} Width: {1}", tex.Height, tex.Width); } } Console.WriteLine("\t\tMaterial flags: "); Console.WriteLine("\t\t\t{0}", seg.Material.MaterialFlags); } } return(0); }