Ejemplo n.º 1
0
 public GcmfRenderContext(Gcmf gcmf)
 {
     this.Gcmf = gcmf;
     this.TransformMatrixIdxs = new byte[8];
     for (int i = 0; i < TransformMatrixIdxs.Length; i++)
     {
         TransformMatrixIdxs[i] = byte.MaxValue;
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new Gma model from a loaded OBJ/MTL model.
        /// </summary>
        /// <param name="model">The model to load the .GMA file from.</param>
        /// <param name="textureIndexMapping">Correspondence between the textures defined in the model materials and .TPL texture indices.</param>
        public Gma(ObjMtlModel model, Dictionary <Bitmap, int> textureIndexMapping)
            : this()
        {
            if (model.Objects.ContainsKey("") && model.Objects[""].Meshes.SelectMany(m => m.Faces).Any())
            {
                throw new InvalidOperationException("Geometry is not allowed outside of named objects.");
            }

            foreach (KeyValuePair <string, ObjMtlObject> objectEntry in model.Objects)
            {
                Gcmf modelObject = new Gcmf(objectEntry.Value, textureIndexMapping);
                this.Add(new GmaEntry(objectEntry.Key, modelObject));
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load a Gma model from the given .GMA stream.
        /// </summary>
        private void Load(EndianBinaryReader input, GcGame game)
        {
            int numObjs           = input.ReadInt32();
            int modelBasePosition = input.ReadInt32();

            List <GmaEntryOffsets> entryOffs = new List <GmaEntryOffsets>();

            for (int i = 0; i < numObjs; i++)
            {
                entryOffs.Add(new GmaEntryOffsets
                {
                    ModelOffset = input.ReadInt32(),
                    NameOffset  = input.ReadInt32()
                });
            }

            int nameBasePosition = Convert.ToInt32(input.BaseStream.Position);

            foreach (GmaEntryOffsets entryOff in entryOffs)
            {
                // There are some "empty" entries, without any data or a name.
                // We insert null into the container in this case.
                if (entryOff.ModelOffset != -1 || entryOff.NameOffset != 0)
                {
                    input.BaseStream.Position = nameBasePosition + entryOff.NameOffset;
                    string name = input.ReadAsciiString();

                    input.BaseStream.Position = modelBasePosition + entryOff.ModelOffset;
                    Gcmf model = new Gcmf();
                    model.Load(input, game);

                    Add(new GmaEntry(name, model));
                }
                else
                {
                    Add(null);
                }
            }
        }
Ejemplo n.º 4
0
 /// <summary>Create a new GmaEntry with the given name and associated model object.</summary>
 public GmaEntry(string name, Gcmf modelObject)
 {
     Name        = name;
     ModelObject = modelObject;
 }