Example #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="flags"></param>
        /// <returns></returns>
        private string CreateQuery(GroupFlags flags)
        {
            string query = string.Empty;

            query += $"?endpoints={flags.HasFlag(GroupFlags.ENDPOINTS).ToString().ToLower()}";
            query += $"&type={flags.HasFlag(GroupFlags.TYPE).ToString().ToLower()}";
            query += $"&config={flags.HasFlag(GroupFlags.CONFIG).ToString().ToLower()}";
            query += $"&icons={flags.HasFlag(GroupFlags.ICONS).ToString().ToLower()}";
            query += $"&info={flags.HasFlag(GroupFlags.INFO).ToString().ToLower()}";
            query += $"&full={flags.HasFlag(GroupFlags.FULL).ToString().ToLower()}";

            return(query);
        }
Example #2
0
        /// <summary>
        /// Serializes the current object into a byte array.
        /// </summary>
        /// <inheritdoc/>
        public byte[] Serialize()
        {
            using (MemoryStream ms = new MemoryStream())
            {
                using (BinaryWriter bw = new BinaryWriter(ms))
                {
                    bw.Write(GroupNameOffset);
                    bw.Write(DescriptiveGroupNameOffset);

                    // Set the flags according to present chunks
                    UpdateFlags();
                    bw.Write((uint)Flags);

                    bw.WriteBox(BoundingBox);

                    bw.Write(PortalReferenceStartingIndex);
                    bw.Write(PortalReferenceCount);

                    bw.Write(RenderBatchCountA);
                    bw.Write(RenderBatchCountInterior);
                    bw.Write(RenderBatchCountExterior);
                    bw.Write(Unknown);

                    foreach (byte fogIndex in FogIndices)
                    {
                        bw.Write(fogIndex);
                    }

                    bw.Write(LiquidType);
                    bw.Write(GroupID.Key);

                    bw.Write(UnknownFlags);
                    bw.Write(Unused);

                    // Write the mandatory chunks
                    bw.WriteIFFChunk(PolygonMaterials);
                    bw.WriteIFFChunk(VertexIndices);
                    bw.WriteIFFChunk(Vertices);
                    bw.WriteIFFChunk(Normals);
                    bw.WriteIFFChunk(TextureCoordinates);
                    bw.WriteIFFChunk(RenderBatches);

                    // Write the optional chunks based on flags
                    if (mobs != null)
                    {
                        bw.WriteIFFChunk(mobs);
                    }

                    if (Flags.HasFlag(GroupFlags.HasLights))
                    {
                        bw.WriteIFFChunk(LightReferences);
                    }

                    if (Flags.HasFlag(GroupFlags.HasDoodads))
                    {
                        bw.WriteIFFChunk(DoodadReferences);
                    }

                    if (Flags.HasFlag(GroupFlags.HasBSP))
                    {
                        bw.WriteIFFChunk(BSPNodes);
                        bw.WriteIFFChunk(BSPFaceIndices);
                    }

                    if (Flags.HasFlag(GroupFlags.UnknownLODRelated))
                    {
                        bw.WriteIFFChunk(mpbv);
                        bw.WriteIFFChunk(mpbp);
                        bw.WriteIFFChunk(mpbi);
                        bw.WriteIFFChunk(mpbg);
                    }

                    if (Flags.HasFlag(GroupFlags.HasVertexColours))
                    {
                        bw.WriteIFFChunk(VertexColours);
                    }

                    if (Flags.HasFlag(GroupFlags.HasLiquids))
                    {
                        bw.WriteIFFChunk(Liquids);
                    }

                    if (Flags.HasFlag(GroupFlags.HasTriangleStrips))
                    {
                        bw.WriteIFFChunk(TriangleStripIndices);
                        bw.WriteIFFChunk(TriangleStrips);
                    }

                    if (Flags.HasFlag(GroupFlags.HasTwoTextureCoordinateSets))
                    {
                        bw.WriteIFFChunk(AdditionalTextureCoordinates);
                    }

                    if (Flags.HasFlag(GroupFlags.HasTwoVertexShadingSets))
                    {
                        bw.WriteIFFChunk(AdditionalVertexColours);
                    }

                    if (Flags.HasFlag(GroupFlags.HasThreeTextureCoordinateSets))
                    {
                        bw.WriteIFFChunk(SecondAddtionalTextureCoordinates);
                    }
                }

                return(ms.ToArray());
            }
        }
Example #3
0
        /// <summary>
        /// Deserialzes the provided binary data of the object. This is the full data block which follows the data
        /// signature and data block length.
        /// </summary>
        /// <param name="inData">The binary data containing the object.</param>
        /// <inheritdoc/>
        public void LoadBinaryData(byte[] inData)
        {
            using (MemoryStream ms = new MemoryStream(inData))
            {
                using (BinaryReader br = new BinaryReader(ms))
                {
                    GroupNameOffset            = br.ReadUInt32();
                    DescriptiveGroupNameOffset = br.ReadUInt32();

                    Flags = (GroupFlags)br.ReadUInt32();

                    BoundingBox = br.ReadBox();

                    PortalReferenceStartingIndex = br.ReadUInt16();
                    PortalReferenceCount         = br.ReadUInt16();

                    RenderBatchCountA        = br.ReadUInt16();
                    RenderBatchCountInterior = br.ReadUInt16();
                    RenderBatchCountExterior = br.ReadUInt16();
                    Unknown = br.ReadUInt16();

                    for (int i = 0; i < 4; ++i)
                    {
                        FogIndices.Add(br.ReadByte());
                    }

                    LiquidType = br.ReadUInt32();
                    GroupID    = new ForeignKey <uint>(DatabaseName.WMOAreaTable, nameof(WMOAreaTableRecord.WMOGroupID), br.ReadUInt32());

                    UnknownFlags = br.ReadUInt32();
                    Unused       = br.ReadUInt32();

                    // Required subchunks
                    PolygonMaterials   = br.ReadIFFChunk <ModelPolygonMaterials>();
                    VertexIndices      = br.ReadIFFChunk <ModelVertexIndices>();
                    Vertices           = br.ReadIFFChunk <ModelVertices>();
                    Normals            = br.ReadIFFChunk <ModelNormals>();
                    TextureCoordinates = br.ReadIFFChunk <ModelTextureCoordinates>();
                    RenderBatches      = br.ReadIFFChunk <ModelRenderBatches>();

                    // Optional chunks
                    if (br.PeekChunkSignature() == MOBS.Signature)
                    {
                        mobs = br.ReadIFFChunk <MOBS>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasLights))
                    {
                        LightReferences = br.ReadIFFChunk <ModelLightReferences>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasDoodads))
                    {
                        DoodadReferences = br.ReadIFFChunk <ModelDoodadReferences>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasBSP))
                    {
                        BSPNodes       = br.ReadIFFChunk <ModelBSPNodes>();
                        BSPFaceIndices = br.ReadIFFChunk <ModelBSPFaceIndices>();
                    }

                    if (Flags.HasFlag(GroupFlags.UnknownLODRelated))
                    {
                        mpbv = br.ReadIFFChunk <MPBV>();
                        mpbp = br.ReadIFFChunk <MPBP>();
                        mpbi = br.ReadIFFChunk <MPBI>();
                        mpbg = br.ReadIFFChunk <MPBG>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasVertexColours))
                    {
                        VertexColours = br.ReadIFFChunk <ModelVertexColours>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasLiquids))
                    {
                        Liquids = br.ReadIFFChunk <ModelLiquids>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasTriangleStrips))
                    {
                        TriangleStripIndices = br.ReadIFFChunk <ModelTriangleStripIndices>();
                        TriangleStrips       = br.ReadIFFChunk <ModelTriangleStrips>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasTwoTextureCoordinateSets))
                    {
                        AdditionalTextureCoordinates = br.ReadIFFChunk <ModelTextureCoordinates>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasTwoVertexShadingSets))
                    {
                        AdditionalVertexColours = br.ReadIFFChunk <ModelVertexColours>();
                    }

                    if (Flags.HasFlag(GroupFlags.HasThreeTextureCoordinateSets))
                    {
                        SecondAddtionalTextureCoordinates = br.ReadIFFChunk <ModelTextureCoordinates>();
                    }
                }
            }
        }
Example #4
0
        public void groupApplyModifiers()
        {
            RuntimeData rd = RuntimeData.get();

            Model model = m_model;

            if (null == model)
            {
                return;
            }
            GeometryModifiersData mods = rd.m_modifiers.findGeomModifier(model.name, m_dir);

            if (null == mods)
            {
                return;
            }

            if (mods.LodNear != 0.0f)
            {
                lod_near = mods.LodNear;
            }
            if (mods.LodFar != 0.0f)
            {
                lod_far = mods.LodFar;
            }
            if (mods.LodNearFade != 0.0f)
            {
                lod_near_fade = mods.LodNearFade;
            }
            if (mods.LodFarFade != 0.0f)
            {
                lod_far_fade = mods.LodFarFade;
            }
            if (mods.LodScale != 0.0f)
            {
                lod_scale = mods.LodScale;
            }

            GroupFlags v1 = (GroupFlags)mods.GroupFlags;

            shadow_dist    = mods.ShadowDist;
            parent_fade    = v1.HasFlag(GroupFlags.ParentFade);
            region_marker  = v1.HasFlag(GroupFlags.RegionMarker);
            volume_trigger = v1.HasFlag(GroupFlags.VolumeTrigger);
            water_volume   = v1.HasFlag(GroupFlags.WaterVolume);
            lava_volume    = v1.HasFlag(GroupFlags.LavaVolume);
            sewer_volume   = v1.HasFlag(GroupFlags.SewerWaterVolume);
            door_volume    = v1.HasFlag(GroupFlags.DoorVolume);
            key_light      = v1.HasFlag(GroupFlags.KeyLight);
            tray           = v1.HasFlag(GroupFlags.VisTray) | v1.HasFlag(GroupFlags.VisOutside);

            if (mods.LodNear != 0.0f || mods.LodFar != 0.0f || mods.LodNearFade != 0.0f || mods.LodFarFade != 0.0f ||
                mods.LodScale != 0.0f)
            {
                lod_fromtrick = true;
            }

            /*
             * if (mods.node._TrickFlags.HasFlag(TrickFlags.NoColl))
             *  ; //TODO: disable collisions for this node
             * if (mods.node._TrickFlags.HasFlag(TrickFlags.SelectOnly))
             *  ; // set the model's triangles as only selectable ?? ( selection mesh ? )
             * if (mods.node._TrickFlags.HasFlag(TrickFlags.NotSelectable))
             *  ; //
             */
        }