void CheckTerrain(string id, int res) { instance = GetComponent<BC2Instance>().instance; string terrainLocation = Util.GetField("TerrainAsset", instance).reference; if (terrainLocation == "" || terrainLocation == null) { Util.Log("TerrainAsset is missing from " + instance.guid); } else { string guid = Util.GetGuid(terrainLocation); terrainLocation = Util.ClearGUIDString(terrainLocation); terrainLoc = terrainLocation; partition = Util.LoadPartition(terrainLocation); int terrainRes; if (res == 0) { terrainRes = TerrainRes(terrainLocation, guid); fullres = terrainRes; } else { terrainRes = res; } int terrainHeight = TerrainHeight(terrainLocation); LoadTerrain(terrainLocation, terrainRes, terrainHeight, id); } }
public static Vector3 CalculatePosition(Inst inst) { Vector3 pos = Vector3.zero; string bc2pos = null; if (Util.GetComplex("Transform", inst) != null || Util.GetComplex("Position", inst) != null) { Util.Log(inst.guid); if(Util.GetComplex("Transform", inst) != null && Util.GetComplex("Transform", inst).value != null) { bc2pos = Util.GetComplex("Transform", inst).value; } else if(Util.GetComplex("Position", inst) != null && Util.GetComplex("Position", inst).value != null) { bc2pos = Util.GetComplex("Position", inst).value; } if (bc2pos != null) { //Debug.Log("pos val for " + inst.guid + " | " + inst.complex.value); string coordiantes = bc2pos; string[] coords = coordiantes.Split ('/'); int numcoords = coords.Length; float z = float.Parse (coords [(numcoords - 4)]); float y = float.Parse (coords [(numcoords - 3)]); float x = float.Parse (coords [(numcoords - 2)]); pos = new Vector3 (x, y, z); } } else { pos = Vector3.zero; } return pos; }
public string GetMeshPath(Inst inst) { List<Partition> partitions = new List<Partition>(); string mesh = ""; if(inst.type == "Entity.ReferenceObjectData" && (Util.GetField("ReferencedObject", inst).reference != null || Util.GetField("ReferencedObject", inst).reference != "null")) { name = Util.GetField("ReferencedObject", inst).reference; string cleanName = Util.ClearGUIDString(name); string refGuid = Util.GetGuid(name); Partition refPartition = Util.LoadPartition(cleanName); partitions.Add(refPartition); if(refPartition != null && name != "null") { Inst bluePrint = Util.GetInst(refGuid, refPartition); string refObject = ""; if (bluePrint != null) { refObject = Util.GetField("Object", bluePrint).reference; } if (Util.GetInst(refObject, refPartition) != null) { Inst staticModelEntityData = Util.GetInst(refObject, refPartition); if (staticModelEntityData != null) { if (Util.GetField("Mesh", staticModelEntityData) != null) { string refMesh = Util.GetField("Mesh", staticModelEntityData).reference; string refMeshClean = Util.ClearGUIDString(refMesh); string refMeshGuid = Util.GetGuid(refMesh); Partition meshPartition = Util.LoadPartition(refMeshClean); if(meshPartition != null) { Inst rigidMeshAsset = Util.GetInst(refMeshGuid, meshPartition); if(rigidMeshAsset != null) { string refMeshMesh = Util.GetField("Name", rigidMeshAsset).value; mesh = refMeshMesh + "_lod0_data"; } } } } } } } return mesh; }
public byte[] Load(string path) { _prg = new List<Inst>(); _labels = new Dictionary<string, Inst>(); using(var f = File.OpenText(path)) { int line = 0; string str; string[] sa; int idx; Inst inst; while(!f.EndOfStream) { str = f.ReadLine(); line++; if(string.IsNullOrWhiteSpace(str)) { continue; } sa = str.Split(WHITE_SPACES, StringSplitOptions.RemoveEmptyEntries); if(sa == null || sa.Length == 0) { continue; } idx = 0; inst = new Inst(this, line); _prg.Add(inst); if(sa[0].StartsWith(":")) { // label inst.label = sa[0].Substring(1); _labels[inst.label] = inst; idx++; } if(idx < sa.Length) { if(!Enum.TryParse(sa[idx].ToUpper(), out inst.op)) { Log.Error("[{0}]{1} - unknown OpName", line, str); continue; } if(++idx < sa.Length) { inst.args = string.Join(" ", sa, idx, sa.Length - idx); } } } } int pc = 0; for(int i = 0; i < _prg.Count; i++) { _prg[i].pos = pc; pc += _prg[i].GetBytes(false).Length; } List<byte> code = new List<byte>(pc); for(int i = 0; i < _prg.Count; i++) { code.AddRange(_prg[i].GetBytes(true)); } return code.ToArray(); }
public void Start() { inst = this.gameObject.GetComponent<BC2Instance>().instance; BC2Array array = Util.GetArray("Points", inst); foreach (Item Item in array.item) { ml = Util.GetMapload(); Inst refPoint = Util.GetInst(Item.reference, ml.partition); points.Add(refPoint); } foreach(Inst point in points) { Complex posString = Util.GetComplex("Position", point); Vector3 pos = Util.CalculatePositionFromString(posString.value); pointPos.Add(pos); } LineRenderer LR = gameObject.AddComponent<LineRenderer>(); LR.SetVertexCount(pointPos.Count); for(int i = 0; i < pointPos.Count; i++) { LR.SetPosition(i, pointPos[i]); } BC2Array planes = Util.GetArray("Planes", inst); Inst plane = Util.GetInst(planes.item[0].reference, ml.partition); if(Util.GetField("PlaneType", plane).value == "Lake") { GeneratePlane gp = transform.gameObject.AddComponent<GeneratePlane>(); foreach(Vector3 v3 in pointPos) { gp.points.Add(v3); } Vector3 startpos = new Vector3(); startpos.y = pointPos[0].y; transform.position = startpos; transform.rotation = new Quaternion(0, 0, 0, 0); gp.Generate(); transform.GetComponent<MeshRenderer>().material = ml.waterMaterial; } }
public static string ClearGUID(Inst inst) { string name = "Unknown"; foreach (Field field in inst.field) { if (field.name == "ReferencedObject") { string pattern = "/[a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+[a-zA-Z0-9]+-[a-zA-Z0-9]+-[a-zA-Z0-9]+"; name = field.reference; name = Regex.Replace(name, pattern, ""); //Debug.Log(name); } } if (name == "Unknown" || name == "null" || name == null) { if (inst.type != null) { name = inst.type + " | " + inst.guid; } } return name; }
public static Matrix4x4 GenerateMatrix4x4(Inst inst) { Matrix4x4 matrix = new Matrix4x4(); string bc2rot = null; foreach(Complex complex in inst.complex) { if(complex.name == "Transform") { bc2rot = complex.value; } } if (IsObject(inst) && bc2rot != null) { string coordiantes = bc2rot; string[] coords = coordiantes.Split ('/'); int numcoords = coords.Length; if(numcoords > 3) { float rz = (float.Parse (coords [0]) * -1); float ry = (float.Parse (coords [1]) * -1); float rx = (float.Parse (coords [2]) * -1); float uz = (float.Parse (coords [4])); float uy = (float.Parse (coords [5])); float ux = (float.Parse (coords [6])); float fz = (float.Parse (coords [8])); float fy = (float.Parse (coords [9])); float fx = (float.Parse (coords [10])); float px = (float.Parse (coords [12])); float py = (float.Parse (coords [13])); float pz = (float.Parse (coords [14])); matrix.SetColumn(0, new Vector4(rx,ry,rz,0)); matrix.SetColumn(1, new Vector4(ux,uy,uz,0)); matrix.SetColumn(2, new Vector4(fx,fy,fz,0)); matrix.SetColumn(3, new Vector4(px,py,pz,0)); } } return matrix; }
public void Call() { var sim = PowerUp(); var tl = sim.TopLevel; var instructions = Inst.FromAsmFile("irq_call"); sim.inputsModifier = (inputs, context) => { // let it run for 100 cycles, then raise IRQ if (context.Clock >= 100) { inputs.ExtIRQ = true; } }; sim.RunAll(instructions); // should be stuck and end label Assert.AreEqual(tl.Regs.State.x[11], (uint)tl.State.PC); Assert.AreEqual(0xFFU, tl.Regs.State.x[12]); Assert.AreEqual(0x1FFU, tl.Regs.State.x[13]); }
public OpCodeMov64(Inst inst, long position, int opCode) : base(inst, position, opCode) { int p1 = (opCode >> 22) & 1; int sf = (opCode >> 31) & 1; if (sf == 0 && p1 != 0) { Emitter = InstEmit.Und; return; } Rd = (opCode >> 0) & 0x1f; Imm = (opCode >> 5) & 0xffff; Pos = (opCode >> 21) & 0x3; Pos <<= 4; Imm <<= Pos; RegisterSize = (opCode >> 31) != 0 ? State.RegisterSize.Int64 : State.RegisterSize.Int32; }
public void AssignLakeMesh() { Inst plane = transform.GetComponent <BC2Instance> ().instance; GameObject go = (GameObject)Instantiate(Util.GetMapload().empty, new Vector3(0, positionPoints[0].transform.position.y, 0), Quaternion.identity); GeneratePlane gp = go.gameObject.AddComponent <GeneratePlane> (); go.transform.parent = transform; go.transform.name = "Water"; foreach (GameObject pos in positionPoints) { gp.points.Add(pos.transform.position); } transform.localScale = Vector3.one; Vector3 startpos = new Vector3(0, 0, 0); startpos.y = gp.points [0].y; //transform.position = startpos; //transform.rotation = new Quaternion (0, 0, 0, 0); gp.Generate(); go.GetComponent <MeshRenderer> ().material = Util.GetMapload().waterMaterial; }
public void GenerateHavokItem2(Inst inst) { // if (inst.array != null) { // foreach (BC2Array array in inst.array) { // if(array.name == "Assets") { // int i = 0; // foreach (Item item in array.item) { // string name = CleanName(item.reference); // string modelname = name; // string actualmodelname = name + "_lod0_data"; // string actualmodelname2 = name + "_mesh_lod0_data"; // //Debug.Log(actualmodelname); // if(Util.FileExist(actualmodelname)) { // modelname = actualmodelname; // } else if(Util.FileExist(actualmodelname2)) { // modelname = actualmodelname2; // } else { // modelname = "Unknown"; // } // if(modelname != "Unknown") { // // GameObject go = Util.LoadMesh(modelname) as GameObject; // Vector3 pos = positions[i]; // GameObject instGO = Instantiate(go, pos, Quaternion.identity) as GameObject; // Quaternion rot = MatrixHelper.QuatFromMatrix(matrix[i]); // instGO.transform.rotation = rot; // instGO.name = name; // instGO.transform.parent = transform; // i++; // } else { // Debug.Log("Could not load file " + name); // } // } // } // } // } }
/// <summary> /// Sets the element and property that the animation will be applied to. /// </summary> public void SetTarget(GuiElement element, string property) { lock (Locker) { if (element == null) { throw new ArgumentException("The target element cannot be null."); } if (string.IsNullOrEmpty(property)) { throw new ArgumentException("The target property cannot be null or empty."); } var prop = element.GetType().GetProperty(property); var instAttr = prop?.DeclaringType?.GetCustomAttribute <TypeIdAttribute>(); var memberAttr = prop?.GetCustomAttribute <InstMemberAttribute>(); if (prop == null) { throw new ArgumentException($"No property found for \"{property}\"."); } if (prop.PropertyType != TargetType) { throw new ArgumentException( $"The animation type ({TargetType}) does not match the property type of \"{property}\" ({prop.PropertyType})."); } if ((memberAttr == null) || (instAttr == null)) { throw new ArgumentException($"The property {property} of {element} cannot be animated."); } TargetProperty = Inst.TypeDictionary[element.ClassName].TaggedProperties[ Inst.EncodePropertyTag(instAttr.Id, memberAttr.Tag)]; TargetElement = element; } }
public override void Initialize(ContentManager Content) { base.Initialize(Content); Rot = RandomFloatInRange(0, 2.0f * JabMath.PI); CreateFramesFromXML("ui/ui_frames"); CurrentFrame = "feather"; ResetDimensions(); UniformScale = ScaleFactor * 0.45f;// *2.5f; for (float y = Camera.Get.ScreenToWorld(Vector2.Zero).X + BaseGame.Get.BackBufferHeight * 3.0f; y > 0; y -= Height * ScaleY * 1.0f) { for (float i = Camera.Get.ScreenToWorld(Vector2.Zero).X; i < Camera.Get.ScreenToWorld(Vector2.One).X; i += 5 * ScaleFactor)// / 1.5f) { if (RandomFloatInRange(0, 400 * ScaleFactor) < 10) { Inst s = new Inst(); s.PosX = i; s.PosY = Camera.Get.ScreenToWorld(Vector2.Zero).Y + ScaleFactor * 2.5f + y; s.InitialYPos = s.PosY; feathers.Add(s); } } } /* * for (int i = -100; i < 100; i++) * { * Inst s = new Inst(); * s.PosX = i * Width * ScaleX; * s.PosY = Camera.Get.ScreenToWorld(Vector2.Zero).Y + ScaleFactor * 2.5f; ; * feathers.Add(s); * }*/ UniformScale = ScaleFactor * 2.5f; }
// 等待ACK/NACK private async Task <bool> WaitAck(int timeout = 1000) { var ret = false; try { int token = 0; await Task.Run(() => { Inst.ReadTimeout = timeout; token = Inst.ReadByte(); }); if (token == ACK) { ret = true; } } catch (Exception) { // ignore } return(ret); }
private void MultiSelectInst() { var lst = GetSelectedInsts(); if (1 == lst.Count) { var fm = new InstInfoDialog(mPack, lst[0]); fm.ShowDialog(); DispInstList(); return; } if (1 < lst.Count) { var inst = new Inst(); var fm = new InstInfoDialog(mPack, inst); fm.ShowDialog(); foreach (var p in lst) { p.Info.Category = inst.Info.Category; } DispInstList(); return; } }
public void GenerateHavokItem(Inst inst) { if (inst.array != null) { foreach (BC2Array array in inst.array) { if(array.name == "Assets") { int i = 0; foreach (Item item in array.item) { string name = CleanName(item.reference); string modelname = name; string actualmodelname = name + "_lod0_data"; string actualmodelname2 = name + "_mesh_lod0_data"; //Debug.Log(actualmodelname); if(Resources.Load(actualmodelname) != null) { modelname = actualmodelname; } else if(Resources.Load(actualmodelname2) != null) { modelname = actualmodelname2; } else { modelname = "Unknown"; } if(modelname != "Unknown") { GameObject go = Resources.Load(modelname) as GameObject; Vector3 pos = positions[i]; GameObject instGO = Instantiate(go, pos, Quaternion.identity) as GameObject; Quaternion rot = MatrixHelper.QuatFromMatrix(matrix[i]); instGO.transform.rotation = rot; instGO.name = name; instGO.transform.parent = transform; i++; } else { Debug.Log("Could not load file " + name); } } } } } }
public override async Task <bool> Probe() { byte[] probeByte = { ProbeCmd }; var ret = false; AppendLog("开始连接..."); var StartTime = DateTime.Now; for (var i = 0; i < _tryTime; i++) { ProgressReport("连接芯片中...", i, _tryTime); Inst.Write(probeByte, 0, 1); if (await WaitAck()) { AppendLog($"连接成功,耗时{(DateTime.Now - StartTime).TotalMilliseconds}毫秒"); ret = true; break; } await Task.Delay(1000); } ProgressReport("连接芯片成功", 0, 1); return(ret); }
public static bool IsObject(Inst inst) { if(GetPosition(inst) == Vector3.zero) { return false; } else { return true; } }
// Horrible! //public IEnumerator GenerateItem(Inst inst) { void GenerateItem(Inst inst) { Vector3 pos = Util.GetPosition (inst); Quaternion rot = Util.GetRotation (inst); string name = "Unknown"; string mesh = inst.type + " | " + inst.guid; List<Partition> partitions = new List<Partition>(); //This part is just trying to get the actual model name. It goes through different partitions and blueprints in order to get an accurate model name. //Normally, it's fine to just do name + _lod0_data, but sometimes we have objects that reference non-existant objects, such as container_large_blue. //While container_large exists, _blue is just referencing an other instance, and thus an other material for said container. //It's mostly not an issue. if(inst.type == "Entity.ReferenceObjectData" && Util.GetField("ReferencedObject", inst) != null && (Util.GetField("ReferencedObject", inst).reference != null && Util.GetField("ReferencedObject", inst).reference != "null")) { name = Util.GetField("ReferencedObject", inst).reference; string cleanName = Util.ClearGUIDString(name); string refGuid = Util.GetGuid(name); Partition refPartition = Util.LoadPartition(cleanName); partitions.Add(refPartition); if(refPartition != null && name != "null") { Inst bluePrint = Util.GetInst(refGuid, refPartition); string refObject = ""; if (bluePrint != null) { refObject = Util.GetField("Object", bluePrint).reference; } if (Util.GetInst(refObject, refPartition) != null) { Inst staticModelEntityData = Util.GetInst(refObject, refPartition); if (staticModelEntityData != null) { if (Util.GetField("Mesh", staticModelEntityData) != null) { string refMesh = Util.GetField("Mesh", staticModelEntityData).reference; string refMeshClean = Util.ClearGUIDString(refMesh); string refMeshGuid = Util.GetGuid(refMesh); Partition meshPartition = Util.LoadPartition(refMeshClean); if(meshPartition != null) { Inst rigidMeshAsset = Util.GetInst(refMeshGuid, meshPartition); if(rigidMeshAsset != null) { string refMeshMesh = Util.GetField("Name", rigidMeshAsset).value; mesh = refMeshMesh + "_lod0_data"; } } } } } } } string meshpath = "Resources/" + mesh + ".meshdata"; GameObject go = null; List<Mesh> subsetMesh = new List<Mesh> (); List<string> subsetNames = new List<string> (); if (Util.FileExist (meshpath)) { BC2Mesh bc2mesh = null; go = Instantiate (empty, Vector3.zero, Quaternion.identity) as GameObject; if (!(instantiatedMeshDictionary.TryGetValue (mesh, out bc2mesh))) { bc2mesh = MeshDataImporter.LoadMesh(meshpath); foreach(string s in subsetNames) { Debug.Log(s); } instantiatedMeshDictionary.Add (mesh, bc2mesh); } int subsetInt = 0; subsetMesh = bc2mesh.subMesh; subsetNames = bc2mesh.subMeshNames; foreach(Mesh sub in subsetMesh) { GameObject subGO = (GameObject) Instantiate(empty,Vector3.zero,Quaternion.identity); MeshRenderer mr = subGO.AddComponent<MeshRenderer>(); MeshFilter mf = subGO.AddComponent<MeshFilter>(); MeshCollider mc = subGO.AddComponent<MeshCollider> (); if (Regex.IsMatch (subsetNames [subsetInt].ToLower (), "glass")) { mr.material = glassMaterial; } else { mr.material = new Material (materialwhite); } mr.material.name = subsetNames[subsetInt]; mf.mesh = sub; mf.mesh.RecalculateNormals(); subGO.name = subsetNames[subsetInt]; subGO.transform.parent = go.transform; mc.sharedMesh = mf.mesh; subsetInt++; } if (bc2mesh.inverted) { Vector3 localScale = go.transform.localScale; localScale.x *= -1; go.transform.localScale = localScale; } } else { go = Instantiate (placeholder.gameObject, pos, rot) as GameObject; } go.name = Util.ClearGUID (inst); //go.AddComponent<MeshRenderer>().material.color = new Color (UnityEngine.Random.Range (0.1f, 1.0f), UnityEngine.Random.Range (0.1f, 1.0f), UnityEngine.Random.Range (0.1f, 1.0f)); GameObject parent = transform.GetComponent<MapItems>().SelectParent(inst.type); go.transform.parent = parent.transform; Matrix4x4 matrix = Util.GenerateMatrix4x4 (inst); Quaternion newQuat = MatrixHelper.QuatFromMatrix(matrix); //Quaternion newQuat = go.transform.localRotation; //newQuat.x *= -1; //newQuat.z *= -1f; go.transform.localRotation = newQuat; go.transform.position = pos; if (inst.type == "Entity.ReferenceObjectData") { Vector3 scale = go.transform.localScale; scale.x *= -1; // the meshimporter is inverted. This is a workaround. go.transform.localScale = scale; if(Regex.IsMatch(go.name.ToLower() ,"invisiblewall")) { go.GetComponentInChildren<MeshRenderer>().material = new Material(materialInvisibleWall); } } BC2Instance instance = go.AddComponent<BC2Instance>(); instance.instance = inst; instance.id = i; instance.mapLoad = this; instance.partitions = partitions; instantiatedGameObjects.Add(go.gameObject); instantiatedDictionary.Add (inst.guid.ToUpper(), go.gameObject); i++; // yield return null; }
public static BC2Array GetArray(string name, Inst inst) { BC2Array ret = null; if (inst == null) { Debug.Log("Didn't find shit like inst"); } if (inst.array != null) { foreach (BC2Array array in inst.array) { if (array.name == name) { ret = array; } } } return ret; }
void GenerateItem(Inst inst) { Vector3 pos = Util.CalculatePosition (inst); string name = "Unknown"; string mesh = inst.type + " | " + inst.guid; List<Partition> partitions = new List<Partition>(); Partition partition = new Partition(); if(inst.type == "Entity.ReferenceObjectData" && (Util.GetField("ReferencedObject", inst).reference != null || Util.GetField("ReferencedObject", inst).reference != "null")) { name = Util.GetField("ReferencedObject", inst).reference; string cleanName = Util.ClearGUIDString(name); string refGuid = Util.GetGuid(name); Partition refPartition = Util.LoadPartition(cleanName); partitions.Add(refPartition); if(refPartition != null && name != "null") { Inst bluePrint = Util.GetInst(refGuid, refPartition); string refObject = ""; if (bluePrint != null) { refObject = Util.GetField("Object", bluePrint).reference; } if (Util.GetInst(refObject, refPartition) != null) { Inst staticModelEntityData = Util.GetInst(refObject, refPartition); if (staticModelEntityData != null) { if (Util.GetField("Mesh", staticModelEntityData) != null) { string refMesh = Util.GetField("Mesh", staticModelEntityData).reference; string refMeshClean = Util.ClearGUIDString(refMesh); string refMeshGuid = Util.GetGuid(refMesh); Partition meshPartition = Util.LoadPartition(refMeshClean); if(meshPartition != null) { Inst rigidMeshAsset = Util.GetInst(refMeshGuid, meshPartition); if(rigidMeshAsset != null) { string refMeshMesh = Util.GetField("Name", rigidMeshAsset).value; mesh = refMeshMesh + "_lod0_data"; } } } } } } } GameObject model; //string actualmodelname = Util.ClearGUID(inst) + "_lod0_data"; //string actualmodelname2 = Util.ClearGUID(inst) + "_mesh_lod0_data"; if(Resources.Load(mesh)) { model = Resources.Load(mesh) as GameObject; } else { if(inst.type == "Terrain.TerrainSplineData") { model = empty; } else { model = placeholder.gameObject; } } //if(Resources.Load(mesh) != null) { // model = Resources.Load(actualmodelname) as GameObject; //} else if(Resources.Load(actualmodelname2) != null) { // model = Resources.Load(actualmodelname2) as GameObject; //} else { // if (inst.type == "Terrain.TerrainSplineData") // { // model = empty.gameObject; // } // else // { // model = placeholder.gameObject; // } //} GameObject go = GameObject.Instantiate(model, pos, Quaternion.identity) as GameObject; go.name = Util.ClearGUID (inst); GameObject parent = transform.GetComponent<MapItems>().SelectParent(inst.type); go.transform.parent = parent.transform; Matrix4x4 matrix = Util.GenerateMatrix4x4 (inst); Quaternion newQuat = MatrixHelper.QuatFromMatrix(matrix); //Quaternion newQuat = go.transform.localRotation; //newQuat.x *= -1; //newQuat.z *= -1f; go.transform.rotation = newQuat; BC2Instance instance = go.AddComponent<BC2Instance>(); instance.instance = inst; instance.id = i; instance.mapLoad = this; InstGameObject instGameObject = new InstGameObject (); instGameObject.GUID = inst.guid; instGameObject.GO = go; InstGameObjects.Add (instGameObject); i++; }
void GeneratePosRot(Inst inst) { int i = -1; string coordinates = null; if (inst.array != null) { foreach (BC2Array array in inst.array) { if (array.name == "Transforms") { coordinates = array.value; //Debug.Log(coordinates); } } string[] coords = coordinates.Split ('/'); //int numcoords = coords.Length; //Debug.Log(numcoords); while(i < coords.Length - 1) { Matrix4x4 m = new Matrix4x4(); float rz = float.Parse (coords [i + 1]) * -1; float ry = float.Parse (coords [i + 2]) * -1; float rx = float.Parse (coords [i + 3]) * -1; float uz = float.Parse (coords [i + 5]); float uy = float.Parse (coords [i + 6]); float ux = float.Parse (coords [i + 7]); float fz = float.Parse (coords [i + 9]); float fy = float.Parse (coords [i + 10]); float fx = float.Parse (coords [i + 11]); float z = float.Parse (coords [(i + 13)]); float y = float.Parse (coords [(i + 14)]); float x = float.Parse (coords [(i + 15)]); m.SetColumn(0, new Vector4(rx, ry, rz, 0)); m.SetColumn(1, new Vector4(ux, uy, uz, 0)); m.SetColumn(2, new Vector4(fx, fy, fz, 0)); m.SetColumn(3, new Vector4(x, y, z, 0)); Vector3 pos = new Vector3(x,y,z); matrix.Add(m); positions.Add(pos); i+=16; } } }
public static Quaternion GetRotation(Inst inst) { Matrix4x4 matrix = Util.GenerateMatrix4x4 (inst); Quaternion newQuat = MatrixHelper.QuatFromMatrix(matrix); return newQuat; }
public override void Initialize(ContentManager Content) { base.Initialize(Content); Rot = RandomFloatInRange(0, 2.0f * JabMath.PI); CreateFramesFromXML("ui/ui_frames"); CurrentFrame = "feather"; ResetDimensions(); UniformScale = ScaleFactor * 0.45f;// *2.5f; for (float y = Camera.Get.ScreenToWorld(Vector2.Zero).X + BaseGame.Get.BackBufferHeight * 3.0f; y > 0; y -= Height * ScaleY * 1.0f) { for (float i = Camera.Get.ScreenToWorld(Vector2.Zero).X; i < Camera.Get.ScreenToWorld(Vector2.One).X; i += 5 * ScaleFactor)// / 1.5f) { if (RandomFloatInRange(0, 400 * ScaleFactor) < 10) { Inst s = new Inst(); s.PosX = i; s.PosY = Camera.Get.ScreenToWorld(Vector2.Zero).Y + ScaleFactor * 2.5f + y; s.InitialYPos = s.PosY; feathers.Add(s); } } } /* for (int i = -100; i < 100; i++) { Inst s = new Inst(); s.PosX = i * Width * ScaleX; s.PosY = Camera.Get.ScreenToWorld(Vector2.Zero).Y + ScaleFactor * 2.5f; ; feathers.Add(s); }*/ UniformScale = ScaleFactor *2.5f; }
public static Field GetField(string name, Inst inst) { Field ret = null; if (inst != null) { foreach (Field field in inst.field) { if (field.name == name) { ret = field; } } } return ret; }
public static Complex GetComplex(string name, Inst inst) { Complex ret = null; foreach (Complex complex in inst.complex) { if (complex.name == name) { ret = complex; } } return ret; }
public void GenerateHavokItem(Inst inst) { string coordinatestring = ""; if (inst.array != null) { foreach (BC2Array array in inst.array) { if (array.name == "Transforms") { coordinatestring = array.value; GeneratePosRot (coordinatestring); } if (array.name == "Assets") { int i = 0; foreach(Item item in array.item) { Vector3 pos = positions [i]; Quaternion rot = MatrixHelper.QuatFromMatrix(matrix[i]); string name = CleanName (item.reference); string modelName = name; string actualModelName = name + "_lod0_data.meshdata"; string actualModelName2 = name + "_mesh_lod0_data.meshdata"; if (Util.FileExist ("Resources/"+actualModelName)) { modelName = actualModelName; } else if (Util.FileExist ("Resources/"+actualModelName2)) { modelName = actualModelName2; } else { modelName = "Havok_unknown"; } if (modelName != "Havok_unknown") { // if (instantiatedDictionary.ContainsKey (name)) { // instantiatedDictionary.TryGetValue (name, out go); // Util.Log ("Saving time on caching yo"); // } else { GameObject go = loadMesh ("Resources/" + modelName); // instantiatedDictionary.Add (name, go.gameObject); // } // go.transform.position = pos; go.transform.rotation = rot; go.transform.localScale = Vector3.one; Vector3 scale = go.transform.localScale; scale.x *= -1; go.transform.localScale = scale; go.name = name; go.transform.parent = transform; HavokItem hi = go.AddComponent<HavokItem> (); hi.ID = i; hi.pos = pos; hi.rot = rot; gameObjects.Add (go); } i++; } } } } }