Beispiel #1
0
        public void ReadFromFile(MemoryStream reader, bool isBigEndian)
        {
            header = new FrameHeader();
            header.ReadFromFile(reader, isBigEndian);

            int j = 0;

            for (int i = 0; i != header.SceneFolders.Count; i++)
            {
                frameScenes.Add(header.SceneFolders[i].RefID, header.SceneFolders[i]);
                NewFrames.Add(new FrameHolder(j++, header.SceneFolders[i]));
            }
            for (int i = 0; i != header.NumGeometries; i++)
            {
                FrameGeometry geo = new FrameGeometry(reader, isBigEndian);
                frameGeometries.Add(geo.RefID, geo);
                NewFrames.Add(new FrameHolder(j++, geo));
            }
            for (int i = 0; i != header.NumMaterialResources; i++)
            {
                FrameMaterial mat = new FrameMaterial(reader, isBigEndian);
                frameMaterials.Add(mat.RefID, mat);
                NewFrames.Add(new FrameHolder(j++, mat));
            }
            for (int i = 0; i != header.NumBlendInfos; i++)
            {
                FrameBlendInfo blendInfo = new FrameBlendInfo(reader, isBigEndian);
                frameBlendInfos.Add(blendInfo.RefID, blendInfo);
                NewFrames.Add(new FrameHolder(j++, blendInfo));
            }
            for (int i = 0; i != header.NumSkeletons; i++)
            {
                FrameSkeleton skeleton = new FrameSkeleton(reader, isBigEndian);
                frameSkeletons.Add(skeleton.RefID, skeleton);
                NewFrames.Add(new FrameHolder(j++, skeleton));
            }
            for (int i = 0; i != header.NumSkelHierachies; i++)
            {
                FrameSkeletonHierachy skeletonHierachy = new FrameSkeletonHierachy(reader, isBigEndian);
                frameSkeletonHierachies.Add(skeletonHierachy.RefID, skeletonHierachy);
                NewFrames.Add(new FrameHolder(j++, skeletonHierachy));
            }

            int[] objectTypes = new int[header.NumObjects];
            int   numBlocks   = header.NumFolderNames + header.NumGeometries + header.NumMaterialResources + header.NumBlendInfos + header.NumSkeletons + header.NumSkelHierachies;

            if (header.NumObjects > 0)
            {
                for (int i = 0; i != header.NumObjects; i++)
                {
                    objectTypes[i] = reader.ReadInt32(isBigEndian);
                }

                for (int i = 0; i != header.NumObjects; i++)
                {
                    FrameObjectBase newObject = new FrameObjectBase();
                    if (objectTypes[i] == (int)ObjectType.Joint)
                    {
                        newObject = new FrameObjectJoint(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.SingleMesh)
                    {
                        newObject = new FrameObjectSingleMesh(reader, isBigEndian);
                        FrameObjectSingleMesh mesh = newObject as FrameObjectSingleMesh;

                        if (mesh.MeshIndex != -1)
                        {
                            mesh.AddRef(FrameEntryRefTypes.Mesh, GetEntryFromIdx(mesh.MeshIndex).Data.RefID);
                            mesh.Geometry = frameGeometries[mesh.Refs["Mesh"]];
                        }

                        if (mesh.MaterialIndex != -1)
                        {
                            mesh.AddRef(FrameEntryRefTypes.Material, GetEntryFromIdx(mesh.MaterialIndex).Data.RefID);
                            mesh.Material = frameMaterials[mesh.Refs["Material"]];
                        }
                    }
                    else if (objectTypes[i] == (int)ObjectType.Frame)
                    {
                        newObject = new FrameObjectFrame(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Light)
                    {
                        newObject = new FrameObjectLight(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Camera)
                    {
                        newObject = new FrameObjectCamera(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Component_U00000005)
                    {
                        newObject = new FrameObjectComponent_U005(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Sector)
                    {
                        newObject = new FrameObjectSector(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Dummy)
                    {
                        newObject = new FrameObjectDummy(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.ParticleDeflector)
                    {
                        newObject = new FrameObjectDeflector(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Area)
                    {
                        newObject = new FrameObjectArea(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Target)
                    {
                        newObject = new FrameObjectTarget(reader, isBigEndian);
                    }

                    else if (objectTypes[i] == (int)ObjectType.Model)
                    {
                        FrameObjectModel mesh = new FrameObjectModel(reader, isBigEndian);
                        mesh.ReadFromFile(reader, isBigEndian);
                        mesh.ReadFromFilePart2(reader, isBigEndian, (FrameSkeleton)GetEntryFromIdx(mesh.SkeletonIndex).Data, (FrameBlendInfo)GetEntryFromIdx(mesh.BlendInfoIndex).Data);
                        mesh.AddRef(FrameEntryRefTypes.Mesh, GetEntryFromIdx(mesh.MeshIndex).Data.RefID);
                        mesh.Geometry = frameGeometries[mesh.Refs[FrameEntry.MeshRef]];
                        mesh.AddRef(FrameEntryRefTypes.Material, GetEntryFromIdx(mesh.MaterialIndex).Data.RefID);
                        mesh.Material = frameMaterials[mesh.Refs[FrameEntry.MaterialRef]];
                        mesh.AddRef(FrameEntryRefTypes.BlendInfo, GetEntryFromIdx(mesh.BlendInfoIndex).Data.RefID);
                        mesh.BlendInfo = frameBlendInfos[mesh.Refs[FrameEntry.BlendInfoRef]];
                        mesh.AddRef(FrameEntryRefTypes.Skeleton, GetEntryFromIdx(mesh.SkeletonIndex).Data.RefID);
                        mesh.Skeleton = frameSkeletons[mesh.Refs[FrameEntry.SkeletonRef]];
                        mesh.AddRef(FrameEntryRefTypes.SkeletonHierachy, GetEntryFromIdx(mesh.SkeletonHierachyIndex).Data.RefID);
                        mesh.SkeletonHierarchy = frameSkeletonHierachies[mesh.Refs[FrameEntry.SkeletonHierRef]];
                        newObject = mesh;
                    }
                    else if (objectTypes[i] == (int)ObjectType.Collision)
                    {
                        newObject = new FrameObjectCollision(reader, isBigEndian);
                    }

                    frameObjects.Add(newObject.RefID, newObject);
                    NewFrames.Add(new FrameHolder(i + numBlocks, newObject));
                }
            }
            objectTypes = null;
            DefineFrameBlockParents();
        }
Beispiel #2
0
        public static FrameObjectBase ReadFrameByObjectID(MemoryStream stream, ObjectType FrameType, bool isBigEndian)
        {
            switch (FrameType)
            {
            case ObjectType.Joint:
                FrameObjectJoint joint = new FrameObjectJoint();
                joint.ReadFromFile(stream, isBigEndian);
                return(joint);

            case ObjectType.SingleMesh:
                FrameObjectSingleMesh mesh = new FrameObjectSingleMesh();
                mesh.ReadFromFile(stream, isBigEndian);
                return(mesh);

            case ObjectType.Frame:
                FrameObjectFrame frame = new FrameObjectFrame();
                frame.ReadFromFile(stream, isBigEndian);
                return(frame);

            case ObjectType.Light:
                FrameObjectLight light = new FrameObjectLight();
                light.ReadFromFile(stream, isBigEndian);
                return(light);

            case ObjectType.Camera:
                FrameObjectCamera camera = new FrameObjectCamera();
                camera.ReadFromFile(stream, isBigEndian);
                return(camera);

            case ObjectType.Component_U00000005:
                FrameObjectComponent_U005 u005 = new FrameObjectComponent_U005();
                u005.ReadFromFile(stream, isBigEndian);
                return(u005);

            case ObjectType.Sector:
                FrameObjectSector sector = new FrameObjectSector();
                sector.ReadFromFile(stream, isBigEndian);
                return(sector);

            case ObjectType.Dummy:
                FrameObjectDummy dummy = new FrameObjectDummy();
                dummy.ReadFromFile(stream, isBigEndian);
                return(dummy);

            case ObjectType.ParticleDeflector:
                FrameObjectDeflector deflector = new FrameObjectDeflector();
                deflector.ReadFromFile(stream, isBigEndian);
                return(deflector);

            case ObjectType.Area:
                FrameObjectArea area = new FrameObjectArea();
                area.ReadFromFile(stream, isBigEndian);
                return(area);

            case ObjectType.Target:
                FrameObjectTarget target = new FrameObjectTarget();
                target.ReadFromFile(stream, isBigEndian);
                return(target);

            case ObjectType.Model:
                FrameObjectModel model = new FrameObjectModel();
                model.ReadFromFile(stream, isBigEndian);
                return(model);

            case ObjectType.Collision:
                FrameObjectCollision collision = new FrameObjectCollision();
                collision.ReadFromFile(stream, isBigEndian);
                return(collision);

            default:
                Debug.WriteLine("Missing frame type!");
                return(null);
            }
        }
Beispiel #3
0
 public FrameObjectFrame(FrameObjectFrame other) : base(other)
 {
     actorHash = other.actorHash;
 }