public ValueArray(ObjectReader reader) { var version = reader.version; if (version[0] < 5 || (version[0] == 5 && version[1] < 5)) //5.5 down { int numBools = reader.ReadInt32(); m_BoolValues = new bool[numBools]; for (int i = 0; i < numBools; i++) { m_BoolValues[i] = reader.ReadBoolean(); } reader.AlignStream(4); m_IntValues = reader.ReadInt32Array(reader.ReadInt32()); m_FloatValues = reader.ReadSingleArray(reader.ReadInt32()); } int numPosValues = reader.ReadInt32(); m_PositionValues = new object[numPosValues]; for (int i = 0; i < numPosValues; i++) { m_PositionValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4(); //5.4 and up } m_QuaternionValues = reader.ReadVector4Array(reader.ReadInt32()); int numScaleValues = reader.ReadInt32(); m_ScaleValues = new object[numScaleValues]; for (int i = 0; i < numScaleValues; i++) { m_ScaleValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4(); //5.4 adn up } if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up { m_FloatValues = reader.ReadSingleArray(reader.ReadInt32()); m_IntValues = reader.ReadInt32Array(reader.ReadInt32()); int numBools = reader.ReadInt32(); m_BoolValues = new bool[numBools]; for (int i = 0; i < numBools; i++) { m_BoolValues[i] = reader.ReadBoolean(); } reader.AlignStream(4); } }
public Blend2dDataConstant(ObjectReader reader) { m_ChildPositionArray = reader.ReadVector2Array(); m_ChildMagnitudeArray = reader.ReadSingleArray(); m_ChildPairVectorArray = reader.ReadVector2Array(); m_ChildPairAvgMagInvArray = reader.ReadSingleArray(); int numNeighbours = reader.ReadInt32(); m_ChildNeighborListArray = new MotionNeighborList[numNeighbours]; for (int i = 0; i < numNeighbours; i++) { m_ChildNeighborListArray[i] = new MotionNeighborList(reader); } }
public HumanPose(ObjectReader reader) { var version = reader.version; m_RootX = new xform(reader); m_LookAtPosition = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up m_LookAtWeight = reader.ReadVector4(); int numGoals = reader.ReadInt32(); m_GoalArray = new List <HumanGoal>(numGoals); for (int i = 0; i < numGoals; i++) { m_GoalArray.Add(new HumanGoal(reader)); } m_LeftHandPose = new HandPose(reader); m_RightHandPose = new HandPose(reader); int numDoFs = reader.ReadInt32(); m_DoFArray = reader.ReadSingleArray(numDoFs); if (version[0] > 5 || (version[0] == 5 && version[1] >= 2))//5.2 and up { int numTDof = reader.ReadInt32(); m_TDoFArray = new object[numTDof]; for (int i = 0; i < numTDof; i++) { m_TDoFArray[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? (object)reader.ReadVector3() : (object)reader.ReadVector4();//5.4 and up } } }
public SkinnedMeshRenderer(ObjectReader reader) : base(reader) { int m_Quality = reader.ReadInt32(); var m_UpdateWhenOffscreen = reader.ReadBoolean(); var m_SkinNormals = reader.ReadBoolean(); //3.1.0 and below reader.AlignStream(); if (version[0] == 2 && version[1] < 6) //2.6 down { var m_DisableAnimationWhenOffscreen = new PPtr <Animation>(reader); } m_Mesh = new PPtr <Mesh>(reader); m_Bones = new PPtr <Transform> [reader.ReadInt32()]; for (int b = 0; b < m_Bones.Length; b++) { m_Bones[b] = new PPtr <Transform>(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { m_BlendShapeWeights = reader.ReadSingleArray(); } }
public HumanPose(ObjectReader reader) { var version = reader.version; m_RootX = new xform(reader); m_LookAtPosition = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? reader.ReadVector3() : (Vector3)reader.ReadVector4();//5.4 and up m_LookAtWeight = reader.ReadVector4(); var numGoals = reader.ReadInt32(); m_GoalArray = new HumanGoal[numGoals]; for (var i = 0; i < numGoals; i++) { m_GoalArray[i] = new HumanGoal(reader); } m_LeftHandPose = new HandPose(reader); m_RightHandPose = new HandPose(reader); m_DoFArray = reader.ReadSingleArray(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 2))//5.2 and up { var numTDof = reader.ReadInt32(); m_TDoFArray = new Vector3[numTDof]; for (var i = 0; i < numTDof; i++) { m_TDoFArray[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? reader.ReadVector3() : (Vector3)reader.ReadVector4();//5.4 and up } } }
public BlendShapeData(ObjectReader reader) { int numVerts = reader.ReadInt32(); vertices = new BlendShapeVertex[numVerts]; for (int i = 0; i < numVerts; i++) { vertices[i] = new BlendShapeVertex(reader); } int numShapes = reader.ReadInt32(); shapes = new MeshBlendShape[numShapes]; for (int i = 0; i < numShapes; i++) { shapes[i] = new MeshBlendShape(reader); } int numChannels = reader.ReadInt32(); channels = new MeshBlendShapeChannel[numChannels]; for (int i = 0; i < numChannels; i++) { channels[i] = new MeshBlendShapeChannel(reader); } fullWeights = reader.ReadSingleArray(); }
public BlendShapeData(ObjectReader reader) { int numVerts = reader.ReadInt32(); vertices = new List <BlendShapeVertex>(numVerts); for (int i = 0; i < numVerts; i++) { vertices.Add(new BlendShapeVertex(reader)); } int numShapes = reader.ReadInt32(); shapes = new List <MeshBlendShape>(numShapes); for (int i = 0; i < numShapes; i++) { shapes.Add(new MeshBlendShape(reader)); } int numChannels = reader.ReadInt32(); channels = new List <MeshBlendShapeChannel>(numChannels); for (int i = 0; i < numChannels; i++) { channels.Add(new MeshBlendShapeChannel(reader)); } fullWeights = reader.ReadSingleArray(); }
public ClipMuscleConstant(ObjectReader reader) { var version = reader.version; m_DeltaPose = new HumanPose(reader); m_StartX = new xform(reader); if (version[0] > 5 || (version[0] == 5 && version[1] >= 5))//5.5 and up { m_StopX = new xform(reader); } m_LeftFootStartX = new xform(reader); m_RightFootStartX = new xform(reader); if (version[0] < 5)//5.0 down { m_MotionStartX = new xform(reader); m_MotionStopX = new xform(reader); } m_AverageSpeed = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? reader.ReadVector3() : (Vector3)reader.ReadVector4();//5.4 and up m_Clip = new Clip(reader); m_StartTime = reader.ReadSingle(); m_StopTime = reader.ReadSingle(); m_OrientationOffsetY = reader.ReadSingle(); m_Level = reader.ReadSingle(); m_CycleOffset = reader.ReadSingle(); m_AverageAngularSpeed = reader.ReadSingle(); m_IndexArray = reader.ReadInt32Array(); if (version[0] < 4 || (version[0] == 4 && version[1] < 3)) //4.3 down { var m_AdditionalCurveIndexArray = reader.ReadInt32Array(); } int numDeltas = reader.ReadInt32(); m_ValueArrayDelta = new List <ValueDelta>(numDeltas); for (int i = 0; i < numDeltas; i++) { m_ValueArrayDelta.Add(new ValueDelta(reader)); } if (version[0] > 5 || (version[0] == 5 && version[1] >= 3))//5.3 and up { m_ValueArrayReferencePose = reader.ReadSingleArray(); } m_Mirror = reader.ReadBoolean(); m_LoopTime = reader.ReadBoolean(); m_LoopBlend = reader.ReadBoolean(); m_LoopBlendOrientation = reader.ReadBoolean(); m_LoopBlendPositionY = reader.ReadBoolean(); m_LoopBlendPositionXZ = reader.ReadBoolean(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 5))//5.5 and up { m_StartAtOrigin = reader.ReadBoolean(); } m_KeepOriginalOrientation = reader.ReadBoolean(); m_KeepOriginalPositionY = reader.ReadBoolean(); m_KeepOriginalPositionXZ = reader.ReadBoolean(); m_HeightFromFeet = reader.ReadBoolean(); reader.AlignStream(); }
public DenseClip(ObjectReader reader) { m_FrameCount = reader.ReadInt32(); m_CurveCount = reader.ReadUInt32(); m_SampleRate = reader.ReadSingle(); m_BeginTime = reader.ReadSingle(); m_SampleArray = reader.ReadSingleArray(); }
public HandPose(ObjectReader reader) { m_GrabX = new xform(reader); m_DoFArray = reader.ReadSingleArray(); m_Override = reader.ReadSingle(); m_CloseOpen = reader.ReadSingle(); m_InOut = reader.ReadSingle(); m_Grab = reader.ReadSingle(); }
public ValueArray(ObjectReader reader) { var version = reader.version; if (version[0] < 5 || (version[0] == 5 && version[1] < 5)) //5.5 down { m_BoolValues = reader.ReadBooleanArray(); reader.AlignStream(); m_IntValues = reader.ReadInt32Array(); m_FloatValues = reader.ReadSingleArray(); } if (version[0] < 4 || (version[0] == 4 && version[1] < 3)) //4.3 down { m_VectorValues = reader.ReadVector4Array(); } else { int numPosValues = reader.ReadInt32(); m_PositionValues = new Vector3[numPosValues]; for (int i = 0; i < numPosValues; i++) { m_PositionValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? reader.ReadVector3() : (Vector3)reader.ReadVector4(); //5.4 and up } m_QuaternionValues = reader.ReadVector4Array(); int numScaleValues = reader.ReadInt32(); m_ScaleValues = new Vector3[numScaleValues]; for (int i = 0; i < numScaleValues; i++) { m_ScaleValues[i] = version[0] > 5 || (version[0] == 5 && version[1] >= 4) ? reader.ReadVector3() : (Vector3)reader.ReadVector4(); //5.4 and up } if (version[0] > 5 || (version[0] == 5 && version[1] >= 5)) //5.5 and up { m_FloatValues = reader.ReadSingleArray(); m_IntValues = reader.ReadInt32Array(); m_BoolValues = reader.ReadBooleanArray(); reader.AlignStream(); } } }
public Human(ObjectReader reader) { var version = reader.version; m_RootX = new xform(reader); m_Skeleton = new Skeleton(reader); m_SkeletonPose = new SkeletonPose(reader); m_LeftHand = new Hand(reader); m_RightHand = new Hand(reader); if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { var numHandles = reader.ReadInt32(); m_Handles = new Handle[numHandles]; for (var i = 0; i < numHandles; i++) { m_Handles[i] = new Handle(reader); } var numColliders = reader.ReadInt32(); m_ColliderArray = new Collider[numColliders]; for (var i = 0; i < numColliders; i++) { m_ColliderArray[i] = new Collider(reader); } } m_HumanBoneIndex = reader.ReadInt32Array(); m_HumanBoneMass = reader.ReadSingleArray(); if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { m_ColliderIndex = reader.ReadInt32Array(); } m_Scale = reader.ReadSingle(); m_ArmTwist = reader.ReadSingle(); m_ForeArmTwist = reader.ReadSingle(); m_UpperLegTwist = reader.ReadSingle(); m_LegTwist = reader.ReadSingle(); m_ArmStretch = reader.ReadSingle(); m_LegStretch = reader.ReadSingle(); m_FeetSpacing = reader.ReadSingle(); m_HasLeftHand = reader.ReadBoolean(); m_HasRightHand = reader.ReadBoolean(); if (version[0] > 5 || (version[0] == 5 && version[1] >= 2)) //5.2 and up { m_HasTDoF = reader.ReadBoolean(); } reader.AlignStream(); }
public Human(ObjectReader reader) { var version = reader.version; m_RootX = new xform(reader); m_Skeleton = new Skeleton(reader); m_SkeletonPose = new SkeletonPose(reader); m_LeftHand = new Hand(reader); m_RightHand = new Hand(reader); if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { int numHandles = reader.ReadInt32(); m_Handles = new List <Handle>(numHandles); for (int i = 0; i < numHandles; i++) { m_Handles.Add(new Handle(reader)); } int numColliders = reader.ReadInt32(); m_ColliderArray = new List <Collider>(numColliders); for (int i = 0; i < numColliders; i++) { m_ColliderArray.Add(new Collider(reader)); } } m_HumanBoneIndex = reader.ReadInt32Array(); m_HumanBoneMass = reader.ReadSingleArray(); if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { m_ColliderIndex = reader.ReadInt32Array(); } m_Scale = reader.ReadSingle(); m_ArmTwist = reader.ReadSingle(); m_ForeArmTwist = reader.ReadSingle(); m_UpperLegTwist = reader.ReadSingle(); m_LegTwist = reader.ReadSingle(); m_ArmStretch = reader.ReadSingle(); m_LegStretch = reader.ReadSingle(); m_FeetSpacing = reader.ReadSingle(); m_HasLeftHand = reader.ReadBoolean(); m_HasRightHand = reader.ReadBoolean(); m_HasTDoF = reader.ReadBoolean(); reader.AlignStream(); }
public BlendTreeNodeConstant(ObjectReader reader) { var version = reader.version; if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up { m_BlendType = reader.ReadUInt32(); } m_BlendEventID = reader.ReadUInt32(); if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up { m_BlendEventYID = reader.ReadUInt32(); } m_ChildIndices = reader.ReadUInt32Array(); if (version[0] < 4 || (version[0] == 4 && version[1] < 1)) //4.1 down { m_ChildThresholdArray = reader.ReadSingleArray(); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up { m_Blend1dData = new Blend1dDataConstant(reader); m_Blend2dData = new Blend2dDataConstant(reader); } if (version[0] >= 5) //5.0 and up { m_BlendDirectData = new BlendDirectDataConstant(reader); } m_ClipID = reader.ReadUInt32(); if (version[0] == 4 && version[1] >= 5) //4.5 - 5.0 { m_ClipIndex = reader.ReadUInt32(); } m_Duration = reader.ReadSingle(); if (version[0] > 4 || (version[0] == 4 && version[1] > 1) || (version[0] == 4 && version[1] == 1 && version[2] >= 3)) //4.1.3 and up { m_CycleOffset = reader.ReadSingle(); m_Mirror = reader.ReadBoolean(); reader.AlignStream(); } }
public BlendShapeData(ObjectReader reader) { var version = reader.version; if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { int numVerts = reader.ReadInt32(); vertices = new BlendShapeVertex[numVerts]; for (int i = 0; i < numVerts; i++) { vertices[i] = new BlendShapeVertex(reader); } int numShapes = reader.ReadInt32(); shapes = new MeshBlendShape[numShapes]; for (int i = 0; i < numShapes; i++) { shapes[i] = new MeshBlendShape(reader); } int numChannels = reader.ReadInt32(); channels = new MeshBlendShapeChannel[numChannels]; for (int i = 0; i < numChannels; i++) { channels[i] = new MeshBlendShapeChannel(reader); } fullWeights = reader.ReadSingleArray(); } else { var m_ShapesSize = reader.ReadInt32(); var m_Shapes = new MeshBlendShape[m_ShapesSize]; for (int i = 0; i < m_ShapesSize; i++) { m_Shapes[i] = new MeshBlendShape(reader); } reader.AlignStream(); var m_ShapeVerticesSize = reader.ReadInt32(); var m_ShapeVertices = new BlendShapeVertex[m_ShapeVerticesSize]; //MeshBlendShapeVertex for (int i = 0; i < m_ShapeVerticesSize; i++) { m_ShapeVertices[i] = new BlendShapeVertex(reader); } } }
public List <uint> m_Indices = new List <uint>(); //use a list because I don't always know the facecount for triangle strips public Mesh(ObjectReader reader) : base(reader) { if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.5 down { m_Use16BitIndices = reader.ReadInt32() > 0; } if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = reader.ReadUInt32Array(m_IndexBuffer_size / 4); } } int m_SubMeshesSize = reader.ReadInt32(); m_SubMeshes = new SubMesh[m_SubMeshesSize]; for (int i = 0; i < m_SubMeshesSize; i++) { m_SubMeshes[i] = new SubMesh(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 1)) //4.1 and up { m_Shapes = new BlendShapeData(reader); } if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3 and up { m_BindPose = reader.ReadMatrixArray(); m_BoneNameHashes = reader.ReadUInt32Array(); var m_RootBoneNameHash = reader.ReadUInt32(); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and up { if (version[0] >= 2019) //2019 and up { var m_BonesAABBSize = reader.ReadInt32(); var m_BonesAABB = new MinMaxAABB[m_BonesAABBSize]; for (int i = 0; i < m_BonesAABBSize; i++) { m_BonesAABB[i] = new MinMaxAABB(reader); } var m_VariableBoneCountWeights = reader.ReadUInt32Array(); } var m_MeshCompression = reader.ReadByte(); if (version[0] >= 4) { if (version[0] < 5) { var m_StreamCompression = reader.ReadByte(); } var m_IsReadable = reader.ReadBoolean(); var m_KeepVertices = reader.ReadBoolean(); var m_KeepIndices = reader.ReadBoolean(); } reader.AlignStream(); //Unity fixed it in 2017.3.1p1 and later versions if ((version[0] > 2017 || (version[0] == 2017 && version[1] >= 4)) || //2017.4 ((version[0] == 2017 && version[1] == 3 && version[2] == 1) && buildType.IsPatch) || //fixed after 2017.3.1px ((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0)) //2017.3.xfx with no compression { var m_IndexFormat = reader.ReadInt32(); } int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = reader.ReadUInt32Array(m_IndexBuffer_size / 4); } } if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.4.2 and earlier { m_VertexCount = reader.ReadInt32(); m_Vertices = reader.ReadSingleArray(m_VertexCount * 3); //Vector3 m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } m_BindPose = reader.ReadMatrixArray(); m_UV0 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 m_UV1 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_TangentSpace_size = reader.ReadInt32(); m_Normals = new float[m_TangentSpace_size * 3]; m_Tangents = new float[m_TangentSpace_size * 4]; for (int v = 0; v < m_TangentSpace_size; v++) { m_Normals[v * 3] = reader.ReadSingle(); m_Normals[v * 3 + 1] = reader.ReadSingle(); m_Normals[v * 3 + 2] = reader.ReadSingle(); m_Tangents[v * 3] = reader.ReadSingle(); m_Tangents[v * 3 + 1] = reader.ReadSingle(); m_Tangents[v * 3 + 2] = reader.ReadSingle(); m_Tangents[v * 3 + 3] = reader.ReadSingle(); //handedness } } else //2.6.0 and later { m_Tangents = reader.ReadSingleArray(reader.ReadInt32() * 4); //Vector4 m_Normals = reader.ReadSingleArray(reader.ReadInt32() * 3); //Vector3 } } else { if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } } if (version[0] == 3 || (version[0] == 4 && version[1] <= 2)) //4.2 and down { m_BindPose = reader.ReadMatrixArray(); } m_VertexData = new VertexData(reader); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later { m_CompressedMesh = new CompressedMesh(reader); } reader.Position += 24; //AABB m_LocalAABB if (version[0] < 3 || (version[0] == 3 && version[1] <= 4)) //3.4.2 and earlier { int m_Colors_size = reader.ReadInt32(); m_Colors = new float[m_Colors_size * 4]; for (int v = 0; v < m_Colors_size * 4; v++) { m_Colors[v] = (float)reader.ReadByte() / 0xFF; } int m_CollisionTriangles_size = reader.ReadInt32(); reader.Position += m_CollisionTriangles_size * 4; //UInt32 indices int m_CollisionVertexCount = reader.ReadInt32(); } int m_MeshUsageFlags = reader.ReadInt32(); if (version[0] >= 5) //5.0 and up { var m_BakedConvexCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); var m_BakedTriangleCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_MeshMetrics = new float[2]; m_MeshMetrics[0] = reader.ReadSingle(); m_MeshMetrics[1] = reader.ReadSingle(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 3)) //2018.3 and up { reader.AlignStream(); m_StreamData = new StreamingInfo(reader); } ProcessData(); }
public Blend1dDataConstant(ObjectReader reader) { m_ChildThresholdArray = reader.ReadSingleArray(); }
public List <uint> m_Indices = new List <uint>(); //use a list because I don't always know the facecount for triangle strips public Mesh(ObjectReader reader) : base(reader) { if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.5 down { m_Use16BitIndices = reader.ReadInt32() > 0; } if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = new uint[m_IndexBuffer_size / 4]; for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = reader.ReadUInt32(); } } } int m_SubMeshesSize = reader.ReadInt32(); m_SubMeshes = new SubMesh[m_SubMeshesSize]; for (int i = 0; i < m_SubMeshesSize; i++) { m_SubMeshes[i] = new SubMesh(reader); } if (version[0] == 4 && ((version[1] == 1 && !buildType.IsAlpha) || (version[1] > 1 && version[1] <= 2))) //4.1.0 to 4.2.x, excluding 4.1.0 alpha { int m_Shapes_size = reader.ReadInt32(); if (m_Shapes_size > 0) { //bool stop = true; } for (int s = 0; s < m_Shapes_size; s++) //untested { var shape_name = reader.ReadAlignedString(); reader.Position += 36; //uint firstVertex, vertexCount; Vector3f aabbMinDelta, aabbMaxDelta; bool hasNormals, hasTangents } int m_ShapeVertices_size = reader.ReadInt32(); reader.Position += m_ShapeVertices_size * 40; //vertex positions, normals, tangents & uint index } else if (version[0] > 4 || (version[0] == 4 && version[1] >= 3)) //4.3.0 and later { m_Shapes = new BlendShapeData(reader); m_BindPose = reader.ReadMatrixArray(); m_BoneNameHashes = reader.ReadUInt32Array(); var m_RootBoneNameHash = reader.ReadUInt32(); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later { var m_MeshCompression = reader.ReadByte(); if (version[0] >= 4) { if (version[0] < 5) { var m_StreamCompression = reader.ReadByte(); } var m_IsReadable = reader.ReadBoolean(); var m_KeepVertices = reader.ReadBoolean(); var m_KeepIndices = reader.ReadBoolean(); } reader.AlignStream(); //Unity fixed it in 2017.3.1p1 and later versions if ((version[0] > 2017 || (version[0] == 2017 && version[1] >= 4)) || //2017.4 ((version[0] == 2017 && version[1] == 3 && version[2] == 1) && buildType.IsPatch) || //fixed after 2017.3.1px ((version[0] == 2017 && version[1] == 3) && m_MeshCompression == 0)) //2017.3.xfx with no compression { var m_IndexFormat = reader.ReadInt32(); } int m_IndexBuffer_size = reader.ReadInt32(); if (m_Use16BitIndices) { m_IndexBuffer = new uint[m_IndexBuffer_size / 2]; for (int i = 0; i < m_IndexBuffer_size / 2; i++) { m_IndexBuffer[i] = reader.ReadUInt16(); } reader.AlignStream(); } else { m_IndexBuffer = new uint[m_IndexBuffer_size / 4]; for (int i = 0; i < m_IndexBuffer_size / 4; i++) { m_IndexBuffer[i] = reader.ReadUInt32(); } reader.AlignStream(); } } if (version[0] < 3 || (version[0] == 3 && version[1] < 5)) //3.4.2 and earlier { m_VertexCount = reader.ReadInt32(); m_Vertices = reader.ReadSingleArray(m_VertexCount * 3); //Vector3 m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } m_BindPose = reader.ReadMatrixArray(); m_UV0 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 m_UV1 = reader.ReadSingleArray(reader.ReadInt32() * 2); //Vector2 if (version[0] == 2 && version[1] <= 5) //2.5 and down { int m_TangentSpace_size = reader.ReadInt32(); m_Normals = new float[m_TangentSpace_size * 3]; for (int v = 0; v < m_TangentSpace_size; v++) { m_Normals[v * 3] = reader.ReadSingle(); m_Normals[v * 3 + 1] = reader.ReadSingle(); m_Normals[v * 3 + 2] = reader.ReadSingle(); reader.Position += 16; //Vector3f tangent & float handedness } } else //2.6.0 and later { m_Tangents = reader.ReadSingleArray(reader.ReadInt32() * 4); //Vector4 m_Normals = reader.ReadSingleArray(reader.ReadInt32() * 3); //Vector3 } } else { if (version[0] < 2018 || (version[0] == 2018 && version[1] < 2)) //2018.2 down { m_Skin = new BoneWeights4[reader.ReadInt32()]; for (int s = 0; s < m_Skin.Length; s++) { m_Skin[s] = new BoneWeights4(reader); } } if (version[0] == 3 || (version[0] == 4 && version[1] <= 2)) //4.2 and down { m_BindPose = reader.ReadMatrixArray(); } m_VertexData = new VertexData(reader); } if (version[0] > 2 || (version[0] == 2 && version[1] >= 6)) //2.6.0 and later { m_CompressedMesh = new CompressedMesh(reader); } reader.Position += 24; //AABB m_LocalAABB if (version[0] < 3 || (version[0] == 3 && version[1] <= 4)) //3.4.2 and earlier { int m_Colors_size = reader.ReadInt32(); m_Colors = new float[m_Colors_size * 4]; for (int v = 0; v < m_Colors_size * 4; v++) { m_Colors[v] = (float)reader.ReadByte() / 0xFF; } int m_CollisionTriangles_size = reader.ReadInt32(); reader.Position += m_CollisionTriangles_size * 4; //UInt32 indices int m_CollisionVertexCount = reader.ReadInt32(); } int m_MeshUsageFlags = reader.ReadInt32(); if (version[0] >= 5) //5.0 and up { var m_BakedConvexCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); var m_BakedTriangleCollisionMesh = reader.ReadBytes(reader.ReadInt32()); reader.AlignStream(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 2)) //2018.2 and up { var m_MeshMetrics = new float[2]; m_MeshMetrics[0] = reader.ReadSingle(); m_MeshMetrics[1] = reader.ReadSingle(); } if (version[0] > 2018 || (version[0] == 2018 && version[1] >= 3)) //2018.3 and up { reader.AlignStream(); m_StreamData = new StreamingInfo(reader); } ProcessData(); }
public BoneWeights4(ObjectReader reader) { weight = reader.ReadSingleArray(4); boneIndex = reader.ReadInt32Array(4); }
private static void DumpType(TypeSig typeSig, StringBuilder sb, ObjectReader reader, string name, int indent, bool isRoot = false) { var typeDef = typeSig.ToTypeDefOrRef().ResolveTypeDefThrow(); if (typeSig.IsPrimitive) { object value = null; switch (typeSig.TypeName) { case "Boolean": value = reader.ReadBoolean(); break; case "Byte": value = reader.ReadByte(); break; case "SByte": value = reader.ReadSByte(); break; case "Int16": value = reader.ReadInt16(); break; case "UInt16": value = reader.ReadUInt16(); break; case "Int32": value = reader.ReadInt32(); break; case "UInt32": value = reader.ReadUInt32(); break; case "Int64": value = reader.ReadInt64(); break; case "UInt64": value = reader.ReadUInt64(); break; case "Single": value = reader.ReadSingle(); break; case "Double": value = reader.ReadDouble(); break; case "Char": value = reader.ReadChar(); break; } reader.AlignStream(4); sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = {value}"); return; } if (typeSig.FullName == "System.String") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = \"{reader.ReadAlignedString()}\""); return; } if (typeSig.FullName == "System.Object") { return; } if (typeDef.IsDelegate) { return; } if (typeSig is ArraySigBase) { if (!typeDef.IsEnum && !IsBaseType(typeDef) && !IsAssignFromUnityObject(typeDef) && !IsEngineType(typeDef) && !typeDef.IsSerializable) { return; } var size = reader.ReadInt32(); sb.AppendLine($"{new string('\t', indent)}{typeSig.TypeName} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}Array Array"); sb.AppendLine($"{new string('\t', indent + 1)}int size = {size}"); for (int i = 0; i < size; i++) { sb.AppendLine($"{new string('\t', indent + 2)}[{i}]"); DumpType(typeDef.ToTypeSig(), sb, reader, "data", indent + 2); } return; } if (!isRoot && typeSig is GenericInstSig genericInstSig) { if (genericInstSig.GenericArguments.Count == 1) { var type = genericInstSig.GenericArguments[0].ToTypeDefOrRef().ResolveTypeDefThrow(); if (!type.IsEnum && !IsBaseType(type) && !IsAssignFromUnityObject(type) && !IsEngineType(type) && !type.IsSerializable) { return; } var size = reader.ReadInt32(); sb.AppendLine($"{new string('\t', indent)}{typeSig.TypeName} {name}"); sb.AppendLine($"{new string('\t', indent + 1)}Array Array"); sb.AppendLine($"{new string('\t', indent + 1)}int size = {size}"); for (int i = 0; i < size; i++) { sb.AppendLine($"{new string('\t', indent + 2)}[{i}]"); DumpType(genericInstSig.GenericArguments[0], sb, reader, "data", indent + 2); } } return; } if (indent != -1 && IsAssignFromUnityObject(typeDef)) { var pptr = reader.ReadPPtr(); sb.AppendLine($"{new string('\t', indent)}PPtr<{typeDef.Name}> {name} = {{fileID: {pptr.m_FileID}, pathID: {pptr.m_PathID}}}"); return; } if (typeDef.IsEnum) { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name} = {reader.ReadUInt32()}"); return; } if (indent != -1 && !IsEngineType(typeDef) && !typeDef.IsSerializable) { return; } if (typeDef.FullName == "UnityEngine.Rect") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var rect = reader.ReadSingleArray(4); return; } if (typeDef.FullName == "UnityEngine.LayerMask") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var value = reader.ReadInt32(); return; } if (typeDef.FullName == "UnityEngine.AnimationCurve") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var animationCurve = new AnimationCurve <float>(reader, reader.ReadSingle); return; } if (typeDef.FullName == "UnityEngine.Gradient") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); if (reader.version[0] == 5 && reader.version[1] < 5) { reader.Position += 68; } else if (reader.version[0] == 5 && reader.version[1] < 6) { reader.Position += 72; } else { reader.Position += 168; } return; } if (typeDef.FullName == "UnityEngine.RectOffset") { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); var left = reader.ReadSingle(); var right = reader.ReadSingle(); var top = reader.ReadSingle(); var bottom = reader.ReadSingle(); return; } if (typeDef.FullName == "UnityEngine.GUIStyle") //TODO { throw new NotSupportedException(); } if (typeDef.IsClass || typeDef.IsValueType) { if (name != null && indent != -1) { sb.AppendLine($"{new string('\t', indent)}{typeDef.Name} {name}"); } if (indent == -1 && typeDef.BaseType.FullName != "UnityEngine.Object") { DumpType(typeDef.BaseType.ToTypeSig(), sb, reader, null, indent, true); } if (indent != -1 && typeDef.BaseType.FullName != "System.Object") { DumpType(typeDef.BaseType.ToTypeSig(), sb, reader, null, indent, true); } foreach (var fieldDef in typeDef.Fields) { var access = fieldDef.Access & FieldAttributes.FieldAccessMask; if (access != FieldAttributes.Public) { if (fieldDef.CustomAttributes.Any(x => x.TypeFullName.Contains("SerializeField"))) { DumpType(fieldDef.FieldType, sb, reader, fieldDef.Name, indent + 1); } } else if ((fieldDef.Attributes & FieldAttributes.Static) == 0 && (fieldDef.Attributes & FieldAttributes.InitOnly) == 0 && (fieldDef.Attributes & FieldAttributes.NotSerialized) == 0) { DumpType(fieldDef.FieldType, sb, reader, fieldDef.Name, indent + 1); } } } }
public ConstantClip(ObjectReader reader) { int numData = reader.ReadInt32(); data = reader.ReadSingleArray(numData); }
public ConstantClip(ObjectReader reader) { data = reader.ReadSingleArray(); }