Exemplo n.º 1
0
 public override GenericRCOLResource.ChunkEntry Export(
     IDictionary<ulong, string> nameMap, bool exportAllNames)
 {
     System.IO.Stream s = null;
     TGIBlock tgi
         = new TGIBlock(0, null, "ITG", ResourceType, 0, 0);
     JazzCreatePropNode jcpn = new JazzCreatePropNode(0, null, s);
     jcpn.ActorDefinitionIndex = this.mPropActor == null
         ? NullCRef : this.mPropActor.ChunkReference;
     jcpn.ParameterDefinitionIndex = this.mPropParam == null
         ? NullCRef : this.mPropParam.ChunkReference;
     jcpn.PropResource = this.mPropKey;
     if (this.TargetCount > 0)
     {
         JazzChunk.ChunkReferenceList dgi = jcpn.DecisionGraphIndexes;
         DecisionGraphNode[] targets = this.Targets;
         Array.Sort(targets, 0, targets.Length,
             AChunkObject.InstantiationComparer.Instance);
         for (int i = 0; i < targets.Length; i++)
         {
             dgi.Add(targets[i] == null
                 ? NullCRef : targets[i].ChunkReference);
         }
     }
     return new GenericRCOLResource.ChunkEntry(0, null, tgi, jcpn);
 }
 public TerrainPaintBrushCatalogResource(int APIversion,
     uint version,
     uint brushVersion,
     Common common,
     BrushOperation normalOperation, BrushOperation oppositeOperation, TGIBlock profileTexture, BrushOrientation orientation,
     float width, float strength, byte baseTextureValue, float wiggleAmount,
     TGIBlock brushTexture,
     TerrainType terrain, CategoryType category
     )
     : base(APIversion,
         version,
         brushVersion,
         common,
         normalOperation,
         oppositeOperation,
         profileTexture,
         orientation,
         width,
         strength,
         baseTextureValue,
         wiggleAmount
     )
 {
     this.brushTexture = (TGIBlock)brushTexture.Clone(OnResourceChanged);
     this.terrain = terrain;
     this.category = category;
 }
Exemplo n.º 3
0
 public override GenericRCOLResource.ChunkEntry Export(
     IDictionary<ulong, string> nameMap, bool exportAllNames)
 {
     System.IO.Stream s = null;
     TGIBlock tgi
         = new TGIBlock(0, null, "ITG", ResourceType, 0, 0);
     JazzRandomNode jrn = new JazzRandomNode(0, null, s);
     if (this.mSlices.Count > 0)
     {
         JazzRandomNode.Outcome outcome;
         JazzRandomNode.OutcomeList oList = jrn.Outcomes;
         JazzChunk.ChunkReferenceList dgi;
         foreach (Slice slice in this.mSlices)
         {
             outcome = new JazzRandomNode.Outcome(0, null);
             outcome.Weight = slice.Weight;
             dgi = outcome.DecisionGraphIndexes;
             foreach (DecisionGraphNode dgn in slice.Targets)
             {
                 dgi.Add(dgn == null ? NullCRef : dgn.ChunkReference);
             }
             oList.Add(outcome);
         }
     }
     jrn.Properties = this.mFlags;
     return new GenericRCOLResource.ChunkEntry(0, null, tgi, jrn);
 }
Exemplo n.º 4
0
 public override GenericRCOLResource.ChunkEntry Export(
     IDictionary<ulong, string> nameMap, bool exportAllNames)
 {
     System.IO.Stream s = null;
     TGIBlock tgi
         = new TGIBlock(0, null, "ITG", ResourceType, 0, 0);
     JazzStopAnimationNode jsan
         = new JazzStopAnimationNode(0, null, s);
     jsan.AnimationFlags = this.Flags;
     jsan.AnimationPriority1 = this.Priority;
     jsan.BlendInTime = this.BlendInTime;
     jsan.BlendOutTime = this.BlendOutTime;
     jsan.Speed = this.Speed;
     ActorDefinition actor = this.Actor;
     jsan.ActorDefinitionIndex = actor == null
         ? NullCRef : actor.ChunkReference;
     jsan.TimingPriority = this.TimingPriority;
     if (this.TargetCount > 0)
     {
         JazzChunk.ChunkReferenceList dgi = jsan.DecisionGraphIndexes;
         DecisionGraphNode[] targets = this.Targets;
         Array.Sort(targets, 0, targets.Length,
             AChunkObject.InstantiationComparer.Instance);
         for (int i = 0; i < targets.Length; i++)
         {
             dgi.Add(targets[i] == null
                 ? NullCRef : targets[i].ChunkReference);
         }
     }
     return new GenericRCOLResource.ChunkEntry(0, null, tgi, jsan);
 }
Exemplo n.º 5
0
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.modlEntryList1 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList2 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList3 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList4 = new ModlEntryList(OnResourceChanged, s);
     this.modlTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference4 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference5 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference6 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference7 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.unknown1 = r.ReadUInt32();
     this.unknown2 = r.ReadByte();
     this.unknown3 = r.ReadUInt32();
     this.catalogGroupID = r.ReadUInt64();
     this.rsltTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.unknownList1 = new SimpleList<uint>(OnResourceChanged);
     ushort count = r.ReadUInt16();
     for (int i = 0; i < count; i++) this.unknownList1.Add(r.ReadUInt32());
     this.unknownList2 = new SimpleList<uint>(OnResourceChanged);
     count = r.ReadUInt16();
     for (int i = 0; i < count; i++) this.unknownList2.Add(r.ReadUInt32());
     count = r.ReadUInt16();
     this.unknownList3 = new SimpleList<uint>(OnResourceChanged);
     for (int i = 0; i < count; i++) this.unknownList3.Add(r.ReadUInt32());
     this.colorList = new SwatchColorList(OnResourceChanged, s);
     this.unknown4 = r.ReadUInt32();
 }
Exemplo n.º 6
0
 protected override Stream UnParse()
 {
     var s = base.UnParse();
     BinaryWriter w = new BinaryWriter(s);
     if (this.modlEntryList1 == null) this.modlEntryList1 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList1.UnParse(s);
     if (this.modlEntryList2 == null) this.modlEntryList2 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList2.UnParse(s);
     if (this.modlEntryList3 == null) this.modlEntryList3 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList3.UnParse(s);
     if (this.modlEntryList4 == null) this.modlEntryList4 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList4.UnParse(s);
     if (this.modlTGIReference1 == null) this.modlTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.modlTGIReference1.UnParse(s);
     if (this.modlTGIReference2 == null) this.modlTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.modlTGIReference2.UnParse(s);
     if (this.modlTGIReference3 == null) this.modlTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.modlTGIReference3.UnParse(s);
     if (this.modlTGIReference4 == null) this.modlTGIReference4 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.modlTGIReference4.UnParse(s);
     if (this.modlTGIReference5 == null) this.modlTGIReference5 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.modlTGIReference5.UnParse(s);
     if (this.modlTGIReference6 == null) this.modlTGIReference6 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.modlTGIReference6.UnParse(s);
     if (this.modlTGIReference7 == null) this.modlTGIReference7 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.modlTGIReference7.UnParse(s);
     w.Write(this.unknown);
     w.Write(this.catalogGroupID);
     if (this.colorList == null) this.colorList = new SwatchColorList(OnResourceChanged);
     this.colorList.UnParse(s);
     return s;
 }
Exemplo n.º 7
0
 public RigEditorViewModel(RigResource.RigResource rig)
 {
     rig.ResourceChanged += OnResourceChanged;
     mIsSaving = false;
     mChildren = new ObservableCollection<BoneViewModel>();
     mRig = rig;
     mManager = new BoneManager();
     mManager.Bones = mRig.Bones;
     foreach (RigResource.RigResource.Bone bone in mRig.Bones)
     {
         if (bone.ParentBoneIndex == -1)
         {
             mChildren.Add(new BoneViewModel(this, this, bone, mManager));
         }
     }
     mManager.BoneAdded += OnBoneAdded;
     mManager.BoneRemoved += OnBoneRemoved;
     mManager.BoneParentChanged += OnBoneParentChanged;
     AddBoneCommand = new UserCommand<RigEditorViewModel>(x => true, y => y.Manager.AddBone(new RigResource.RigResource.Bone(0, null), null));
     GetMatrixInfoCommand = new UserCommand<RigEditorViewModel>(x => true, ExecuteMatrixInfo);
     CommitCommand = new UserCommand<RigEditorViewModel>(x => true, y =>
         {
             mIsSaving = true;
             Application.Current.Shutdown();
         });
     CancelCommand = new UserCommand<RigEditorViewModel>(x => true, y =>
         {
             mIsSaving = false;
             Application.Current.Shutdown();
         });
     IResourceKey key = new TGIBlock(0, null);
     key.ResourceType = 0x00000000;
 }
 public TerrainPaintBrushCatalogResource(int APIversion,
     uint version,
     uint brushVersion,
     Common common,
     BrushOperation normalOperation, BrushOperation oppositeOperation, TGIBlock profileTexture, BrushOrientation orientation,
     float width, float strength, byte baseTextureValue, float wiggleAmount,
     TGIBlock brushTexture
     )
     : this(APIversion,
         version,
         brushVersion,
         common,
         normalOperation,
         oppositeOperation,
         profileTexture,
         orientation,
         width,
         strength,
         baseTextureValue,
         wiggleAmount,
         brushTexture,
         0, 0
     )
 {
     if (checking) if (version >= 0x00000004)
             throw new InvalidOperationException(String.Format("Constructor requires terrain and category for version {0}", version));
 }
Exemplo n.º 9
0
 string MakeItem(TGIBlock tgib)
 {
     string s = "";
     if (ExtList.Ext.ContainsKey("0x" + tgib.ResourceType.ToString("X8")))
         s += " (" + ExtList.Ext["0x" + tgib.ResourceType.ToString("X8")][0] + ")";
     return tgib + s;
 }
 public TerrainGeometryWaterBrushCatalogResource(int APIversion,
     uint version,
     uint brushVersion,
     Common common,
     BrushOperation normalOperation,
     BrushOperation oppositeOperation,
     TGIBlock profileTexture,
     BrushOrientation orientation,
     float width,
     float strength,
     byte baseTextureValue,
     float wiggleAmount
     )
     : base(APIversion, version, common)
 {
     this.brushVersion = brushVersion;
     this.normalOperation = normalOperation;
     this.oppositeOperation = oppositeOperation;
     this.profileTexture = profileTexture;
     this.orientation = orientation;
     this.width = width;
     this.strength = strength;
     this.baseTextureValue = baseTextureValue;
     this.wiggleAmount = wiggleAmount;
 }
Exemplo n.º 11
0
 protected override Stream UnParse()
 {
     var s = base.UnParse();
     BinaryWriter w = new BinaryWriter(s);
     if (this.modlList == null)
     {                                           
         TGIBlock[] tgiList = new TGIBlock[8];
         for (int i = 0; i < 8; i++) tgiList[i] = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
         this.modlList = new CountedTGIBlockList(OnResourceChanged, tgiList);
     }
     foreach (var tgi in this.modlList)
     {
         // There is a bug in Peter's code.
         // The TGIBlcok being copied for several times and the TGI order got lost
         w.Write(tgi.Instance);
         w.Write(tgi.ResourceType);
         w.Write(tgi.ResourceGroup);
     }
     w.Write(this.unknown1);
     w.Write(this.unknown2);
     w.Write(this.unknown3);
     if (colorList == null) this.colorList = new SwatchColorList(OnResourceChanged);
     this.colorList.UnParse(s);
     return s;
 }
Exemplo n.º 12
0
 public TerrainPaintBrushCatalogResource(int APIversion, Stream unused, TerrainPaintBrushCatalogResource basis)
     : base(APIversion, null, basis)
 {
     this.brushTexture = (TGIBlock)basis.brushTexture.Clone(OnResourceChanged);
     this.terrain = basis.terrain;
     this.category = basis.category;
 }
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.cobjTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.cobjTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.cobjTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
 }
Exemplo n.º 14
0
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.unknown = r.ReadUInt32();
     this.matdTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.cflrTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.catalogGroupID = r.ReadUInt64();
     this.colorList = new SwatchColorList(OnResourceChanged, s);
 }
Exemplo n.º 15
0
 public override GenericRCOLResource.ChunkEntry Export(
     IDictionary<ulong, string> nameMap, bool exportAllNames)
 {
     System.IO.Stream s = null;
     TGIBlock tgi
         = new TGIBlock(0, null, "ITG", ResourceType, 0, 0);
     JazzNextStateNode jnsn = new JazzNextStateNode(0, null, s);
     jnsn.StateIndex = this.mNextState == null
         ? NullCRef : this.mNextState.ChunkReference;
     return new GenericRCOLResource.ChunkEntry(0, null, tgi, jnsn);
 }
Exemplo n.º 16
0
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.unknown1 = r.ReadUInt32();
     this.crmtTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.crtrTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.crtrTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.toolTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.unknown2 = r.ReadUInt32();
 }
Exemplo n.º 17
0
 private ListViewItem CreateListViewItem(TGIBlock tgib)
 {
     ListViewItem lvi = new ListViewItem();
     lvi.Text = s4pi.Extensions.ExtList.Ext.ContainsKey("0x" + tgib.ResourceType.ToString("X8"))
         ? s4pi.Extensions.ExtList.Ext["0x" + tgib.ResourceType.ToString("X8")][0] : "";
     lvi.SubItems.AddRange(new string[] {
         "0x" + tgib.ResourceType.ToString("X8"),
         "0x" + tgib.ResourceGroup.ToString("X8"),
         "0x" + tgib.Instance.ToString("X16"),
     });
     return lvi;
 }
 protected override Stream UnParse()
 {
     var s = base.UnParse();
     BinaryWriter w = new BinaryWriter(s);
     if (this.cobjTGIReference1 == null) this.cobjTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.cobjTGIReference1.UnParse(s);
     if (this.cobjTGIReference2 == null) this.cobjTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.cobjTGIReference2.UnParse(s);
     if (this.cobjTGIReference3 == null) this.cobjTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.cobjTGIReference3.UnParse(s);
     return s;
 }
Exemplo n.º 19
0
 protected override void Parse(Stream s)
 {
     BinaryReader r = new BinaryReader(s);
     base.Parse(s);
     TGIBlock[] tgiList = new TGIBlock[8];
     for (int i = 0; i < 8; i++) tgiList[i] = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlList = new CountedTGIBlockList(OnResourceChanged, "ITG", tgiList);
     this.unknown1 = r.ReadUInt32();
     this.unknown2 = r.ReadUInt64();
     this.unknown3 = r.ReadUInt32();
     if (this.colorList == null) this.colorList = new SwatchColorList(OnResourceChanged);
     this.colorList = new SwatchColorList(OnResourceChanged, s);
 }
Exemplo n.º 20
0
 protected override Stream UnParse()
 {
     var s = base.UnParse();
     BinaryWriter w = new BinaryWriter(s);
     w.Write(this.unknown);
     if (this.matdTGIReference == null) this.matdTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.matdTGIReference.UnParse(s);
     if (this.cflrTGIReference == null) this.cflrTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.cflrTGIReference.UnParse(s);
     w.Write(this.catalogGroupID);
     if (this.colorList == null) this.colorList = new SwatchColorList(OnResourceChanged);
     this.colorList.UnParse(s);
     return s;
 }
Exemplo n.º 21
0
        static int Main(params string[] args)
        {
#if DEBUG
            if (args.Length == 0)
            {
                TGIBlock tgib = new TGIBlock(0, null, "ITG", 0x736884F1, 0, 0);
                ARCOLBlock rcol = GenericRCOLResourceHandler.CreateRCOLBlock(0, null, 0x736884F1);
                GenericRCOLResource.ChunkEntry ce = new GenericRCOLResource.ChunkEntry(0, null, tgib, rcol);
                GenericRCOLResource grr = new GenericRCOLResource(0, null);
                grr.ChunkEntries.Add(ce);
                Clipboard.SetData(DataFormats.Serializable, grr.Stream);
            }
#endif
            return s3pi.Helpers.RunHelper.Run(typeof(MainForm), args);
        }
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.brushVersion = r.ReadUInt32();
     common = new Common(requestedApiVersion, OnResourceChanged, s);
     this.normalOperation = (BrushOperation)r.ReadUInt32();
     this.oppositeOperation = (BrushOperation)r.ReadUInt32();
     this.profileTexture = new TGIBlock(requestedApiVersion, OnResourceChanged, s);
     this.orientation = (BrushOrientation)r.ReadUInt32();
     this.width = r.ReadSingle();
     this.strength = r.ReadSingle();
     this.baseTextureValue = r.ReadByte();
     this.wiggleAmount = r.ReadSingle();
 }
Exemplo n.º 23
0
        protected override Stream UnParse()
        {
            if (version == 0 && publicChunks == 0 && unused == 0 && blockList == null && resources == null)
            {
                // In that case, assume we're a newly created "stream == null" situation GenericRCOLResource that needs
                // some help to become a real life GeometryResource.

                resources = new CountedTGIBlockList(OnResourceChanged, "ITG");
                // Unfortunately, a Resource does not know its own ResourceKey.  This is the best we can manage.
                TGIBlock rk = new TGIBlock(0, null, 0x015A1849, 0, 0);
                GEOM geom = new GEOM(requestedApiVersion, OnResourceChanged);
                blockList = new ChunkEntryList(OnResourceChanged, new ChunkEntry[] { new ChunkEntry(0, OnResourceChanged, rk, geom), }) { ParentTGIBlocks = Resources, };
            }
            return base.UnParse();
        }
        protected override void Parse(Stream s)
        {
            base.Parse(s);
            this.brushTexture = new TGIBlock(requestedApiVersion, OnResourceChanged, s);

            if (version >= 4)
            {
                BinaryReader r = new BinaryReader(s);
                this.terrain = (TerrainType)r.ReadUInt32();
                this.category = (CategoryType)r.ReadUInt32();
            }

            if (checking) if (this.GetType().Equals(typeof(TerrainPaintBrushCatalogResource)) && s.Position != s.Length)
                    throw new InvalidDataException(String.Format("Data stream length 0x{0:X8} is {1:X8} bytes longer than expected at {2:X8}",
                        s.Length, s.Length - s.Position, s.Position));
        }
Exemplo n.º 25
0
 protected override Stream UnParse()
 {
     var s = base.UnParse();
     BinaryWriter w = new BinaryWriter(s);
     w.Write(this.unknown1);
     if (this.crmtTGIReference == null) this.crmtTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.crmtTGIReference.UnParse(s);
     if (this.crtrTGIReference1 == null) this.crtrTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.crtrTGIReference1.UnParse(s);
     if (this.crtrTGIReference2 == null) this.crtrTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.crtrTGIReference2.UnParse(s);
     if (this.toolTGIReference == null) this.toolTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
     this.toolTGIReference.UnParse(s);
     w.Write(this.unknown2);
     return s;
 }
Exemplo n.º 26
0
        protected override void Parse(Stream s)
        {
            base.Parse(s);
            BinaryReader r = new BinaryReader(s);
            this.cwalTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cwalTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cfenTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cspnTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cflrTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cflrTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cobjTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cobjTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.unknTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cfndTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.ccolTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cstrTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.crmtTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cobjTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cxtrTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.nullTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.crtrTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cfrzTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cwalTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cflrTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            this.cflrTGIReference4 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);

            if (base.Version >= 0x0E)
            {
                this.nullTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
                this.nullTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
                this.cwalTGIReference4 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
                this.cflrTGIReference5 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
            }

            this.unknownList1 = new SimpleList<uint>(OnResourceChanged);
            for (var i = 0; i < r.ReadByte(); i++) this.unknownList1.Add(r.ReadUInt32());

            this.unknown1 = r.ReadUInt32();
            this.unknown2 = r.ReadUInt32();
            this.unknown3 = r.ReadUInt32();
            this.unknown4 = r.ReadUInt32();
            this.unknown5 = r.ReadByte();
            this.imgIIDReference = r.ReadUInt64();
        }
Exemplo n.º 27
0
 protected override void Parse(Stream s)
 {
     base.Parse(s);
     BinaryReader r = new BinaryReader(s);
     this.modlEntryList1 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList2 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList3 = new ModlEntryList(OnResourceChanged, s);
     this.modlEntryList4 = new ModlEntryList(OnResourceChanged, s);
     this.modlTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference4 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference5 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference6 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.modlTGIReference7 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG", s);
     this.unknown = r.ReadUInt32();
     this.catalogGroupID = r.ReadUInt64();
     this.colorList = new SwatchColorList(OnResourceChanged, s);
 }
Exemplo n.º 28
0
        private IResourceConnection OBJD_setFallback()
        {
            Diagnostics.Log("OBJD_setFallback");
            if ((base.originalKey.ResourceGroup >> 27) > 0)
            {
                return(null);                                           // Only base game objects
            }
            int          fallbackIndex = (int)(uint)base.Resource["FallbackIndex"].Value;
            TGIBlockList tgiBlocks     = base.Resource["TGIBlocks"].Value as TGIBlockList;
            TGIBlock     tgi           = tgiBlocks[fallbackIndex];

            if (tgi.Equals(s3pi.Filetable.RK.NULL))
            {
                fallbackIndex = tgiBlocks.Count;
                base.Resource["FallbackIndex"] = new TypedValue(typeof(uint), (uint)fallbackIndex, "X");
                tgiBlocks.Add(new TGIBlock(0, null, "TGI", base.originalKey.ResourceType, base.originalKey.ResourceGroup, base.originalKey.Instance));
                tgi = tgiBlocks[fallbackIndex];
                Diagnostics.Log("OBJD_setFallback: FallbackIndex: 0x" + fallbackIndex.ToString("X2") + ", Resourcekey: " + tgi);
            }
            return(new DefaultConnection(tgi, tgi, ResourceDataActions.FindWrite, "objd.TGIBlocks[" + fallbackIndex + "]"));
        }
Exemplo n.º 29
0
            public void UnParse(Stream s)
            {
                var bw = new BinaryWriter(s);

                bw.Write(Convert.ToByte(imgGroupType));
                if (imgRef01 == null)
                {
                    this.imgRef01 = new TGIBlock(kRecommendedApiVersion, null, TGIBlock.Order.ITG);
                }
                imgRef01.UnParse(s);
                if (imgRef02 == null)
                {
                    this.imgRef02 = new TGIBlock(kRecommendedApiVersion, null, TGIBlock.Order.ITG);
                }
                imgRef02.UnParse(s);
                if (imgRef03 == null)
                {
                    this.imgRef03 = new TGIBlock(kRecommendedApiVersion, null, TGIBlock.Order.ITG);
                }
                imgRef03.UnParse(s);
            }
        protected override void Parse(Stream s)
        {
            base.Parse(s);
            this.brushTexture = new TGIBlock(requestedApiVersion, OnResourceChanged, s);

            if (version >= 4)
            {
                BinaryReader r = new BinaryReader(s);
                this.terrain  = (TerrainType)r.ReadUInt32();
                this.category = (CategoryType)r.ReadUInt32();
            }

            if (checking)
            {
                if (this.GetType().Equals(typeof(TerrainPaintBrushCatalogResource)) && s.Position != s.Length)
                {
                    throw new InvalidDataException(String.Format("Data stream length 0x{0:X8} is {1:X8} bytes longer than expected at {2:X8}",
                                                                 s.Length, s.Length - s.Position, s.Position));
                }
            }
        }
Exemplo n.º 31
0
        protected override Stream UnParse()
        {
            long         posn;
            MemoryStream s = new MemoryStream();
            BinaryWriter w = new BinaryWriter(s);

            w.Write(version);

            posn = s.Position;
            w.Write((uint)0);
            w.Write((uint)0);

            BigEndianUnicodeString.Write(s, partName);
            w.Write(unknown1);

            if (version >= 8)
            {
                if (blendGeometry == null)
                {
                    blendGeometry = new TGIBlock(requestedApiVersion, OnResourceChanged);
                }
                blendGeometry.UnParse(s);
            }

            if (tgiBlocks == null)
            {
                tgiBlocks = new TGIBlockList(OnResourceChanged, true);
            }
            if (casEntries == null)
            {
                casEntries = new CASEntryList(OnResourceChanged, tgiBlocks);
            }
            casEntries.UnParse(s);

            tgiBlocks.UnParse(s, posn);

            s.Flush();

            return(s);
        }
Exemplo n.º 32
0
        void Parse(Stream s)
        {
            var br = new BinaryReader(s);

            this.version         = br.ReadUInt32();
            this.commonA         = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s);
            this.modlEntryList01 = new SpnFenMODLEntryList(this.OnResourceChanged, s);
            this.modlEntryList02 = new SpnFenMODLEntryList(this.OnResourceChanged, s);
            this.modlEntryList03 = new SpnFenMODLEntryList(this.OnResourceChanged, s);
            this.modlEntryList04 = new SpnFenMODLEntryList(this.OnResourceChanged, s);
            this.refList         = new Gp7references(kRecommendedApiVersion, this.OnResourceChanged, s);
            this.unk01           = br.ReadByte();
            this.unk02           = br.ReadUInt32();
            this.materialVariant = br.ReadUInt32();
            this.swatchGrouping  = br.ReadUInt64();
            this.slot            = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG, s);
            this.unkList01       = new WhateverList(this.OnResourceChanged, s);
            this.unkList02       = new WhateverList(this.OnResourceChanged, s);
            this.unkList03       = new WhateverList(this.OnResourceChanged, s);
            this.colors          = new ColorList(this.OnResourceChanged, s);
            this.unk04           = br.ReadUInt32();
        }
Exemplo n.º 33
0
        protected override Stream UnParse()
        {
            var s  = new MemoryStream();
            var bw = new BinaryWriter(s);

            bw.Write(this.version);
            if (this.commonA == null)
            {
                this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged);
            }
            this.commonA.UnParse(s);
            bw.Write(this.unk01);
            bw.Write(this.unk02);
            if (this.modlRef1 == null)
            {
                this.modlRef1 = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG);
            }
            this.modlRef1.UnParse(s);
            bw.Write(this.materialVariant);
            bw.Write(this.swatchGrouping);
            bw.Write(this.float1);
            bw.Write(this.float2);
            if (this.trimRef == null)
            {
                this.trimRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG);
            }
            this.trimRef.UnParse(s);
            if (this.modlRef2 == null)
            {
                this.modlRef2 = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG);
            }
            this.modlRef2.UnParse(s);
            if (this.colors == null)
            {
                this.colors = new ColorList(this.OnResourceChanged);
            }
            this.colors.UnParse(s);
            return(s);
        }
Exemplo n.º 34
0
        void Parse(Stream s)
        {
            s.Position = 0;
            BinaryReader r = new BinaryReader(s);

            version     = r.ReadUInt32();
            uint01      = r.ReadUInt32();
            uintlong02  = r.ReadUInt64();
            uint03      = r.ReadUInt32();
            this.myself = new TGIBlock(recommendedApiVersion, null, TGIBlock.Order.ITG, s);
            uint04      = r.ReadUInt32();
            uint05      = r.ReadUInt32();

            uint magic = r.ReadUInt32();

            if (checking)
            {
                if (magic != FOURCC("TMLT"))
                {
                    throw new InvalidDataException(String.Format("Expected magic tag 0x{0:X8}; read 0x{1:X8}; position 0x{2:X8}",
                                                                 FOURCC("TMLT"), magic, s.Position));
                }
            }
            float01    = r.ReadSingle();
            float02    = r.ReadSingle();
            float03    = r.ReadSingle();
            colorRed   = r.ReadSingle();
            colorGreen = r.ReadSingle();
            colorBlue  = r.ReadSingle();
            float07    = r.ReadSingle();
            float08    = r.ReadSingle();
            float09    = r.ReadSingle();
            float10    = r.ReadSingle();
            float11    = r.ReadSingle();
            float12    = r.ReadSingle();
            byte01     = r.ReadByte();
            byte02     = r.ReadByte();
            byte03     = r.ReadByte();
        }
Exemplo n.º 35
0
        internal static MemoryStream AddInstantiator(Package package, string instanceName, string station, bool isWorkoutStation, bool isSlowDanceStation)
        {
            MemoryStream s = null;

            try
            {
                TGIBlock tgi       = new TGIBlock(0, null, 0x0333406C, 0, FNV64.GetHash(instanceName));
                string   workout   = isWorkoutStation ? "1" : "0";
                string   slowDance = isSlowDanceStation ? "1" : "0";
                s = new MemoryStream(Encoding.ASCII.GetBytes(string.Format(kInstantiator, station, workout, slowDance)));
                package.AddResource(tgi, s, true);
                return(s);
            }
            catch
            {
                if (s != null)
                {
                    s.Close();
                }
                throw;
            }
        }
Exemplo n.º 36
0
            public void Parse(Stream s, ResourceKeyTable keys)
            {
                var br = new BinaryReader(s);

                mAgeGenderFlags = new AgeGenderFlags(0, handler, s);
                mTypeFlags      = (DataTypeFlags)br.ReadUInt32();
                mSpecularKey    = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mDetailDarkKey  = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mDetailLightKey = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mNormalMapKey   = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                mOverlayKey     = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                if (mOwner.Version >= 6)
                {
                    mMuscleNormalMapKey   = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                    mCleavageNormalMapKey = new TGIBlock(0, handler, keys[br.ReadInt32()]);
                }
                else
                {
                    mMuscleNormalMapKey   = new TGIBlock(0, handler);
                    mCleavageNormalMapKey = new TGIBlock(0, handler);
                }
            }
Exemplo n.º 37
0
        protected override Stream UnParse()
        {
            var          s = base.UnParse();
            BinaryWriter w = new BinaryWriter(s);

            if (this.cobjTGIReference1 == null)
            {
                this.cobjTGIReference1 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
            }
            this.cobjTGIReference1.UnParse(s);
            if (this.cobjTGIReference2 == null)
            {
                this.cobjTGIReference2 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
            }
            this.cobjTGIReference2.UnParse(s);
            if (this.cobjTGIReference3 == null)
            {
                this.cobjTGIReference3 = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
            }
            this.cobjTGIReference3.UnParse(s);
            return(s);
        }
Exemplo n.º 38
0
            public PackagedNMap(IPackage package, bool create)
            {
                if (package == null)
                {
                    throw new ArgumentNullException("package");
                }
                this.package = package;
                IResource nmap;
                List <IResourceIndexEntry> rieList = package.FindAll(IsNameMap);

                if ((rieList == null || rieList.Count == 0) && create)
                {
                    TGIBlock tgi = new TGIBlock(0, null, NameMapTID, 0u, 0ul);
                    nmap = WrapperDealer.CreateNewResource(0, NameMapTIDStr);
                    IResourceIndexEntry rie
                        = package.AddResource(tgi, nmap.Stream, false);
                    this.nmaps.Add(new KeyValuePair <IResourceIndexEntry,
                                                     IResource>(rie, nmap));
                }
                else
                {
                    int i, count = rieList.Count;
                    for (i = 0; i < count; i++)
                    {
                        nmap = null;
                        try
                        {
                            nmap = WrapperDealer.GetResource(0, package, rieList[i]);
                        }
                        catch { }
                        if (nmap != null)
                        {
                            this.nmaps.Add(new KeyValuePair <IResourceIndexEntry,
                                                             IResource>(rieList[i], nmap));
                        }
                    }
                }
            }
Exemplo n.º 39
0
        void Parse(Stream s)
        {
            BinaryReader r = new BinaryReader(s);

            version      = r.ReadUInt32();
            publicChunks = r.ReadInt32();
            unused       = r.ReadUInt32();
            int countResources = r.ReadInt32();
            int countChunks    = r.ReadInt32();

            TGIBlock[] chunks = new TGIBlock[countChunks];
            for (int i = 0; i < countChunks; i++)
            {
                chunks[i] = new TGIBlock(0, OnResourceChanged, "ITG", s);
            }
            resources = new CountedTGIBlockList(OnResourceChanged, "ITG", countResources, s);

            RCOLIndexEntry[] index = new RCOLIndexEntry[countChunks];
            for (int i = 0; i < countChunks; i++)
            {
                index[i].Position = r.ReadUInt32(); index[i].Length = r.ReadInt32();
            }
            if (countChunks == 1)
            {
                index[0].Position = 0x2c + (uint)countResources * 16;
                index[0].Length   = (int)(s.Length - index[0].Position);
                if (chunks[0].ResourceType == 0)
                {
                    string tag = new string(r.ReadChars(4));
                    chunks[0].ResourceType = GenericRCOLResourceHandler.RCOLTypesForTag(tag).FirstOrDefault();
                }
            }

            blockList = new ChunkEntryList(requestedApiVersion, OnResourceChanged, s, chunks, index)
            {
                ParentTGIBlocks = resources,
            };
        }
Exemplo n.º 40
0
        void Parse(Stream s)
        {
            long         tgiPosn, tgiSize;
            BinaryReader r = new BinaryReader(s);

            version = r.ReadUInt32();
            tgiPosn = r.ReadUInt32() + s.Position;
            tgiSize = r.ReadUInt32();

            partName = BigEndianUnicodeString.Read(s);
            unknown1 = r.ReadUInt32();

            if (version >= 8)
            {
                blendGeometry = new TGIBlock(requestedApiVersion, OnResourceChanged, s);
            }

            casEntries = new CASEntryList(OnResourceChanged, s);

            tgiBlocks = new TGIBlockList(OnResourceChanged, s, tgiPosn, tgiSize, addEight: version >= 8);

            casEntries.ParentTGIBlocks = tgiBlocks;
        }
Exemplo n.º 41
0
        void Parse(Stream s)
        {
            var br = new BinaryReader(s);

            this.version = br.ReadUInt32();
            this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s);
            if (this.version == 0x0D)
            {
                cstlRefsSize = 21;
            }
            cstlRefs = new TGIBlock[cstlRefsSize];
            for (int i = 0; i < cstlRefs.Length; i++)
            {
                cstlRefs[i] = new TGIBlock(requestedApiVersion, OnResourceChanged, TGIBlock.Order.ITG, s);
            }
            this.unkList1 = new UnkCSTLUintList(OnResourceChanged, s);
            this.unk01    = br.ReadUInt32();
            this.unk02    = br.ReadUInt32();
            this.unk03    = br.ReadUInt32();
            this.unk04    = br.ReadUInt32();
            this.unk05    = br.ReadByte();
            this.unkIID01 = br.ReadUInt64();
        }
 public TerrainGeometryWaterBrushCatalogResource(uint version,
                                                 uint brushVersion,
                                                 Common common,
                                                 BrushOperation normalOperation,
                                                 BrushOperation oppositeOperation,
                                                 TGIBlock profileTexture,
                                                 BrushOrientation orientation,
                                                 float width,
                                                 float strength,
                                                 byte baseTextureValue,
                                                 float wiggleAmount)
     : base(version, common)
 {
     this.brushVersion      = brushVersion;
     this.normalOperation   = normalOperation;
     this.oppositeOperation = oppositeOperation;
     this.profileTexture    = profileTexture;
     this.orientation       = orientation;
     this.width             = width;
     this.strength          = strength;
     this.baseTextureValue  = baseTextureValue;
     this.wiggleAmount      = wiggleAmount;
 }
Exemplo n.º 43
0
        internal static FileStream AddSnr(MusicFile file, Package package)
        {
            FileStream s = null;

            try
            {
                ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"lib\ealayer3.exe"),
                                                                  $"-E \"{file.mFullName}\" --single-block")
                {
                    WindowStyle = ProcessWindowStyle.Hidden
                };
                using (Process proc = new Process())
                {
                    proc.StartInfo = startInfo;
                    proc.Start();
                    proc.WaitForExit();
                }
                TGIBlock tgi     = new TGIBlock(0, null, 0x01A527DB, 0x001407EC, FNV64.GetHash(file.mDisplayName));
                string   snrName = Path.ChangeExtension(file.mFullName, ".ealayer3");
                s = File.OpenRead(snrName);
                if (package.AddResource(tgi, s, true) == null)
                {
                    throw new DuplicateFileException();
                }
                return(s);
            }
            catch
            {
                if (s != null)
                {
                    string path = s.Name;
                    s.Close();
                    File.Delete(path);
                }
                throw;
            }
        }
Exemplo n.º 44
0
        internal static MemoryStream AddPreviewTuning(string trackTitle, Package package)
        {
            MemoryStream s = null;

            try
            {
                ulong    hashedInstance = FNV64.GetHash(trackTitle);
                TGIBlock tgi            = new TGIBlock(0, null, 0x8070223D, 0x001407EC, hashedInstance);
                s = new MemoryStream();
                //Header, codec block, and start of parent block
                s.Write(BitConverter.GetBytes(3).Reverse().ToArray(), 0, 4);
                s.Write(AudioTuningHeader, 0, AudioTuningHeader.Length);
                //Parent tgi
                s.Write(new byte[] { 0x5E, 0x87, 0x99, 0x26, 0x70, 0xE5, 0x6A, 0x25 }, 0, 8);
                s.Write(InstanceTuningFooter, 0, InstanceTuningFooter.Length);
                //Start of samples block
                s.Write(SampleTuningHeader, 0, SampleTuningHeader.Length);

                byte[] b = BitConverter.GetBytes(hashedInstance);
                s.Write(b, 0, b.Length);
                s.Write(InstanceTuningFooter, 0, InstanceTuningFooter.Length);
                if (package.AddResource(tgi, s, true) == null)
                {
                    throw new DuplicateFileException();
                }
                return(s);
            }
            catch
            {
                if (s != null)
                {
                    s.Close();
                }
                throw;
            }
        }
Exemplo n.º 45
0
        protected override Stream UnParse()
        {
            var          s = base.UnParse();
            BinaryWriter w = new BinaryWriter(s);

            w.Write(this.unknown);
            if (this.matdTGIReference == null)
            {
                this.matdTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
            }
            this.matdTGIReference.UnParse(s);
            if (this.cflrTGIReference == null)
            {
                this.cflrTGIReference = new TGIBlock(RecommendedApiVersion, OnResourceChanged, "ITG");
            }
            this.cflrTGIReference.UnParse(s);
            w.Write(this.catalogGroupID);
            if (this.colorList == null)
            {
                this.colorList = new SwatchColorList(OnResourceChanged);
            }
            this.colorList.UnParse(s);
            return(s);
        }
Exemplo n.º 46
0
        private IResourceConnection OBJD_getOBJK()
        {
            Diagnostics.Log("OBJD_getOBJK");
            uint             index   = (uint)base.Resource["OBJKIndex"].Value;
            IList <TGIBlock> ltgi    = (IList <TGIBlock>)base.Resource["TGIBlocks"].Value;
            TGIBlock         objkTGI = ltgi[(int)index];

            if (preTestResources)
            {
                SpecificResource objkItem = new SpecificResource(FileTable.GameContent, objkTGI);
                if (objkItem == null || objkItem.ResourceIndexEntry == null)
                {
                    Diagnostics.Show(String.Format("OBJK {0} -> OBJK {1}: not found\n", base.originalKey, objkTGI),
                                     "Missing OBJK");
                    return(null);
                }
                else
                {
                    Diagnostics.Log(String.Format("OBJD_getOBJK: Found {0}", objkItem.LongName));
                }
            }
            return(new DefaultConnection(objkTGI, objkTGI, ResourceDataActions.FindWrite,
                                         "objd.TGIBlocks[" + (int)index + "]"));
        }
Exemplo n.º 47
0
        public List <offScale> VertsToVBUFs(GenericRCOLResource rcolResource, MLOD mlod, IResourceKey defaultRK, List <meshExpImp.ModelBlocks.Vertex[]> lmverts, List <List <meshExpImp.ModelBlocks.Vertex[]> > llverts, bool updateBBs, bool updateUVs)
        {
            // List of UV elements going off scale
            List <offScale> offScales = new List <offScale>();

            // Find everything for each mesh group
            Dictionary <GenericRCOLResource.ChunkReference, List <int> > meshGroups = new Dictionary <GenericRCOLResource.ChunkReference, List <int> >();
            Dictionary <int, VRTF>    meshVRTF     = new Dictionary <int, VRTF>();
            Dictionary <int, float[]> meshUVScales = new Dictionary <int, float[]>();

            for (int m = 0; m < mlod.Meshes.Count; m++)
            {
                if (meshGroups.ContainsKey(mlod.Meshes[m].MaterialIndex))
                {
                    meshGroups[mlod.Meshes[m].MaterialIndex].Add(m);
                }
                else
                {
                    meshGroups.Add(mlod.Meshes[m].MaterialIndex, new List <int> {
                        m
                    });
                }
                VRTF vrtf = GenericRCOLResource.ChunkReference.GetBlock(rcolResource, mlod.Meshes[m].VertexFormatIndex) as VRTF ?? VRTF.CreateDefaultForMesh(mlod.Meshes[m]);
                meshVRTF.Add(m, vrtf);

                if (updateUVs)
                {
                    rcolResource.FixUVScales(mlod.Meshes[m]);
                }
                meshUVScales.Add(m, rcolResource.GetUVScales(mlod.Meshes[m]));
            }

            // Update the VBUFs for each mesh group and set the mesh bounds whilst we're here
            foreach (var key in meshGroups.Keys)
            {
                foreach (int m in meshGroups[key])
                {
                    VBUF vbuf = GenericRCOLResource.ChunkReference.GetBlock(rcolResource, mlod.Meshes[m].VertexBufferIndex) as VBUF;
                    if (vbuf == null)
                    {
                        vbuf = new VBUF(rcolResource.RequestedApiVersion, null)
                        {
                            Version = 0x00000101, Flags = VBUF.FormatFlags.None, SwizzleInfo = new GenericRCOLResource.ChunkReference(0, null, 0),
                        }
                    }
                    ;

                    offScales.AddRange(getOffScales(m, -1, lmverts[m], meshUVScales[m]));
                    vbuf.SetVertices(mlod, m, meshVRTF[m], lmverts[m], meshUVScales[m]);

                    if (llverts[m] != null)
                    {
                        for (int g = 0; g < llverts[m].Count; g++)
                        {
                            if (llverts[m][g] != null)
                            {
                                offScales.AddRange(getOffScales(m, g, llverts[m][g], meshUVScales[m]));
                                vbuf.SetVertices(mlod, mlod.Meshes[m], g, meshVRTF[m], llverts[m][g], meshUVScales[m]);
                            }
                        }
                    }

                    IResourceKey vbufRK = GenericRCOLResource.ChunkReference.GetKey(rcolResource, mlod.Meshes[m].VertexBufferIndex);
                    if (vbufRK == null)//means we created the VBUF: create a RK and add it
                    {
                        vbufRK = new TGIBlock(0, null, defaultRK)
                        {
                            ResourceType = vbuf.ResourceType,
                        }
                    }
                    ;

                    rcolResource.ReplaceChunk(mlod.Meshes[m], "VertexBufferIndex", vbufRK, vbuf);

                    if (updateBBs)
                    {
                        mlod.Meshes[m].Bounds = vbuf.GetBoundingBox(mlod.Meshes[m], meshVRTF[m]);
                    }
                }
            }

            return(offScales);
        }
Exemplo n.º 48
0
 void MakeNew()
 {
     this.matdLabel = (MainWallHeight)0x0;
     this.matdRef   = new TGIBlock(kRecommendedApiVersion, null, TGIBlock.Order.ITG);
 }
Exemplo n.º 49
0
        //--


        public void Import_Mesh(StreamReader r, MLOD.Mesh mesh, GenericRCOLResource rcolResource, MLOD mlod, IResourceKey defaultRK, out meshExpImp.ModelBlocks.Vertex[] mverts, out List <meshExpImp.ModelBlocks.Vertex[]> lverts)
        {
            #region Import VRTF
            bool isDefaultVRTF  = false;
            VRTF defaultForMesh = VRTF.CreateDefaultForMesh(mesh);

            VRTF vrtf = new VRTF(rcolResource.RequestedApiVersion, null)
            {
                Version = 2, Layouts = null,
            };
            r.Import_VRTF(mpb, vrtf);

            IResourceKey vrtfRK = GenericRCOLResource.ChunkReference.GetKey(rcolResource, mesh.VertexFormatIndex);
            if (vrtfRK == null)
            {
                vrtfRK = GenericRCOLResource.ChunkReference.GetKey(rcolResource, mesh.SkinControllerIndex);
                if (vrtfRK == null)
                {
                    vrtfRK = GenericRCOLResource.ChunkReference.GetKey(rcolResource, mesh.ScaleOffsetIndex);
                }
                if (vrtfRK == null)
                {
                    vrtfRK = new TGIBlock(0, null, 0, 0,
                                          System.Security.Cryptography.FNV64.GetHash(DateTime.UtcNow.ToString() + defaultRK.ToString()));
                }
                vrtfRK = new TGIBlock(0, null, vrtfRK)
                {
                    ResourceType = vrtf.ResourceType,
                };
            }

            if (vrtf.Equals(defaultForMesh))
            {
                isDefaultVRTF          = true;
                mesh.VertexFormatIndex = new GenericRCOLResource.ChunkReference(0, null, 0);//Clear the reference
            }
            else
            {
                rcolResource.ReplaceChunk(mesh, "VertexFormatIndex", vrtfRK, vrtf);
            }
            #endregion

            #region Import SKIN
            // we need to read the data in the file...
            SKIN skin = new SKIN(rcolResource.RequestedApiVersion, null)
            {
                Version = 1, Bones = null,
            };
            r.Import_SKIN(mpb, skin);

            // However, we do *NOT* want to update the RCOL with what we read - we are not replacing the object skeleton here
#if UNDEF
            if (skin.Bones != null)
            {
                IResourceKey skinRK = GenericRCOLResource.ChunkReference.GetKey(rcolResource, mesh.SkinControllerIndex);
                if (skinRK == null)
                {
                    skinRK = new TGIBlock(0, null, vrtfRK)
                    {
                        ResourceType = skin.ResourceType,
                    }
                }
                ;

                rcolResource.ReplaceChunk(mesh, "SkinControllerIndex", skinRK, skin);
            }
#endif
            #endregion

            mverts = Import_VBUF_Main(r, mlod, mesh, vrtf, isDefaultVRTF);

            #region Import IBUF
            IBUF ibuf = GenericRCOLResource.ChunkReference.GetBlock(rcolResource, mesh.IndexBufferIndex) as IBUF;
            if (ibuf == null)
            {
                ibuf = new IBUF(rcolResource.RequestedApiVersion, null)
                {
                    Version = 2, Flags = IBUF.FormatFlags.DifferencedIndices, DisplayListUsage = 0,
                }
            }
            ;
            Import_IBUF_Main(r, mlod, mesh, ibuf);

            IResourceKey ibufRK = GenericRCOLResource.ChunkReference.GetKey(rcolResource, mesh.IndexBufferIndex);
            if (ibufRK == null)
            {
                ibufRK = new TGIBlock(0, null, defaultRK)
                {
                    ResourceType = ibuf.ResourceType,
                }
            }
            ;

            rcolResource.ReplaceChunk(mesh, "IndexBufferIndex", ibufRK, ibuf);
            #endregion

            // This reads both VBUF Vertex[]s and the ibufs; but the ibufs just go straight in quite happily
            lverts = Import_MeshGeoStates(r, mlod, mesh, vrtf, isDefaultVRTF, ibuf);

            #region Update the JointReferences
            UIntList joints = CreateJointReferences(mesh, mverts, lverts ?? new List <meshExpImp.ModelBlocks.Vertex[]>(), skin);

            List <uint> added   = new List <uint>(joints);
            List <uint> removed = new List <uint>();
            foreach (var j in mesh.JointReferences)
            {
                if (joints.Contains(j))
                {
                    added.Remove(j);
                }
                else
                {
                    removed.Add(j);
                }
            }

            // Remove root
            removed.Remove(0xCD68F001);

            if (added.Count != 0)
            {
                mesh.JointReferences.AddRange(added);

                System.Windows.Forms.CopyableMessageBox.Show(String.Format("Mesh: 0x{0:X8}\nJointReferences with newly assigned (via BlendIndex) vertex: {1}\n({2})",
                                                                           mesh.Name,
                                                                           added.Count,
                                                                           String.Join(", ", added.ConvertAll <string>(a => "0x" + a.ToString("X8")).ToArray())),
                                                             "Warning", System.Windows.Forms.CopyableMessageBoxButtons.OK, System.Windows.Forms.CopyableMessageBoxIcon.Warning);
            }

// with the 20120601 change to export, this warning on import has lost its severity... and been dropped.
#if UNDEF
            if (removed.Count != 0)
            {
//#if UNDEF
                // http://dino.drealm.info/den/denforum/index.php?topic=394.msg3876#msg3876
                removed.ForEach(j => mesh.JointReferences[mesh.JointReferences.IndexOf(j)] = 0);
//#endif
                // However, OM felt more comfortable if there was some indication something a little odd was going on.
                System.Windows.Forms.CopyableMessageBox.Show(String.Format("Mesh: 0x{0:X8}\nJointReferences with no assigned (via BlendIndex) vertex: {1}\n({2})",
                                                                           mesh.Name,
                                                                           removed.Count,
                                                                           String.Join(", ", removed.ConvertAll <string>(a => "0x" + a.ToString("X8")).ToArray())),
                                                             "Warning", System.Windows.Forms.CopyableMessageBoxButtons.OK, System.Windows.Forms.CopyableMessageBoxIcon.Warning);
            }
#endif
            #endregion
        }

        meshExpImp.ModelBlocks.Vertex[] Import_VBUF_Main(StreamReader r, MLOD mlod, MLOD.Mesh mesh, VRTF vrtf, bool isDefaultVRTF)
        {
            string tagLine = r.ReadTag();

            string[] split = tagLine.Split(new char[] { ' ', }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length != 2)
            {
                throw new InvalidDataException("Invalid tag line read for 'vbuf'.");
            }
            if (split[0] != "vbuf")
            {
                throw new InvalidDataException("Expected line tag 'vbuf' not found.");
            }
            int count;

            if (!int.TryParse(split[1], out count))
            {
                throw new InvalidDataException("'vbuf' line has invalid count.");
            }

            return(r.Import_VBUF(mpb, count, vrtf));
        }

        void Import_IBUF_Main(StreamReader r, MLOD mlod, MLOD.Mesh mesh, IBUF ibuf)
        {
            string tagLine = r.ReadTag();

            string[] split = tagLine.Split(new char[] { ' ', }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length != 2)
            {
                throw new InvalidDataException("Invalid tag line read for 'ibuf'.");
            }
            if (split[0] != "ibuf")
            {
                throw new InvalidDataException("Expected line tag 'ibuf' not found.");
            }
            int count;

            if (!int.TryParse(split[1], out count))
            {
                throw new InvalidDataException("'ibuf' line has invalid count.");
            }

            ibuf.SetIndices(mlod, mesh, r.Import_IBUF(mpb, IBUF.IndexCountFromPrimitiveType(mesh.PrimitiveType), count));
        }

        List <meshExpImp.ModelBlocks.Vertex[]> Import_MeshGeoStates(StreamReader r, MLOD mlod, MLOD.Mesh mesh, VRTF vrtf, bool isDefaultVRTF, IBUF ibuf)
        {
            MLOD.GeometryStateList oldGeos = new MLOD.GeometryStateList(null, mesh.GeometryStates);
            r.Import_GEOS(mpb, mesh);
            if (mesh.GeometryStates.Count <= 0)
            {
                return(null);
            }

            List <meshExpImp.ModelBlocks.Vertex[]> lverts = new List <meshExpImp.ModelBlocks.Vertex[]>();

            for (int g = 0; g < mesh.GeometryStates.Count; g++)
            {
                lverts.Add(Import_VBUF_Geos(r, mlod, mesh, g, vrtf, isDefaultVRTF));
                Import_IBUF_Geos(r, mlod, mesh, g, ibuf);
            }
            return(lverts);
        }

        UIntList CreateJointReferences(MLOD.Mesh mesh, meshExpImp.ModelBlocks.Vertex[] mverts, List <meshExpImp.ModelBlocks.Vertex[]> lverts, SKIN skin)
        {
            if (skin == null || skin.Bones == null)
            {
                return(new UIntList(null));
            }

            int maxReference = -1;

            lverts.Insert(0, mverts);
            foreach (var vertices in lverts)
            {
                if (vertices != null)
                {
                    foreach (var vert in vertices)
                    {
                        if (vert.BlendIndices != null)
                        {
                            foreach (var reference in vert.BlendIndices)
                            {
                                if ((sbyte)reference > maxReference)
                                {
                                    maxReference = reference;
                                }
                            }
                        }
                    }
                }
            }
            lverts.Remove(mverts);

            return(maxReference > -1 ? new UIntList(null, skin.Bones.GetRange(0, maxReference + 1).ConvertAll <uint>(x => x.NameHash)) : new UIntList(null));
        }

        meshExpImp.ModelBlocks.Vertex[] Import_VBUF_Geos(StreamReader r, MLOD mlod, MLOD.Mesh mesh, int geoStateIndex, VRTF vrtf, bool isDefaultVRTF)
        {
            //w.WriteLine(string.Format("vbuf {0} {1} {2}", geoStateIndex, mesh.GeometryStates[geoStateIndex].MinVertexIndex, mesh.GeometryStates[geoStateIndex].VertexCount));
            string tagLine = r.ReadTag();

            string[] split = tagLine.Split(new char[] { ' ', }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length != 4)
            {
                throw new InvalidDataException(string.Format("Invalid tag line read for geoState {0} 'vbuf'.", geoStateIndex));
            }
            if (split[0] != "vbuf")
            {
                throw new InvalidDataException("Expected line tag 'vbuf' not found.");
            }
            int lineIndex;

            if (!int.TryParse(split[1], out lineIndex))
            {
                throw new InvalidDataException(string.Format("geoState {0} 'vbuf' line has invalid geoStateIndex.", geoStateIndex));
            }
            if (lineIndex != geoStateIndex)
            {
                throw new InvalidDataException(string.Format("geoState {0} 'vbuf' line has incorrect geoStateIndex value {1}.", geoStateIndex, lineIndex));
            }
            int minVertexIndex;

            if (!int.TryParse(split[2], out minVertexIndex))
            {
                throw new InvalidDataException(string.Format("geoState {0} 'vbuf' line has invalid MinVertexIndex.", geoStateIndex));
            }
            int vertexCount;

            if (!int.TryParse(split[3], out vertexCount))
            {
                throw new InvalidDataException(string.Format("geoState {0} 'vbuf' line has invalid VertexCount.", geoStateIndex));
            }

            if (minVertexIndex + vertexCount <= mesh.MinVertexIndex + mesh.VertexCount)
            {
                mesh.GeometryStates[geoStateIndex].MinVertexIndex = minVertexIndex;
                mesh.GeometryStates[geoStateIndex].VertexCount    = vertexCount;
                return(null);
            }

            if (minVertexIndex != mesh.GeometryStates[geoStateIndex].MinVertexIndex)
            {
                throw new InvalidDataException(string.Format("geoState {0} 'vbuf' line has unexpected MinVertexIndex {1}; expected {2}.", geoStateIndex, minVertexIndex, mesh.GeometryStates[geoStateIndex].MinVertexIndex));
            }
            return(r.Import_VBUF(mpb, vertexCount, vrtf));
        }

        void Import_IBUF_Geos(StreamReader r, MLOD mlod, MLOD.Mesh mesh, int geoStateIndex, IBUF ibuf)
        {
            //w.WriteLine(string.Format("ibuf {0} {1} {2}", geoStateIndex, mesh.GeometryStates[geoStateIndex].StartIndex, mesh.GeometryStates[geoStateIndex].PrimitiveCount));
            string tagLine = r.ReadTag();

            string[] split = tagLine.Split(new char[] { ' ', }, StringSplitOptions.RemoveEmptyEntries);
            if (split.Length != 4)
            {
                throw new InvalidDataException("Invalid tag line read for 'ibuf'.");
            }
            if (split[0] != "ibuf")
            {
                throw new InvalidDataException("Expected line tag 'ibuf' not found.");
            }
            int lineIndex;

            if (!int.TryParse(split[1], out lineIndex))
            {
                throw new InvalidDataException(string.Format("geoState {0} 'ibuf' line has invalid geoStateIndex.", geoStateIndex));
            }
            if (lineIndex != geoStateIndex)
            {
                throw new InvalidDataException(string.Format("geoState {0} 'ibuf' line has incorrect geoStateIndex value {1}.", geoStateIndex, lineIndex));
            }
            int startIndex;

            if (!int.TryParse(split[2], out startIndex))
            {
                throw new InvalidDataException(string.Format("geoState {0} 'ibuf' line has invalid StartIndex.", geoStateIndex));
            }
            int primitiveCount;

            if (!int.TryParse(split[3], out primitiveCount))
            {
                throw new InvalidDataException(string.Format("geoState {0} 'ibuf' line has invalid PrimitiveCount.", geoStateIndex));
            }

            int sizePerPrimitive = IBUF.IndexCountFromPrimitiveType(mesh.PrimitiveType);

            if (startIndex + primitiveCount * sizePerPrimitive <= mesh.StartIndex + mesh.PrimitiveCount * sizePerPrimitive)
            {
                mesh.GeometryStates[geoStateIndex].StartIndex     = startIndex;
                mesh.GeometryStates[geoStateIndex].PrimitiveCount = primitiveCount;
                return;
            }

            if (startIndex != mesh.GeometryStates[geoStateIndex].StartIndex)
            {
                throw new InvalidDataException(string.Format("geoState {0} 'ibuf' line has unexpected StartIndex {1}; expected {2}.", geoStateIndex, startIndex, mesh.GeometryStates[geoStateIndex].StartIndex));
            }
            ibuf.SetIndices(mlod, mesh, geoStateIndex, r.Import_IBUF(mpb, IBUF.IndexCountFromPrimitiveType(mesh.PrimitiveType), primitiveCount));
        }
        private void Save_Click(object sender, EventArgs e)
        {
            if (calculatedHashOfNameFld.Text.Length < 5)
            {
                MessageBox.Show("Enter file name!");
            }
            else
            {
                string lang = comboBox1.SelectedValue.ToString();
                if (lang.Equals("Add All Langs At Once"))
                {
                    DataTable dt = comboBox1.DataSource as DataTable;
                    foreach (DataRow dr in dt.Rows)
                    {
                        string l = dr.ItemArray[0].ToString();
                        if (!l.Equals("Add All Langs At Once"))
                        {
                            string fn = getStblNameHash(l);

                            UInt64 fnU = Convert.ToUInt64(fn, 16);
                            //ulong a = (ulong)FNVHasherStrFunctions.fnv64HighBit("qqqq");

                            TGIBlock newnmrk = new TGIBlock(0,
                                                            null,
                                                            0x220557DA,
                                                            0x80000000,
                                                            fnU);
                            Stream s = new MemoryStream();

                            List <uint>   textResourceID = new List <uint>();
                            List <string> textString     = new List <string>();

                            ArrayList tempList = new ArrayList();

                            tempList.Add(textResourceID);
                            tempList.Add(textString);

                            mainUI.WriteSTBLStream(tempList, s);
                            var addedResIndexEntry = MainUI.imppkg.AddResource(newnmrk, s, true);
                        }
                    }
                    mainUI.saveSTBL();
                    mainUI.closeSTBL();
                    mainUI.SavePackage();
                    mainUI.closePackage();
                }
                else
                {
                    string fn = getStblNameHash(lang);

                    UInt64 fnU = Convert.ToUInt64(fn, 16);
                    //ulong a = (ulong)FNVHasherStrFunctions.fnv64HighBit("qqqq");

                    TGIBlock newnmrk = new TGIBlock(0,
                                                    null,
                                                    0x220557DA,
                                                    0x80000000,
                                                    fnU);
                    Stream s = new MemoryStream();

                    List <uint>   textResourceID = new List <uint>();
                    List <string> textString     = new List <string>();

                    ArrayList tempList = new ArrayList();

                    tempList.Add(textResourceID);
                    tempList.Add(textString);

                    mainUI.WriteSTBLStream(tempList, s);
                    var addedResIndexEntry = MainUI.imppkg.AddResource(newnmrk, s, true);
                    MainUI.lrie.Add(addedResIndexEntry);

                    BigInteger bi = BigInteger.Parse(addedResIndexEntry.Instance.ToString());
                    MainUI.packageElId = bi;

                    ArrayList textResourceID2 = new ArrayList();
                    ArrayList textString2     = new ArrayList();

                    tempList = new ArrayList();

                    tempList.Add(textResourceID2);
                    tempList.Add(textString2);

                    mainUI.STBLToDataGridView(tempList);

                    MainUI.imppkg.SavePackage();
                    MainUI.imppkg.Dispose();

                    mainUI.openPackageFile(MainUI.pathToOpenedPackageFile);
                }

                MessageBox.Show("Successfully done!");
            }
        }
Exemplo n.º 51
0
 /// <summary>
 /// Create a ChunkEntry from an existing <see cref="TGIBlock"/> and an existing <see cref="ARCOLBlock"/>.
 /// </summary>
 /// <param name="APIversion">Unused; the requested API version.</param>
 /// <param name="handler">The change event handler.</param>
 /// <param name="tgiBlock">An existing <see cref="T:TGIBlock"/>.</param>
 /// <param name="rcolBlock">An existing <see cref="ARCOLBlock"/>.</param>
 public ChunkEntry(int APIversion, EventHandler handler, TGIBlock tgiBlock, ARCOLBlock rcolBlock)
     : base(APIversion, handler)
 {
     this.tgiBlock  = tgiBlock.Clone(handler) as TGIBlock;
     this.rcolBlock = rcolBlock.Clone(handler) as ARCOLBlock;
 }
Exemplo n.º 52
0
 public ElementTextureKey(EventHandler handler, FieldType field, uint resourceType, uint resourceGroup,
                          ulong instance) : base(handler, field)
 {
     this.data = new TGIBlock(handler, "ITG", resourceType, resourceGroup, instance);
 }
Exemplo n.º 53
0
 void Parse(Stream s)
 {
     data = new TGIBlock(handler, "ITG", s); ReadZeros(s, 4);
 }
Exemplo n.º 54
0
 protected override Stream UnParse()
 {
     var s = new MemoryStream();
     var bw = new BinaryWriter(s);
     bw.Write(this.version);
     if (this.commonA == null) { this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); }
     this.commonA.UnParse(s);
     if (this.trimRef == null) { this.trimRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG); }
     this.trimRef.UnParse(s);
     bw.Write(this.materialVariant);
     if (this.modlRef == null) { this.modlRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG); }
     this.modlRef.UnParse(s);
     bw.Write(this.swatchGrouping);
     if (this.colors == null) { this.colors = new ColorList(this.OnResourceChanged); }
     this.colors.UnParse(s);
     bw.Write(this.unk02);
     return s;
 }
Exemplo n.º 55
0
 public ElementTextureKey(EventHandler handler, FieldType field, IResourceKey data) : base(handler, field)
 {
     this.data = new TGIBlock(handler, "ITG", data);
 }
Exemplo n.º 56
0
 void Parse(Stream s)
 {
     var br = new BinaryReader(s);
     this.version = br.ReadUInt32();
     this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s);
     this.trimRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG, s);
     this.materialVariant = br.ReadUInt32();
     this.modlRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG, s);
     this.swatchGrouping = br.ReadUInt64();
     this.colors = new ColorList(this.OnResourceChanged, s);
     this.unk02 = br.ReadUInt32();
 }
Exemplo n.º 57
0
        private byte[] Edit(byte[] data, Editor editor)
        {
            IResourceKey rk = new TGIBlock(0, null);
            IResource res = s4pi.WrapperDealer.WrapperDealer.CreateNewResource(0, "0x00000000");
            res.Stream.Position = 0;
            new BinaryWriter(res.Stream).Write(data);

            MemoryStream ms = editor(rk, res);

            return ms == null ? null : ms.ToArray();
        }
Exemplo n.º 58
0
 public WallImgGroupEntry(int APIversion, EventHandler handler, CornerWallHeight imgGroupType, TGIBlock imgRef01, TGIBlock imgRef02, TGIBlock imgRef03)
     : base(APIversion, handler)
 {
     this.imgGroupType = imgGroupType;
     this.imgRef01     = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, imgRef01);
     this.imgRef02     = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, imgRef02);
     this.imgRef03     = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, imgRef03);
 }
Exemplo n.º 59
0
 public CSTR_references(int APIversion, EventHandler handler, TGIBlock modlRef01, TGIBlock modlRef02, TGIBlock modlRef03, TGIBlock unkRef01, TGIBlock wallRef, TGIBlock objRef)
     : base(APIversion, handler)
 {
     this.modlRef01 = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, modlRef01);
     this.modlRef02 = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, modlRef02);
     this.modlRef03 = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, modlRef03);
     this.unkRef01  = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, unkRef01);
     this.wallRef   = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, wallRef);
     this.objRef    = new TGIBlock(kRecommendedApiVersion, handler, TGIBlock.Order.ITG, objRef);
 }
Exemplo n.º 60
0
        private void setEffectNameTSMI_Click(object sender, EventArgs e)
        {
            VisualEffectHandleContainer container = this.outputEffectLST.SelectedItem as VisualEffectHandleContainer;

            if (container != null)
            {
                container.SetEffectName(this.PromptForEffectName(container.Handle.EffectName));
                int index = this.outputEffectLST.SelectedIndex;
                this.outputEffectLST.Items.RemoveAt(index);
                this.outputEffectLST.Items.Insert(index, container);/**/
                //this.outputEffectLST.Invalidate();
            }
        }

        private void LocateMetaReferences(VisualEffectName handle, EffectResource resource,
                                          List <VisualEffectHandleContainer> references)
        {
            MetaparticleEffect[] metaEffects = EffectHelper.FindEffects <MetaparticleEffect>(handle, resource);
            if (metaEffects != null && metaEffects.Length > 0)
            {
                int i, j;
                VisualEffectName dep;
                string           effectName;
                bool             flag = false;
                for (i = 0; i < metaEffects.Length; i++)
                {
                    // compensate for variations in casing
                    effectName = metaEffects[i].ComponentName.ToLowerInvariant();
                    for (j = 0; j < references.Count && !flag; j++)
                    {
                        if (references[j].OriginalName == effectName)
                        {
                            //references[j].Dependents.Add(metaEffects[i]);
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        dep = EffectHelper.FindVisualEffectHandle(effectName, resource);
                        if (dep != null)
                        {
                            references.Add(new VisualEffectHandleContainer(
                                               new VisualEffectName(0, null, dep), resource));
                            this.LocateMetaReferences(dep, resource, references);
                        }
                    }
                    flag = false;
                    // compensate for variations in casing
                    effectName = metaEffects[i].ComponentType.ToLowerInvariant();
                    for (j = 0; j < references.Count && !flag; j++)
                    {
                        if (references[j].OriginalName == effectName)
                        {
                            //references[j].Dependents.Add(metaEffects[i]);
                            flag = true;
                        }
                    }
                    if (!flag)
                    {
                        dep = EffectHelper.FindVisualEffectHandle(effectName, resource);
                        if (dep != null)
                        {
                            references.Add(new VisualEffectHandleContainer(
                                               new VisualEffectName(0, null, dep), resource));
                            this.LocateMetaReferences(dep, resource, references);
                        }
                    }
                    flag = false;
                }
            }
        }

        private void LocateSeqReferences(VisualEffectName handle, EffectResource resource,
                                         List <VisualEffectHandleContainer> references)
        {
            SequenceEffect[] seqEffects = EffectHelper.FindEffects <SequenceEffect>(handle, resource);
            if (seqEffects != null && seqEffects.Length > 0)
            {
                int i, j, k;
                VisualEffectName dep;
                SequenceEffect   seqEffect;
                string           effectName;
                bool             flag = false;
                for (i = 0; i < seqEffects.Length; i++)
                {
                    seqEffect = seqEffects[i];
                    for (j = 0; j < seqEffect.Elements.Count; j++)
                    {
                        // compensate for variations in casing
                        effectName = seqEffect.Elements[j].EffectName.ToLowerInvariant();
                        for (k = 0; k < references.Count && !flag; k++)
                        {
                            if (references[k].OriginalName == effectName)
                            {
                                //references[j].Dependents.Add(seqEffects[i]);
                                flag = true;
                            }
                        }
                        if (!flag)
                        {
                            dep = EffectHelper.FindVisualEffectHandle(effectName, resource);
                            if (dep != null)
                            {
                                references.Add(new VisualEffectHandleContainer(
                                                   new VisualEffectName(0, null, dep), resource));
                                this.LocateSeqReferences(dep, resource, references);
                            }
                        }
                        flag = false;
                    }
                }
            }
        }

        private void cloneEffect_Click(object sender, EventArgs e)
        {
            VisualEffectName handle = (this.inputEffectLST.SelectedItem as VisualEffectHandleContainer).Handle;
            EffectResource   owner  = (this.inputEffectLST.SelectedItem as VisualEffectHandleContainer).Owner;

            if (handle != null)
            {
                VisualEffectHandleContainer con;
                foreach (VisualEffectHandleContainer container in this.outputEffectLST.Items)
                {
                    if (container.Handle.Index == handle.Index)
                    {
                        MessageBox.Show("Selected effect has already been cloned.");
                        return;
                    }
                }
                con = new VisualEffectHandleContainer(new VisualEffectName(0, null, handle), owner);
                con.SetEffectName(this.PromptForEffectName(con.OriginalName));
                this.outputEffectLST.Items.Add(con);

                List <VisualEffectHandleContainer> references = new List <VisualEffectHandleContainer>();
                this.LocateMetaReferences(handle, owner, references);
                int metaCount = references.Count;
                this.LocateSeqReferences(handle, owner, references);
                int seqCount = references.Count - metaCount;
                if (references.Count > 0)
                {
                    string format;
                    if (metaCount > 0)
                    {
                        if (seqCount > 0)
                        {
                            format = "{0} has metaparticle and sequence effects.\n";
                        }
                        else
                        {
                            format = "{0} has metaparticle effects.\n";
                        }
                    }
                    else
                    {
                        format = "{0} has sequence effects.\n";
                    }
                    DialogResult result = MessageBox.Show(
                        //string.Concat(handle.EffectName, " has metaparticle and/or sequence effects.\n",
                        string.Concat(string.Format(format, handle.EffectName),
                                      "Would you like to clone all effects referenced by them?"),
                        "Clone Referenced Effects", MessageBoxButtons.YesNo);
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        for (int i = 0; i < references.Count; i++)
                        {
                            con = references[i];
                            con.SetEffectName(this.PromptForEffectName(con.OriginalName));
                            this.outputEffectLST.Items.Add(con);
                        }
                    }
                }
                this.saveOutputBTN.Enabled  = true;
                this.printOutputBTN.Enabled = true;
            }
        }

        private void removeEffect_Click(object sender, EventArgs e)
        {
            int index = this.outputEffectLST.SelectedIndex;

            if (index >= 0)
            {
                this.outputEffectLST.Items.RemoveAt(index);
            }
            if (this.outputEffectLST.Items.Count == 0)
            {
                this.saveOutputBTN.Enabled  = false;
                this.printOutputBTN.Enabled = false;
            }
        }

        private void saveOutput_Click(object sender, EventArgs e)
        {
            /*if (this.mEffectResource == null)
             * {
             *  MessageBox.Show("Please open an effect file to clone effects from it.");
             *  return;
             * }
             * if (this.outputEffectLST.Items.Count == 0)
             * {
             *  MessageBox.Show("Please select at least one effect from the left list to clone.");
             *  return;
             * }/**/
            using (SaveFileDialog dialog = new SaveFileDialog())
            {
                dialog.Title           = "Save Effect Clone";
                dialog.Filter          = kEffectDialogFilter;
                dialog.AddExtension    = true;
                dialog.OverwritePrompt = true;
                DialogResult result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    string resName = Path.GetFileNameWithoutExtension(dialog.FileName);
                    ulong  resHash = System.Security.Cryptography.FNV64.GetHash(resName);

                    string fileName  = dialog.FileName;
                    string extension = Path.GetExtension(fileName).ToLowerInvariant();

                    if (extension == ".effects")
                    {
                        resName = kEffectS3piNameHead + resHash.ToString("X16") + "_" + resName
                                  + kEffectS3piNameTail;
                        string prompt = "Would you like to save the effect file as:\n\n" + resName
                                        + "\n\ninstead of:\n\n" + Path.GetFileName(fileName);
                        result = MessageBox.Show(prompt, "Make S3PI File Name?", MessageBoxButtons.YesNo);
                        if (result == DialogResult.Yes)
                        {
                            fileName = dialog.FileName.Replace(Path.GetFileNameWithoutExtension(fileName), resName);
                        }
                        else
                        {
                            fileName = dialog.FileName;
                        }
                    }

                    VisualEffectHandleContainer con;
                    int i, count = this.outputEffectLST.Items.Count;
                    for (i = 0; i < count; i++)
                    {
                        con = this.outputEffectLST.Items[i] as VisualEffectHandleContainer;
                        this.mOutputEffectResBuilder.AddVisualEffect(con.Handle, con.Owner);
                    }
                    this.mOutputEffectResBuilder.FlushEffects();

                    for (i = 0; i < count; i++)
                    {
                        con = this.outputEffectLST.Items[i] as VisualEffectHandleContainer;
                        this.mOutputEffectResBuilder.SetAllEffectReferences(con.OriginalName, con.Handle.EffectName);
                    }
                    //EffectResource output = this.mInputEffectResBuilder.BuildResource();
                    //this.mInputEffectResBuilder.ResetOld();

                    if (extension == ".effects")
                    {
                        using (FileStream fileStream = new FileStream(fileName, FileMode.Create))
                        {
                            this.mOutputEffectResBuilder.UnParse(fileStream);

                            /*Stream stream = output.Stream;
                             * int length = (int)stream.Length;
                             * byte[] buffer = new byte[length];
                             * stream.Read(buffer, 0, length);
                             * fileStream.Write(buffer, 0, length);/**/
                        }
                    }
                    else if (extension == ".package")
                    {
                        // Fail-safe to prevent accidental collision with existing SWB resources
                        //resHash = System.Security.Cryptography.FNV64.GetHash(resName + DateTime.Now.ToString());
                        TGIBlock     effectKey = new TGIBlock(0, null, kEffectTID, kEffectGID, resHash);
                        MemoryStream mStream   = new MemoryStream();
                        this.mOutputEffectResBuilder.UnParse(mStream);

                        TGIBlock nameMapKey = new TGIBlock(0, null, 0x0166038C, 0, 0L);
                        NameMapResource.NameMapResource nameMap
                            = new NameMapResource.NameMapResource(0, null);
                        nameMap.Add(resHash, resName);

                        IPackage effectPackage = s3pi.Package.Package.NewPackage(0);
                        effectPackage.AddResource(effectKey, mStream, false);
                        effectPackage.AddResource(nameMapKey, nameMap.Stream, false);
                        effectPackage.SaveAs(fileName);
                    }
                    this.outputEffectLST.Items.Clear();
                    this.mOutputEffectResBuilder = new EffectResourceBuilder();
                }
            }
        }