protected override void Check() { var m = new M2(); m.Roots.ShouldBe(new[] { m.A, m.B, m.C, m.D() }, ignoreOrder: true); m.Components.ShouldBe(new[] { m.A, m.B, m.C, m.D() }, ignoreOrder: true); m.Faults.ShouldBeEmpty(); }
public void AddShelvesTest() { var m1 = new M1(2, 50); var groupIds =new int[]{49, 50, 51, 52}; var m2 = new M2(groupIds); var m3 = new M3(49, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg"); var imgs = new string[] { "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg" }; var m4 = new M4(groupIds, imgs); var m5 = new M5(groupIds, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg"); var result = ShelfApi.AddShelves("accessToken", m1, m2, m3, m4, m5, "http://img0.bdstatic.com/img/image/shouye/dengni57.jpg", "测试货架"); Console.Write(result); Assert.IsNotNull(result); }
protected override void Check() { var m1 = new M2(); var s = new Simulator(m1); var m2 = (M2)s.Model; m2.A.I.ShouldBe(m1.A.I); m2.B.I.ShouldBe(m1.B.I); m2.C.I.ShouldBe(m1.C.I); m2.D().I.ShouldBe(m1.D().I); m2.Roots.ShouldBe(new[] { m2.A, m2.B, m2.C, m2.D() }, ignoreOrder: true); m2.Components.ShouldBe(new[] { m2.A, m2.B, m2.C, m2.D() }, ignoreOrder: true); m2.Faults.ShouldBeEmpty(); }
public static int Main () { M2 m2 = new M2(); // Expecting failure try { var DLL = Assembly.LoadFile(@"test-multi-netmodule-3-dll2.dll"); var m3Type = DLL.GetType("M3"); var m3 = Activator.CreateInstance(m3Type); var m3m1Field = m3Type.GetField("m1"); Console.WriteLine("M3 assembly:" + m3Type.Assembly); Console.WriteLine("M3.M1 assembly:" + m3m1Field.DeclaringType.Assembly); } catch (System.TypeLoadException) { return 0; } Console.WriteLine("M2 assembly:" + typeof (M2).Assembly); Console.WriteLine("M2.M1 assembly:" + m2.m1.GetType().Assembly); return 1; }
//перегрузка оператора умножения для матриц public static Matrix operator *(Matrix M1, Matrix M2) { if (M1.ColumnNumber() != M2.RowNumber()) throw new Exception("Матрицы нельзя перемножить"); else { int nn=M1.RowNumber(); int kk=M2.ColumnNumber(); double[,] matr = new double[nn, kk]; for (int i = 0; i < nn; i++) { for (int j = 0; j < kk; j++) matr[i, j] = 0; } for (int i = 0; i < nn; i++) { for (int j = 0; j < kk; j++) { for (int s = 0; s < M2.RowNumber(); s++) matr[i, j] += M1[i, s] * M2[s, j]; } } Matrix M = new Matrix(nn, kk, matr); return M; } }
IEnumerator Merit() { yield return(new WaitForSeconds(Pause * 2)); M1.SetActive(true); yield return(new WaitForSeconds(Pause)); M2.SetActive(true); yield return(new WaitForSeconds(Pause)); M3.SetActive(true); yield return(new WaitForSeconds(Pause)); M4.SetActive(true); yield return(new WaitForSeconds(Pause)); M5.SetActive(true); yield return(new WaitForSeconds(Pause * 2)); Victory.SetActive(true); yield return(new WaitForSeconds(Pause * 2)); Application.LoadLevel("Credits"); }
public GilneanFemale(M2 model, Character character) { Model = model; Character = character; }
public void Pool <T, U, V, W>(M2 <T, U, V, W> m) { PrivatePool(m); }
public void Spawn <T, U, V, W>(M2 <T, U, V, W> m) { PrivateSpawn(m); }
public OrcMale(M2 model, Character character) { Model = model; Character = character; }
public void SyncContext <T, U, V, W>(M2 <T, U, V, W> m) { SyncContext(m); }
public WorgenFemale(M2 model, Character character) { Model = model; Character = character; }
public PandarenFemale(M2 model, Character character) { Model = model; Character = character; }
private static M2 Transform(M2Model model, IEnumerable<int> indicies, MapDoodadDefinition mddf) { var currentM2 = new M2(); currentM2.Vertices.Clear(); currentM2.Indices.Clear(); var posX = (mddf.Position.X - TerrainConstants.CenterPoint)*-1; var posY = (mddf.Position.Y - TerrainConstants.CenterPoint)*-1; var origin = new Vector3(posX, posY, mddf.Position.Z); // Create the scale matrix used in the following loop. Matrix scaleMatrix; Matrix.CreateScale(mddf.Scale, out scaleMatrix); // Creation the rotations var rotateZ = Matrix.CreateRotationZ(MathHelper.ToRadians(mddf.OrientationB + 180)); var rotateY = Matrix.CreateRotationY(MathHelper.ToRadians(mddf.OrientationA)); var rotateX = Matrix.CreateRotationX(MathHelper.ToRadians(mddf.OrientationC)); var worldMatrix = Matrix.Multiply(scaleMatrix, rotateZ); worldMatrix = Matrix.Multiply(worldMatrix, rotateX); worldMatrix = Matrix.Multiply(worldMatrix, rotateY); for (var i = 0; i < model.BoundingVertices.Length; i++) { var position = model.BoundingVertices[i]; var normal = model.BoundingNormals[i]; // Scale and Rotate Vector3 rotatedPosition; Vector3.Transform(ref position, ref worldMatrix, out rotatedPosition); Vector3 rotatedNormal; Vector3.Transform(ref normal, ref worldMatrix, out rotatedNormal); rotatedNormal.Normalize(); // Translate Vector3 finalVector; Vector3.Add(ref rotatedPosition, ref origin, out finalVector); currentM2.Vertices.Add(finalVector); } currentM2.Indices.AddRange(indicies); return currentM2; }
public SyncMethod NewSyncMethod <T, U, V, W>(M2 <T, U, V, W> @delegate) { return(new SyncMethod(this, @delegate)); }
public void Do <T, U, V, W, X>(M2 <T, U, V, W, X> m) { DoAny(m); }
public void Do <T, U, V, W, X, Y, Z>(M2 <T, U, V, W, X, Y, Z> m) { DoAny(m); }
public void Do <T, U, V>(M2 <T, U, V> m) { DoAny(m); }
public void Do <T, U>(M2 <T, U> m) { DoAny(m); }
public void SyncContext <T, U, V, W>(M2 <T, U, V, W> m) { PrivateSyncContext(m); }
public void M2(M2 input) { }
public (Mesh, Texture2D[]) M2ToMesh(CASCFile file) { Mesh m2Mesh = new Mesh(); BinaryReader br = new BinaryReader(new MemoryStream(CascFileBytes(file))); // New BinaryReader for the file in MemoryStream br.BaseStream.Seek(0, SeekOrigin.Begin); // Go the the beginning of the stream // Manually Parsing the File /* * while (br.BaseStream.Position < br.BaseStream.Length) { // Advance the reader position until the end of the file * //string chunkID = System.Text.Encoding.UTF8.GetString(br.ReadBytes(4)); // Reading first 4 bytes of a chunk will give us the ID * //int chunkID = (int)br.ReadUInt32(); // Maybe better to use INT for performance, opting for string for readability * ChunkID chunkID = (ChunkID)br.ReadUInt32(); * long chunkSize = (long)br.ReadUInt32(); // Get the size in bytes of the current chunk * long nextChunkPos = br.BaseStream.Position + chunkSize; // The next chunk will be from the current reader's position + size of current chunk * * // Process current chunk * switch (chunkID) { * case ChunkID.MD21: // MD21 Header * ParseChunkMD21(); * break; * case ChunkID.SFID: // Skin File IDs * ParseChunkSFID(); * break; * case ChunkID.TXID: // Texture File IDs * ParseChunkTXID(); * break; * } * br.BaseStream.Seek(nextChunkPos, SeekOrigin.Begin); // Advance the reader position to the the next chunk and proceed with loop * Debug.Log("Processed ChunkID: " + chunkID); // Name of current chunk * }*/ var model = new M2(); model.Load(br); //Debug.Log(model.Name + " loaded"); //Debug.Log(model.Version); Debug.Log("nViews: " + model.nViews); Debug.Log("Texture Count: " + model.Textures.Count); Texture2D[] textures = new Texture2D[model.Textures.Count]; for (int i = 0; i < model.Textures.Count; i++) { Debug.Log("Texture File: " + model.Textures[i].Name + "FileDataID: " + model.Textures[i].FileDataID); Texture2D tex = BlpToTexture2d(GetCascFile(model.Textures[i].FileDataID)); textures[i] = tex; } if (model.Views.Count > 0) { for (int i = 0; i < model.Views.Count; i++) { //var substream = stream.BaseStream as Substream; //var path = substream != null ? ((FileStream)substream.GetInnerStream()).Name : ((FileStream)stream.BaseStream).Name; //using (var skinFile = new BinaryReader(new FileStream(M2SkinProfile.SkinFileName(path, i), FileMode.Open))) using (var skinFile = new BinaryReader(new MemoryStream(CascFileBytes(GetCascFile(model.Views[i].FileDataID))))) { model.Views[i].Load(skinFile, model.Version); model.Views[i].LoadContent(skinFile, model.Version); } Debug.Log("Skin File: " + model.Views[i].FileDataID); } } Vector3[] vertices = new Vector3[model.GlobalVertexList.Count]; Vector3[] normals = new Vector3[model.GlobalVertexList.Count]; Vector2[] uv1 = new Vector2[model.GlobalVertexList.Count]; Vector2[] uv2 = new Vector2[model.GlobalVertexList.Count]; int index = 0; foreach (M2Vertex v in model.GlobalVertexList) { vertices[index] = new Vector3(v.Position.y, v.Position.z, -v.Position.x); normals[index] = new Vector3(v.Normal.y, v.Normal.z, -v.Normal.x); uv1[index] = v.TexCoords[0]; uv2[index] = v.TexCoords[1]; index++; } int[] triangles = new int[model.Views[0].Triangles.Count]; for (int i = 0; i < model.Views[0].Triangles.Count; i++) { triangles[i] = (int)model.Views[0].Triangles[i]; } // Compltely Wrong /* * for (int i = 0; i < model.Views[0].Submeshes.Count; i++) { * M2SkinSection sub = model.Views[0].Submeshes[i]; * SubMeshDescriptor smd = new SubMeshDescriptor(); * smd.baseVertex = sub.StartVertex; * Bounds bounds = new Bounds(sub.CenterBoundingBox, new Vector3(sub.Radius, sub.Radius, sub.Radius)); // radius isn't correct * smd.bounds = bounds; * smd.firstVertex = 0; ///? * smd.indexCount = 3; * smd.indexStart = sub.StartVertex; * smd.topology = MeshTopology.Triangles; * smd.vertexCount = sub.NVertices; * m2Mesh.SetSubMesh(i, smd, MeshUpdateFlags.Default); * }*/ m2Mesh.vertices = vertices; m2Mesh.normals = normals; m2Mesh.triangles = triangles.Reverse().ToArray(); // Reverses the faces m2Mesh.uv = uv1; m2Mesh.uv2 = uv2; return(m2Mesh, textures); }
public override void OnImportAsset(UnityEditor.AssetImporters.AssetImportContext ctx) { //Load file contents M2 file = new M2(); file.LoadFile(ctx.assetPath); //Prepare blank asset GameObject model = new GameObject(); model.AddComponent <Animator>(); model.AddComponent <SkinnedMeshRenderer>(); SkinnedMeshRenderer renderer = model.GetComponent <SkinnedMeshRenderer>(); Mesh mesh = new Mesh(); mesh.name = file.Name + "_mesh"; //Fill vertex data Vector3[] vertices = new Vector3[file.Vertices.Length]; Vector3[] normals = new Vector3[file.Vertices.Length]; BoneWeight[] weights = new BoneWeight[file.Vertices.Length]; Vector2[] uv = new Vector2[file.Vertices.Length]; Vector2[] uv2 = new Vector2[file.Vertices.Length]; for (int i = 0; i < file.Vertices.Length; i++) { vertices[i] = new Vector3(-file.Vertices[i].Position.X / 2, file.Vertices[i].Position.Z / 2, -file.Vertices[i].Position.Y / 2); normals[i] = new Vector3(-file.Vertices[i].Normal.X, file.Vertices[i].Normal.Z, -file.Vertices[i].Normal.Y); BoneWeight weight = new BoneWeight { boneIndex0 = file.Vertices[i].Bones[0], boneIndex1 = file.Vertices[i].Bones[1], boneIndex2 = file.Vertices[i].Bones[2], boneIndex3 = file.Vertices[i].Bones[3], weight0 = file.Vertices[i].Weights[0] / 255f, weight1 = file.Vertices[i].Weights[1] / 255f, weight2 = file.Vertices[i].Weights[2] / 255f, weight3 = file.Vertices[i].Weights[3] / 255f }; weights[i] = weight; uv[i] = new Vector2(file.Vertices[i].UV[0].X, 1 - file.Vertices[i].UV[0].Y); uv2[i] = new Vector2(file.Vertices[i].UV[1].X, 1 - file.Vertices[i].UV[1].Y); } mesh.vertices = vertices; mesh.normals = normals; mesh.boneWeights = weights; mesh.uv = uv; mesh.uv2 = uv2; //Fill Submesh data mesh.subMeshCount = file.Skin.Submeshes.Length; for (int i = 0; i < mesh.subMeshCount; i++) { int[] triangles = new int[file.Skin.Submeshes[i].Count]; for (int j = 0; j < triangles.Length; j++) { triangles[j] = file.Skin.Indices[file.Skin.Submeshes[i].Start + j]; } mesh.SetTriangles(triangles, i); } //Generate bones Transform[] bones = new Transform[file.Skeleton.Bones.Length]; for (int i = 0; i < bones.Length; i++) { bones[i] = new GameObject("Bone" + i).transform; bones[i].position = new Vector3(-file.Skeleton.Bones[i].Pivot.X / 2, file.Skeleton.Bones[i].Pivot.Z / 2, -file.Skeleton.Bones[i].Pivot.Y / 2); } GameObject skeleton = new GameObject("Skeleton"); for (int i = 0; i < bones.Length; i++) { if (file.Skeleton.Bones[i].Parent == -1) { bones[i].parent = skeleton.transform; } else { bones[i].parent = bones[file.Skeleton.Bones[i].Parent]; } } Matrix4x4[] bind = new Matrix4x4[bones.Length]; for (int i = 0; i < bones.Length; i++) { bind[i] = bones[i].worldToLocalMatrix * model.transform.localToWorldMatrix; } skeleton.transform.parent = model.transform; renderer.materials = new Material[mesh.subMeshCount]; renderer.sharedMesh = mesh; renderer.bones = bones; renderer.rootBone = bones[0]; mesh.bindposes = bind; //Seralize data in json so they can be accessible at runtime TextAsset json = new TextAsset(JsonConvert.SerializeObject(file)); json.name = file.Name + "_data"; model.AddComponent <M2Model>(); model.GetComponent <M2Model>().json = json; //Fill particle effect data if (file.Particles.Length > 0) { GameObject[] particles = new GameObject[file.Particles.Length]; for (int i = 0; i < particles.Length; i++) { particles[i] = ParticleEffect(file.Particles[i]); particles[i].transform.parent = bones[file.Particles[i].Bone]; particles[i].transform.localPosition = Vector3.zero; particles[i].name = "Particle" + i; ctx.AddObjectToAsset(particles[i].name, particles[i]); } } //Populate the asset ctx.AddObjectToAsset(file.Name, model); ctx.AddObjectToAsset(mesh.name, mesh); ctx.AddObjectToAsset(skeleton.name, skeleton); ctx.AddObjectToAsset(json.name, json); }
public DwarfMale(M2 model, Character character) { Model = model; Character = character; }
public HumanMale(M2 model, Character character) { Model = model; Character = character; }
//Generate 3D Mesh gameobject from m2 file public static GameObject Generate3DMesh(M2 file) { GameObject model = new GameObject(file.Name); model.AddComponent <SkinnedMeshRenderer>(); SkinnedMeshRenderer renderer = model.GetComponent <SkinnedMeshRenderer>(); Mesh mesh = new Mesh(); mesh.name = file.Name + "_mesh"; //Fill vertex data Vector3[] vertices = new Vector3[file.Vertices.Length]; Vector3[] normals = new Vector3[file.Vertices.Length]; BoneWeight[] weights = new BoneWeight[file.Vertices.Length]; Vector2[] uv = new Vector2[file.Vertices.Length]; Vector2[] uv2 = new Vector2[file.Vertices.Length]; for (int i = 0; i < file.Vertices.Length; i++) { vertices[i] = new Vector3(-file.Vertices[i].Position.X / 2, file.Vertices[i].Position.Z / 2, -file.Vertices[i].Position.Y / 2); normals[i] = new Vector3(-file.Vertices[i].Normal.X, file.Vertices[i].Normal.Z, -file.Vertices[i].Normal.Y); BoneWeight weight = new BoneWeight { boneIndex0 = file.Vertices[i].Bones[0], boneIndex1 = file.Vertices[i].Bones[1], boneIndex2 = file.Vertices[i].Bones[2], boneIndex3 = file.Vertices[i].Bones[3], weight0 = file.Vertices[i].Weights[0] / 255f, weight1 = file.Vertices[i].Weights[1] / 255f, weight2 = file.Vertices[i].Weights[2] / 255f, weight3 = file.Vertices[i].Weights[3] / 255f }; weights[i] = weight; uv[i] = new Vector2(file.Vertices[i].UV[0].X, 1 - file.Vertices[i].UV[0].Y); uv2[i] = new Vector2(file.Vertices[i].UV[1].X, 1 - file.Vertices[i].UV[1].Y); } mesh.vertices = vertices; mesh.normals = normals; mesh.boneWeights = weights; mesh.uv = uv; mesh.uv2 = uv2; //Fill Submesh data mesh.subMeshCount = file.Skin.Submeshes.Length; for (int i = 0; i < mesh.subMeshCount; i++) { int[] triangles = new int[file.Skin.Submeshes[i].Count]; for (int j = 0; j < triangles.Length; j++) { triangles[j] = file.Skin.Indices[file.Skin.Submeshes[i].Start + j]; } mesh.SetTriangles(triangles, i); } //Generate bones Transform[] bones = new Transform[file.Skeleton.Bones.Length]; for (int i = 0; i < bones.Length; i++) { bones[i] = new GameObject("Bone" + i).transform; bones[i].position = new Vector3(-file.Skeleton.Bones[i].Pivot.X / 2, file.Skeleton.Bones[i].Pivot.Z / 2, -file.Skeleton.Bones[i].Pivot.Y / 2); } GameObject skeleton = new GameObject("Skeleton"); for (int i = 0; i < bones.Length; i++) { if (file.Skeleton.Bones[i].Parent == -1) { bones[i].parent = skeleton.transform; } else { bones[i].parent = bones[file.Skeleton.Bones[i].Parent]; } } Matrix4x4[] bind = new Matrix4x4[bones.Length]; for (int i = 0; i < bones.Length; i++) { bind[i] = bones[i].worldToLocalMatrix * model.transform.localToWorldMatrix; } skeleton.transform.parent = model.transform; renderer.materials = new Material[mesh.subMeshCount]; renderer.sharedMesh = mesh; renderer.bones = bones; renderer.rootBone = bones[0]; mesh.bindposes = bind; return(model); }
public void ParseM2Block() { M2.Load(currentM2datapath, currentM2uniqueID, currentM2position, currentM2rotation, currentM2scale); }
public void Do <T, U>(M2 <T, U> m) { PrivateDo(m); }
public void SyncContext <T, U>(M2 <T, U> m) { SyncContext(m); }
public static void InsertWMOGeometry(MODF.MODFEntry wmo, WMORoot model, List<Vector3> vertices, List<Triangle<uint>> indices) { var transform = Transformation.GetTransform(wmo.Position, wmo.Rotation); foreach (var group in model.Groups) { var vo = (uint)vertices.Count; foreach (var v in group.MOVT.Vertices) vertices.Add((Vector3)Vector3.Transform(v, transform)); for (int i = 0; i < group.MOVI.Indices.Length; i++) { if (((byte)group.MOPY.Entries[i].Flags & 0x04) != 0 && group.MOPY.Entries[i].MaterialId != 0xFF) continue; var idx = group.MOVI.Indices[i]; indices.Add(new Triangle<uint>(TriangleType.Wmo, vo + idx.V0, vo + idx.V1, vo + idx.V2)); } } if (wmo.DoodadSet >= 0 && wmo.DoodadSet < model.MODS.Entries.Length) { var set = model.MODS.Entries[wmo.DoodadSet]; var instances = new List<MODD.MODDEntry>((int)set.nDoodads); for (uint i = set.FirstInstanceIndex; i < (set.nDoodads + set.FirstInstanceIndex); i++) { if (i >= model.MODD.Entries.Length) break; instances.Add(model.MODD.Entries[(int)i]); } foreach (var instance in instances) { string path; if (!model.MODN.Filenames.TryGetValue(instance.ofsMODN, out path)) continue; var doodad = new M2(path); if (!doodad.IsCollidable) continue; var doodadTransform = Transformation.GetWmoDoodadTransform(instance, wmo); var vo = (uint)vertices.Count; foreach (var v in doodad.Vertices) vertices.Add((Vector3)Vector3.Transform(v, doodadTransform)); foreach (var t in doodad.Indices) indices.Add(new Triangle<uint>(TriangleType.Doodad, t.V0 + vo, t.V1 + vo, t.V2 + vo)); } } foreach (var group in model.Groups) { if ((group.LiquidVertices == null || group.LiquidVertices.Count == 0) || (group.LiquidIndices == null || group.LiquidIndices.Count == 0)) continue; var vo = (uint)vertices.Count; foreach (var v in group.LiquidVertices) vertices.Add((Vector3)Vector3.Transform(v, transform)); foreach (var t in group.LiquidIndices) indices.Add(new Triangle<uint>(t.Type, t.V1 + vo, t.V0 + vo, t.V2 + vo)); } }
public void Pool <T, U>(M2 <T, U> m) { PrivatePool(m); }
public override void OnImportAsset(AssetImportContext ctx) { //Load file contents BoneLib.Bone file = new BoneLib.Bone(); file.LoadFile(ctx.assetPath); //Load skel file for reference M2 model = new M2(); model.LoadFile(ctx.assetPath.Substring(0, ctx.assetPath.Length - 8) + ".m2"); Skel skeleton = model.Skeleton; //Create empty animation clip AnimationClip clip = new AnimationClip(); AnimationCurve curve; Matrix4x4 matrix; Vector4[] columns = new Vector4[4]; float value; //Generate temporary bones Transform[] bones = new Transform[skeleton.Bones.Length]; for (int i = 0; i < bones.Length; i++) { bones[i] = new GameObject("Bone" + i).transform; bones[i].position = new Vector3(-skeleton.Bones[i].Pivot.X / 2, skeleton.Bones[i].Pivot.Z / 2, -skeleton.Bones[i].Pivot.Y / 2); } GameObject rig = new GameObject("Skeleton"); for (int i = 0; i < bones.Length; i++) { if (skeleton.Bones[i].Parent == -1) { bones[i].parent = rig.transform; } else { bones[i].parent = bones[skeleton.Bones[i].Parent]; } } //Fill animation data for each bone for (int i = 0; i < file.Bones.Length; i++) { string path = GetBonePath(skeleton.Bones[file.Bones[i]].Parent, skeleton.Bones) + "Bone" + file.Bones[i]; for (int j = 0; j < 4; j++) { columns[j] = new Vector4(file.Transformations[i][j][0], file.Transformations[i][j][1], file.Transformations[i][j][2], file.Transformations[i][j][3]); } matrix = new Matrix4x4(columns[0], columns[1], columns[2], columns[3]); value = -matrix.m03 / 2 + bones[file.Bones[i]].localPosition.x; curve = AnimationCurve.Linear(0f, value, 0.1f, value); clip.SetCurve(path, typeof(Transform), "localPosition.x", curve); value = matrix.m23 / 2 + bones[file.Bones[i]].localPosition.y; curve = AnimationCurve.Linear(0f, value, 0.1f, value); clip.SetCurve(path, typeof(Transform), "localPosition.y", curve); value = -matrix.m13 / 2 + bones[file.Bones[i]].localPosition.z; curve = AnimationCurve.Linear(0f, value, 0.1f, value); clip.SetCurve(path, typeof(Transform), "localPosition.z", curve); UnityEngine.Quaternion rotation = matrix.rotation; curve = AnimationCurve.Linear(0f, -rotation.x, 1f, rotation.x); clip.SetCurve(path, typeof(Transform), "localRotation.x", curve); curve = AnimationCurve.Linear(0f, -rotation.z, 0.1f, rotation.z); clip.SetCurve(path, typeof(Transform), "localRotation.y", curve); curve = AnimationCurve.Linear(0f, rotation.y, 0.1f, rotation.y); clip.SetCurve(path, typeof(Transform), "localRotation.z", curve); curve = AnimationCurve.Linear(0f, rotation.w, 0.1f, rotation.w); clip.SetCurve(path, typeof(Transform), "localRotation.w", curve); Vector3 scale = matrix.lossyScale; curve = AnimationCurve.Linear(0f, scale.x, 0.1f, scale.x); clip.SetCurve(path, typeof(Transform), "localScale.x", curve); curve = AnimationCurve.Linear(0f, scale.z, 0.1f, scale.z); clip.SetCurve(path, typeof(Transform), "localScale.y", curve); curve = AnimationCurve.Linear(0f, scale.y, 0.1f, scale.y); clip.SetCurve(path, typeof(Transform), "localScale.z", curve); } //Clear temporary bones and add animation clip to the asset DestroyImmediate(rig); ctx.AddObjectToAsset(Path.GetFileNameWithoutExtension(ctx.assetPath.Replace("/", "\\")), clip); }
public void Spawn <T, U>(M2 <T, U> m) { PrivateSpawn(m); }
public MechagnomeFemale(M2 model, Character character) { Model = model; Character = character; }
public void Continue <T, U, V, W>(M2 <T, U, V, W> m) { PrivateContinue(m); }
private void GenerateDoodads() { if (ADT.Type != ADTType.Objects || ADT.MDDF == null) return; var drawn = new HashSet<uint>(); for (int i = 0; i < MCRD.MDDFEntryIndex.Length; i++) { var doodad = ADT.MDDF.Entries[MCRD.MDDFEntryIndex[i]]; if (drawn.Contains(doodad.UniqueId)) continue; drawn.Add(doodad.UniqueId); if (doodad.MMIDEntryIndex >= ADT.DoodadPaths.Count) continue; var path = ADT.DoodadPaths[(int)doodad.MMIDEntryIndex]; var model = new M2(path); if (!model.IsCollidable) continue; if (DoodadVertices == null) DoodadVertices = new List<Vector3>((MCRD.MDDFEntryIndex.Length / 4) * model.Vertices.Length); if (DoodadIndices == null) DoodadIndices = new List<Triangle<uint>>((MCRD.MDDFEntryIndex.Length / 4) * model.Indices.Length); var transform = Transformation.GetTransform(doodad.Position, doodad.Rotation, doodad.Scale / 1024.0f); var vo = (uint)DoodadVertices.Count; foreach (var v in model.Vertices) DoodadVertices.Add((Vector3)Vector3.Transform(v, transform)); foreach (var t in model.Indices) DoodadIndices.Add(new Triangle<uint>(TriangleType.Doodad, t.V0 + vo, t.V1 + vo, t.V2 + vo)); } }
public void Do <T, U, V, W>(M2 <T, U, V, W> m) { PrivateDo(m); }
public VulperaMale(M2 model, Character character) { Model = model; Character = character; }