public RoadLink(BinaryReaderEx input) { ConnectionCount = input.ReadInt16(); Positions = new Vector3P[ConnectionCount]; for (int i = 0; i < ConnectionCount; i++) { Positions[i] = new Vector3P(input); } if (input.Version >= 24) { ConnectionTypes = new byte[ConnectionCount]; for (int i = 0; i < ConnectionCount; i++) { ConnectionTypes[i] = input.ReadByte(); } } ObjectID = input.ReadInt32(); if (input.Version >= 16) { P3dPath = input.ReadAsciiz(); ToWorld = new Matrix4P(input); } }
public StaticEntityInfo(BinaryReaderEx input) { ClassName = input.ReadAsciiz(); ShapeName = input.ReadAsciiz(); Position = new Vector3P(input); ObjectId = input.ReadInt32(); }
public void Read(BinaryReaderEx input) { var num = (DataSize - 4) / 12; FrameTime = input.ReadSingle(); FramePoints = new Vector3P[num]; for (int i = 0; i < num; ++i) { FramePoints[i] = new Vector3P(input); } }
public void Read(BinaryReaderEx input) { if (input.ReadAscii(4) != "P3DM") { throw new ArgumentException("Only P3DM LODs are supported"); } var headerSize = input.ReadInt32(); Version = input.ReadInt32(); if (headerSize != 28 || Version != 0x100) { throw new ArgumentOutOfRangeException("Unknown P3DM version"); } var nPoints = input.ReadInt32(); var nNormals = input.ReadInt32(); var nFaces = input.ReadInt32(); Flags = input.ReadInt32(); Points = new Point[nPoints]; Normals = new Vector3P[nNormals]; Faces = new Face[nFaces]; for (int i = 0; i < nPoints; ++i) { Points[i] = new Point(input); } for (int i = 0; i < nNormals; ++i) { Normals[i] = new Vector3P(input); } for (int i = 0; i < nFaces; ++i) { Faces[i] = new Face(input); } if (input.ReadAscii(4) != "TAGG") { throw new FormatException("TAGG expected"); } Taggs = new LinkedList <Tagg>(); Tagg mlodTagg; do { mlodTagg = Tagg.ReadTagg(input, nPoints, Faces); Taggs.AddLast(mlodTagg); }while (!(mlodTagg is EOFTagg)); Resolution = input.ReadSingle(); }
// Token: 0x06000032 RID: 50 RVA: 0x000029DC File Offset: 0x00000BDC private static void ConvertPoints(ODOL odol, MLOD_LOD dstLod, LOD srcLod) { Vector3P boundingCenter = odol.modelInfo.boundingCenter; Vector3P bboxMinVisual = odol.modelInfo.bboxMinVisual; Vector3P bboxMaxVisual = odol.modelInfo.bboxMaxVisual; int num = srcLod.Vertices.Length; dstLod.points = new Point[num]; for (int i = 0; i < num; i++) { Vector3P pos = srcLod.Vertices[i] + boundingCenter; dstLod.points[i] = new Point(pos, Conversion.clipFlagsToPointFlags(srcLod.ClipFlags[i])); } }
private void ReadRTM(BinaryReaderEx input) { Displacement = new Vector3P(input); var nFrames = input.ReadInt32(); BoneNames = input.ReadArray(inp => inp.ReadAscii(32)); var nBones = BoneNames.Length; FrameTimes = new float[nFrames]; FrameTransforms = new Matrix4P[nFrames, nBones]; for (int frame = 0; frame < nFrames; frame++) { FrameTimes[frame] = input.ReadSingle(); for (int b = 0; b < nBones; b++) { input.ReadAscii(32); //redundand boneName FrameTransforms[frame, b] = new Matrix4P(input); } } }
private void Read(BinaryReaderEx input) { if ("BMTR" != input.ReadAscii(4)) { throw new FormatException(); } Version = input.ReadInt32(); input.Version = Version; if (Version >= 3) { input.UseLZOCompression = true; } if (Version >= 5) { input.UseCompressionFlag = true; } Reversed = input.ReadBoolean(); Step = new Vector3P(input); var nPhases = input.ReadInt32(); PreloadCount = input.ReadInt32(); var nAnimatedBones = input.ReadInt32(); BoneNames = input.ReadStringArray(); //metadata if (Version >= 4) { MetaDataValues = input.ReadStringArray(); AnimKeyStones = input.ReadArray(inp => new AnimKeyStone(inp)); } PhaseTimes = input.ReadCompressedFloatArray(); Phases = Enumerable.Range(0, nPhases).Select(_ => input.ReadCompressedArray(inp => TransformP.Read(inp), 14)).ToArray(); }
public Point(Vector3P pos, PointFlags flags) : base(pos.X, pos.Y, pos.Z) { PointFlags = flags; }
public void loadFromODOL(BinaryReaderEx reader, bool readPoints = false) { var numProxies = reader.ReadUInt32(); for (int i = 0; i < numProxies; i++) { var proxyName = reader.ReadAsciiz(); reader.BaseStream.Seek( 4 * 3 * 4 //Transform xyzn 4 vectors of 3 floats each + 4 + 4 + 4 + 4, SeekOrigin.Current); } var numBonesSub = reader.ReadUInt32(); reader.BaseStream.Seek(numBonesSub * 4, SeekOrigin.Current); var numBones = reader.ReadUInt32(); for (int i = 0; i < numBones; i++) { var numLinks = reader.ReadUInt32(); reader.BaseStream.Seek(numLinks * 4, SeekOrigin.Current); } reader.BaseStream.Seek(4 + 4 + 4 + 4 + 4 * 3 + 4 * 3 + 4 * 3 + 4, SeekOrigin.Current); var numTextures = reader.ReadUInt32(); for (int i = 0; i < numTextures; i++) { var texName = reader.ReadAsciiz(); } var numMaterials = reader.ReadUInt32(); for (int i = 0; i < numMaterials; i++) { var name1 = reader.ReadAsciiz(); reader.BaseStream.Seek(4 + 4 * 4 * 6 + 4 + 8 + 8, SeekOrigin.Current); var name2 = reader.ReadAsciiz(); reader.BaseStream.Seek(8, SeekOrigin.Current); var numTex = reader.ReadUInt32(); var numTrans = reader.ReadUInt32(); for (int i2 = 0; i2 < numTex; i2++) { reader.ReadUInt32(); var name3 = reader.ReadAsciiz(); reader.ReadUInt32(); reader.ReadByte(); } reader.BaseStream.Seek((4 + 4 * 12) * numTrans, SeekOrigin.Current); reader.ReadUInt32();//#TODO skip TI stage if version <11 var nameTI = reader.ReadAsciiz(); reader.ReadUInt32(); reader.ReadByte(); } var t1 = reader.ReadCompressedIntArray(); var t2 = reader.ReadCompressedIntArray(); //reader.BaseStream.Seek(8, SeekOrigin.Current); //ptv vtp var numFaces2 = reader.ReadUInt32(); var faceSize = reader.ReadUInt32(); //This doesn't match.. Dunno why reader.BaseStream.Seek(2, SeekOrigin.Current); //reader.BaseStream.Seek(faceSize, SeekOrigin.Current); //int sz = 0; for (int i = 0; i < numFaces2; i++) { var numVerts = reader.ReadByte(); //sz += 1; //sz += numVerts * 4; reader.BaseStream.Seek(numVerts * 4, SeekOrigin.Current); } var numSections = reader.ReadUInt32(); for (int i = 0; i < numSections; i++) { reader.BaseStream.Seek(16 + 4 + 2 + 4, SeekOrigin.Current); var matIndex = reader.ReadInt32(); if (matIndex == -1) { var matname = reader.ReadAsciiz(); } var uvC = reader.ReadUInt32(); reader.BaseStream.Seek(8, SeekOrigin.Current); var uknw = reader.ReadUInt32(); if (uknw == 1) { reader.BaseStream.Seek(16 + 4 + 2 + 4 + 2 + 16, SeekOrigin.Current); } } var tempSelections = new Dictionary <string, List <UInt32> >(); var numSelections = reader.ReadUInt32(); for (int i = 0; i < numSelections; i++) { string selectionName = reader.ReadAsciiz(); int nElements = reader.ReadInt32(); if (nElements != 0) { var b = reader.ReadByte();//#TODO do this properly. Search in binary for `"Error decompressing block %d..%d of %s"` var expectedDataSize = (uint)(nElements * 4); var stream = reader.ReadCompressed(expectedDataSize, b == 2); } var always0 = reader.ReadUInt32(); if (always0 != 0) { throw new ArgumentOutOfRangeException(); } var isSectional = reader.ReadByte(); nElements = reader.ReadInt32(); //sections if (nElements != 0) { var b = reader.ReadByte(); var expectedDataSize = (uint)(nElements * 4); var stream = reader.ReadCompressed(expectedDataSize, b == 2); } nElements = reader.ReadInt32(); //vertices if (nElements != 0) { var b = reader.ReadByte(); var expectedDataSize = (uint)(nElements * 4); var stream = reader.ReadCompressed(expectedDataSize, b == 2); if (readPoints) { var streamB = new BinaryReaderEx(new MemoryStream(stream)); List <UInt32> pointList = new List <UInt32>(nElements); for (int i2 = 0; i2 < nElements; i2++) { pointList.Add(streamB.ReadUInt32()); } tempSelections.Add(selectionName, pointList); } } nElements = reader.ReadInt32();//weights if (nElements != 0) { var b = reader.ReadByte(); var expectedDataSize = (uint)nElements; var stream = reader.ReadCompressed(expectedDataSize, b == 2); } } var numProperties = reader.ReadUInt32(); for (int i = 0; i < numProperties; i++) { string key = reader.ReadAsciiz(); var valuePos = reader.Position; string value = reader.ReadAsciiz(); if (properties.ContainsKey(key.ToLower())) { propertyExceptions.Add(new PropertyException(key, "duplicate property " + value)); } else { properties.Add(key.ToLower(), new Property(value, valuePos)); //#TODO maybe we also want to keep a version with original casing? } } var numFrames = reader.ReadUInt32(); if (numFrames != 0) { throw new NotImplementedException("Animation frames not implemented"); } reader.BaseStream.Seek(13, SeekOrigin.Current); var stuff = reader.ReadUInt32(); //vertex table size, can jump directly to end if (!readPoints) { reader.BaseStream.Seek(stuff, SeekOrigin.Current); } else { var numPoints = reader.ReadUInt32(); if (numPoints != 0) { var b = reader.ReadByte(); var expectedDataSize = (uint)numPoints * 4; if (b == 1) { reader.ReadUInt32(); } else { reader.ReadCompressed(expectedDataSize, b == 2); } } reader.BaseStream.Seek(16, SeekOrigin.Current); //uv limits var numUVs = reader.ReadUInt32() - 1; reader.ReadByte(); if (numUVs != 0) { numUVs = 1; //reader.ReadByte(); reader.BaseStream.Seek(4 * numUVs, SeekOrigin.Current); //uv limits } var secondUV = reader.ReadUInt32() - 1; if (secondUV != 0) { throw new NotImplementedException(); } var numPoints2 = reader.ReadUInt32(); if (numPoints2 != 0) { var b = reader.ReadByte(); var expectedDataSize = (uint)numPoints2 * (3 * 4); var stream = reader.ReadCompressed(expectedDataSize, b == 2); var streamB = new BinaryReaderEx(new MemoryStream(stream)); var array = new Vector3P[numPoints2]; for (int i2 = 0; i2 < numPoints2; i2++) { array[i2] = new Vector3P(streamB.ReadSingle(), streamB.ReadSingle(), streamB.ReadSingle()); } foreach (KeyValuePair <string, List <UInt32> > entry in tempSelections) { var selectionPoints = new List <Vector3P>(entry.Value.Count); foreach (UInt32 pointIndex in entry.Value) { selectionPoints.Add(array[pointIndex]); } selections.Add(entry.Key, selectionPoints); } } /* * var numNormals = reader.ReadUInt32(); * reader.ReadByte(); * if (numNormals != 0) * reader.ReadByte(); * for (int i = 0; i < numNormals; i++) * { * reader.BaseStream.Seek(4 * numNormals, SeekOrigin.Current); * } * * * reader.BaseStream.Seek(4, SeekOrigin.Current); * var numVertBone = reader.ReadUInt32(); * if (numVertBone != 0) * reader.ReadByte(); * * for (int i = 0; i < numVertBone; i++) * { * reader.BaseStream.Seek(4 +(4*2), SeekOrigin.Current); * }*/ } reader.BaseStream.Seek(4 + 4 + 1, SeekOrigin.Current); //End of lod }
// Token: 0x06000035 RID: 53 RVA: 0x00002CE4 File Offset: 0x00000EE4 private static void ReconstructProxies(LOD src, out Dictionary <string, List <Conversion.PointWeight> > points, out Dictionary <string, List <int> > faces) { points = new Dictionary <string, List <Conversion.PointWeight> >(src.NamedSelections.Length * 2); faces = new Dictionary <string, List <int> >(src.NamedSelections.Length * 2); for (int i = 0; i < src.Faces.Length; i++) { Polygon polygon = src.Faces[i]; if (polygon.VertexIndices.Length == 3) { VertexIndex vi = polygon.VertexIndices[0]; VertexIndex vi2 = polygon.VertexIndices[1]; VertexIndex vi3 = polygon.VertexIndices[2]; Vector3P vector3P = src.Vertices[vi]; Vector3P vector3P2 = src.Vertices[vi2]; Vector3P vector3P3 = src.Vertices[vi3]; float num = vector3P.Distance(vector3P2); float num2 = vector3P.Distance(vector3P3); float num3 = vector3P2.Distance(vector3P3); if (num > num2) { Methods.Swap <Vector3P>(ref vector3P2, ref vector3P3); Methods.Swap <float>(ref num, ref num2); } if (num > num3) { Methods.Swap <Vector3P>(ref vector3P, ref vector3P3); Methods.Swap <float>(ref num, ref num3); } if (num2 > num3) { Methods.Swap <Vector3P>(ref vector3P, ref vector3P2); Methods.Swap <float>(ref num2, ref num3); } Vector3P vector3P4 = vector3P; Vector3P vector3P5 = vector3P2 - vector3P; Vector3P vector3P6 = vector3P3 - vector3P; vector3P5.Normalize(); vector3P6.Normalize(); if (Methods.EqualsFloat(vector3P6 * vector3P5, 0f, 0.05f)) { for (int j = 0; j < src.Proxies.Length; j++) { Vector3P position = src.Proxies[j].transformation.Position; Vector3P up = src.Proxies[j].transformation.Orientation.Up; Vector3P dir = src.Proxies[j].transformation.Orientation.Dir; if (vector3P4.Equals(position) && vector3P5.Equals(dir) && vector3P6.Equals(up)) { Proxy proxy = src.Proxies[j]; string name = src.NamedSelections[proxy.namedSelectionIndex].Name; if (!faces.ContainsKey(name)) { faces[name] = i.Yield <int>().ToList <int>(); points[name] = Methods.Yield <Conversion.PointWeight>(new Conversion.PointWeight[] { new Conversion.PointWeight(vi, byte.MaxValue), new Conversion.PointWeight(vi2, byte.MaxValue), new Conversion.PointWeight(vi3, byte.MaxValue) }).ToList <Conversion.PointWeight>(); break; } } } } } } }
public void SetPolyLassoObjectShapePointPairs(PolyLassoObject pObj) { pObj.shapePointPairs = new List <Vector3P>(); List <Vector3> shape = PolyLassoObjectToWorldShape(pObj); float offsetZ = Mathf.Abs(surforgeSettings.textureBorders.minZ - surforgeSettings.textureBorders.maxZ) * surforgeSettings.root.transform.localScale.z; float offsetX = Mathf.Abs(surforgeSettings.textureBorders.minX - surforgeSettings.textureBorders.maxX) * surforgeSettings.root.transform.localScale.x; for (int i = 0; i < shape.Count; i++) { Vector3P pair = new Vector3P(); if (i < (shape.Count - 1)) { pair.a = shape[i]; pair.b = shape[i + 1]; } else { pair.a = shape[i]; pair.b = shape[0]; } pObj.shapePointPairs.Add(pair); if (surforgeSettings.seamless) { Vector3P pairSeamless1 = new Vector3P(); pairSeamless1.a = new Vector3(pair.a.x + offsetX, pair.a.y, pair.a.z); pairSeamless1.b = new Vector3(pair.b.x + offsetX, pair.b.y, pair.b.z); pObj.shapePointPairs.Add(pairSeamless1); Vector3P pairSeamless2 = new Vector3P(); pairSeamless2.a = new Vector3(pair.a.x - offsetX, pair.a.y, pair.a.z); pairSeamless2.b = new Vector3(pair.b.x - offsetX, pair.b.y, pair.b.z); pObj.shapePointPairs.Add(pairSeamless2); Vector3P pairSeamless3 = new Vector3P(); pairSeamless3.a = new Vector3(pair.a.x, pair.a.y, pair.a.z + offsetZ); pairSeamless3.b = new Vector3(pair.b.x, pair.b.y, pair.b.z + offsetZ); pObj.shapePointPairs.Add(pairSeamless3); Vector3P pairSeamless4 = new Vector3P(); pairSeamless4.a = new Vector3(pair.a.x, pair.a.y, pair.a.z - offsetZ); pairSeamless4.b = new Vector3(pair.b.x, pair.b.y, pair.b.z - offsetZ); pObj.shapePointPairs.Add(pairSeamless4); Vector3P pairSeamless5 = new Vector3P(); pairSeamless5.a = new Vector3(pair.a.x + offsetX, pair.a.y, pair.a.z + offsetZ); pairSeamless5.b = new Vector3(pair.b.x + offsetX, pair.b.y, pair.b.z + offsetZ); pObj.shapePointPairs.Add(pairSeamless5); Vector3P pairSeamless6 = new Vector3P(); pairSeamless6.a = new Vector3(pair.a.x + offsetX, pair.a.y, pair.a.z - offsetZ); pairSeamless6.b = new Vector3(pair.b.x + offsetX, pair.b.y, pair.b.z - offsetZ); pObj.shapePointPairs.Add(pairSeamless6); Vector3P pairSeamless7 = new Vector3P(); pairSeamless7.a = new Vector3(pair.a.x - offsetX, pair.a.y, pair.a.z + offsetZ); pairSeamless7.b = new Vector3(pair.b.x - offsetX, pair.b.y, pair.b.z + offsetZ); pObj.shapePointPairs.Add(pairSeamless7); Vector3P pairSeamless8 = new Vector3P(); pairSeamless8.a = new Vector3(pair.a.x - offsetX, pair.a.y, pair.a.z - offsetZ); pairSeamless8.b = new Vector3(pair.b.x - offsetX, pair.b.y, pair.b.z - offsetZ); pObj.shapePointPairs.Add(pairSeamless8); } } }