Пример #1
0
        /// <summary>
        /// R_RenderScene
        /// r_refdef must be set before the first call
        /// </summary>
        private void RenderScene( )
        {
            SetupFrame( );

            SetFrustum( );

            SetupGL( );

            Occlusion.MarkLeaves( );    // done here so we know if we're in water

            DrawWorld( );               // adds entities to the list

            Host.Sound.ExtraUpdate( );  // don't let sound get messed up if going slow

            DrawEntitiesOnList( );

            Host.Video.Device.DisableMultitexture( );

            RenderDlights( );

            Particles.DrawParticles(Host.Client.cl.time, Host.Client.cl.oldtime, Host.Server.Gravity, Origin, ViewUp, ViewRight, ViewPn);

#if GLTEST
            Test_Draw();
#endif
        }
Пример #2
0
        public void OpenDoor(bool autoClose)
        {
            if (VfxState == 1)
            {
                return;
            }

            VfxState = 1;

            PacketOut Out = new PacketOut((byte)Opcodes.F_UPDATE_STATE, 20);

            Out.WriteUInt16(Oid);
            Out.WriteByte(6); //state
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(8);
            Out.WriteByte(0);
            Out.WriteByte(1);
            Out.Fill(0, 10);
            DispatchPacket(Out, false);


            if (Zone != null && Zone.Region != null && Spawn != null)
            {
                Occlusion.SetFixtureVisible(Spawn.DoorId, false);
            }

            if (autoClose)
            {
                EvtInterface.AddEvent(CloseDoor, 7000, 1);
            }
        }
Пример #3
0
        public void CloseDoor()
        {
            EvtInterface.RemoveEvent(CloseDoor);

            if (VfxState == 0)
            {
                return;
            }

            VfxState = 0;

            if (Zone != null && Zone.Region != null && Spawn != null)
            {
                Occlusion.SetFixtureVisible(Spawn.DoorId, true);
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_UPDATE_STATE, 20);

            Out.WriteUInt16(Oid);
            Out.WriteByte(6);     //state
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(8);
            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.Fill(0, 10);
            DispatchPacket(Out, false);
        }
Пример #4
0
        /// <summary>
        /// R_Init
        /// </summary>
        public void Initialise( )
        {
            for (var i = 0; i < _Frustum.Length; i++)
            {
                _Frustum[i] = new Plane( );
            }

            Host.Commands.Add("timerefresh", TimeRefresh_f);
            //Cmd.Add("envmap", Envmap_f);
            //Cmd.Add("pointfile", ReadPointFile_f);

            InitialiseClientVariables();

            Particles.InitParticles( );
            Particles.InitParticleTexture( );

            // reserve 16 textures
            PlayerTextures = new BaseTexture[16];

            for (var i = 0; i < PlayerTextures.Length; i++)
            {
                PlayerTextures[i] = BaseTexture.FromDynamicBuffer(Host.Video.Device, "_PlayerTexture{i}", new ByteArraySegment(new Byte[512 * 256 * 4]), 512, 256, false, false);
            }

            TextureChains = new TextureChains();
            Occlusion     = new Occlusion(Host, TextureChains);
        }
Пример #5
0
        /// <summary>
        /// R_SetupFrame
        /// </summary>
        private void SetupFrame( )
        {
            // don't allow cheats in multiplayer
            if (Host.Client.cl.maxclients > 1)
            {
                Host.CVars.Set("r_fullbright", false);
            }

            AnimateLight( );

            _FrameCount++;

            // build the transformation matrix for the given view angles
            Origin = _RefDef.vieworg;

            MathLib.AngleVectors(ref _RefDef.viewangles, out ViewPn, out ViewRight, out ViewUp);

            // current viewleaf
            Occlusion.SetupFrame(ref Origin);
            Host.View.SetContentsColor(Occlusion.ViewLeaf.contents);
            Host.View.CalcBlend( );

            _CacheThrash = false;
            _BrushPolys  = 0;
            _AliasPolys  = 0;
        }
Пример #6
0
 public void Dispose()
 {
     Albedo?.Dispose();
     NormalMap?.Dispose();
     HeightMap?.Dispose();
     Occlusion?.Dispose();
 }
Пример #7
0
        public void Spawn(bool attackable)
        {
            GameObject?.Destroy();

            GameObject_proto proto = GameObjectService.GetGameObjectProto(Info.GameObjectId);

            if (proto == null)
            {
                Log.Error("KeepDoor", "No Door Proto");
                return;
            }

            _logger.Debug($"Spawning Keep Door = {Info.DoorId} Number = {Info.Number} for Keep = {Keep.Info.Name}");

            GameObject_spawn spawn = new GameObject_spawn
            {
                Guid   = (uint)GameObjectService.GenerateGameObjectSpawnGUID(),
                WorldO = Info.O,
                WorldY = Info.Y,
                WorldZ = Info.Z,
                WorldX = Info.X,
                ZoneId = Info.ZoneId,
                DoorId = Info.DoorId,
            };

            spawn.BuildFromProto(proto);

            GameObject = new KeepGameObject(spawn, this, Keep);
            Region.AddObject(GameObject, spawn.ZoneId);

            GameObject.SetAttackable(attackable);

            Occlusion.SetFixtureVisible(Info.DoorId, true);
        }
Пример #8
0
        /// <summary>
        /// R_Init
        /// </summary>
        public void Initialise( )
        {
            for (var i = 0; i < _Frustum.Length; i++)
            {
                _Frustum[i] = new Plane( );
            }

            Host.Commands.Add("timerefresh", TimeRefresh_f);
            //Cmd.Add("envmap", Envmap_f);
            //Cmd.Add("pointfile", ReadPointFile_f);

            if (Host.Cvars.NoRefresh == null)
            {
                Host.Cvars.NoRefresh     = Host.CVars.Add("r_norefresh", false);
                Host.Cvars.DrawEntities  = Host.CVars.Add("r_drawentities", true);
                Host.Cvars.DrawViewModel = Host.CVars.Add("r_drawviewmodel", true);
                Host.Cvars.Speeds        = Host.CVars.Add("r_speeds", false);
                Host.Cvars.FullBright    = Host.CVars.Add("r_fullbright", false);
                Host.Cvars.LightMap      = Host.CVars.Add("r_lightmap", false);
                Host.Cvars.Shadows       = Host.CVars.Add("r_shadows", false);
                //_MirrorAlpha = Host.CVars.Add( "r_mirroralpha", "1" );
                Host.Cvars.WaterAlpha = Host.CVars.Add("r_wateralpha", 1f);
                Host.Cvars.Dynamic    = Host.CVars.Add("r_dynamic", true);
                Host.Cvars.NoVis      = Host.CVars.Add("r_novis", false);

                Host.Cvars.glFinish           = Host.CVars.Add("gl_finish", false);
                Host.Cvars.glClear            = Host.CVars.Add("gl_clear", 0f);
                Host.Cvars.glCull             = Host.CVars.Add("gl_cull", true);
                Host.Cvars.glTexSort          = Host.CVars.Add("gl_texsort", true);
                Host.Cvars.glSmoothModels     = Host.CVars.Add("gl_smoothmodels", true);
                Host.Cvars.glAffineModels     = Host.CVars.Add("gl_affinemodels", false);
                Host.Cvars.glPolyBlend        = Host.CVars.Add("gl_polyblend", true);
                Host.Cvars.glFlashBlend       = Host.CVars.Add("gl_flashblend", true);
                Host.Cvars.glPlayerMip        = Host.CVars.Add("gl_playermip", 0);
                Host.Cvars.glNoColors         = Host.CVars.Add("gl_nocolors", false);
                Host.Cvars.glKeepTJunctions   = Host.CVars.Add("gl_keeptjunctions", false);
                Host.Cvars.glReportTJunctions = Host.CVars.Add("gl_reporttjunctions", false);
                Host.Cvars.glDoubleEyes       = Host.CVars.Add("gl_doubleeys", true);
            }

            if (Host.Video.Device.Desc.SupportsMultiTexture)
            {
                Host.CVars.Set("gl_texsort", 0.0f);
            }

            Particles.InitParticles( );
            Particles.InitParticleTexture( );

            // reserve 16 textures
            PlayerTextures = new BaseTexture[16];

            for (var i = 0; i < PlayerTextures.Length; i++)
            {
                PlayerTextures[i] = BaseTexture.FromDynamicBuffer(Host.Video.Device, "_PlayerTexture{i}", new ByteArraySegment(new Byte[512 * 256 * 4]), 512, 256, false, false);
            }

            TextureChains = new TextureChains();
            Occlusion     = new Occlusion(Host, TextureChains);
        }
Пример #9
0
 protected override void SetDeath(Unit killer)
 {
     base.SetDeath(killer);
     OpenDoor(false);
     EvtInterface.RemoveEventNotify(EventName.OnReceiveDamage, OnReceiveDamage);
     _keep.OnDoorDestroyed(_keepDoor.Info.Number, killer.Realm, _keepDoor.GameObject.DoorId);
     Occlusion.SetFixtureVisible(_keepDoor.Info.DoorId, false);
 }
Пример #10
0
        public YAMLNode ExportYAML(IAssetsExporter exporter)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add("m_ProbeOcclusionLightIndex", ProbeOcclusionLightIndex.ExportYAML(true));
            node.Add("m_Occlusion", Occlusion.ExportYAML());
            node.Add("m_OcclusionMaskChannel", OcclusionMaskChannel.ExportYAML());
            return(node);
        }
Пример #11
0
        public YAMLNode ExportYAML(IExportContainer container)
        {
            YAMLMappingNode node = new YAMLMappingNode();

            node.Add(ProbeOcclusionLightIndexName, ProbeOcclusionLightIndex.ExportYAML(true));
            node.Add(OcclusionName, Occlusion.ExportYAML());
            node.Add(OcclusionMaskChannelName, OcclusionMaskChannel.ExportYAML());
            return(node);
        }
Пример #12
0
        /// <summary>
        /// R_MirrorChain
        /// </summary>
        //private void MirrorChain( MemorySurface s )
        //{
        //    if( _IsMirror )
        //        return;
        //    _IsMirror = true;
        //    _MirrorPlane = s.plane;
        //}

        /// <summary>
        /// R_RecursiveWorldNode
        /// </summary>
        private void RecursiveWorldNode(MemoryNodeBase node)
        {
            Occlusion.RecursiveWorldNode(node, _ModelOrg, _FrameCount, ref _Frustum, (surf) =>
            {
                DrawSequentialPoly(surf);
            }, (efrags) =>
            {
                StoreEfrags(efrags);
            });
        }
Пример #13
0
    /// 加载地图配置
    public void LoadMapOcclusionConfig()
    {
        JsonData jsondata = JsonMapper.ToObject(ConfigDataLoaderHelper.GetText("config/MapOcclusionConfig"));

        for (int i = 0; i < jsondata.Count; ++i)
        {
            string    weight    = jsondata[i]["weight"].ToString();
            Occlusion occlusion = new Occlusion(GenerateMesh(), int.Parse(weight));
            _occlusionDictionary[jsondata[i]["position"].ToString()] = occlusion;
        }
    }
Пример #14
0
        /// <summary>
        /// Returns LOS information about keep door
        /// </summary>
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// <returns>True if command was correctly handled, false if operation was canceled</returns>
        public static bool DoorInfo(Player plr, ref List <string> values)
        {
            if (plr.CbtInterface.GetCurrentTarget() is KeepDoor.KeepGameObject)
            {
                var door = (KeepDoor.KeepGameObject)plr.CbtInterface.GetCurrentTarget();

                plr.SendClientMessage("DoorID=" + door.DoorId);
                plr.SendClientMessage("Occlusion_Visible=" + Occlusion.GetFixtureVisible(door.DoorId));
            }
            return(true);
        }
Пример #15
0
            public void Reset(int nCols, int nRows)
            {
                var oldColOverlaps = ColOverlaps;
                var oldRowOverlaps = RowOverlaps;
                var oldMasks       = Masks;
                var oldRects       = Rects;
                var oldOcclusions  = Occlusions;

                ColOverlaps = Enumerable.Repeat(0.1f, nCols - 1).ToArray();
                RowOverlaps = Enumerable.Repeat(0.1f, nRows - 1).ToArray();

                MaskImagePath   = "";
                MaskImageToggle = false;

                Masks = new Mask[nCols * nRows];
                for (var i = 0; i < Masks.Length; i++)
                {
                    Masks [i] = new Mask(Vector2.zero, Vector2.one);
                }

                Rects = new float[4 * NUM_RECTS];

                Occlusions = new Occlusion[nCols * nRows];
                for (var i = 0; i < Occlusions.Length; i++)
                {
                    Occlusions [i] = new Occlusion();
                }

                if (oldColOverlaps != null)
                {
                    System.Array.Copy(oldColOverlaps, ColOverlaps, Mathf.Min(oldColOverlaps.Length, ColOverlaps.Length));
                }
                if (oldRowOverlaps != null)
                {
                    System.Array.Copy(oldRowOverlaps, RowOverlaps, Mathf.Min(oldRowOverlaps.Length, RowOverlaps.Length));
                }
                if (oldMasks != null)
                {
                    System.Array.Copy(oldMasks, Masks, Mathf.Min(oldMasks.Length, Masks.Length));
                }
                if (oldRects != null)
                {
                    System.Array.Copy(oldRects, Rects, Mathf.Min(oldRects.Length, Rects.Length));
                }
                if (oldOcclusions != null)
                {
                    System.Array.Copy(oldOcclusions, Occlusions, Mathf.Min(oldOcclusions.Length, Occlusions.Length));
                }

                OcclusionGamma = 0.454f;
                BlendGamma     = 0.454f;             // use this gamma value to be the exact inverse of the gamma curve that is built into a physical projector.
            }
Пример #16
0
            public override void RezUnit()
            {
                _keepDoor.GameObject = new KeepGameObject(Spawn, _keepDoor, _keep);
                Region.AddObject(_keepDoor.GameObject, Spawn.ZoneId);

                Occlusion.SetFixtureVisible(_keepDoor.Info.DoorId, true);
                Destroy();

                //if (_keepDoor.Info.Number == (int)KeepDoorType.OuterMain && _keep.LastMessage >= Keep.KeepMessage.Outer0)
                //    _keep.LastMessage = Keep.KeepMessage.Safe;
                //else if (_keepDoor.Info.Number == (int)KeepDoorType.InnerMain && _keep.LastMessage >= Keep.KeepMessage.Inner0)
                //    _keep.LastMessage = Keep.KeepMessage.Outer0;
            }
Пример #17
0
    /// <summary>
    /// Takes in raster, frustum and projects values onto point cloud. Returns list of point-values.
    /// oc: specs for occlusion approximation of point-cloud.
    /// extras: list containing point-clouds.
    /// meshGuide: guide to visibility of point-cloud sections.
    /// meshList: list of meshes whose colors are updated according to projection
    /// </summary>
    public List <PointValue <byte> > ProjectToVisible(byte[] raster, Frustum viewField, int height, int width,
                                                      Occlusion oc, List <SurfacePoints> extras, List <bool> meshGuide,
                                                      float closest, float furthest, Vector3 curPos, Vector2 FOVReduction, bool proxConfig)
    {
        // reset metadata
        CheckedVertices     = 0;
        VerticesInView      = 0;
        NonOccludedVertices = 0;

        // gather visible vertices from all meshes
        List <CachedVertex> visible = AllInView(extras, meshGuide, viewField, oc);

        // project to visible
        return(Project(visible, viewField, raster, height, width, closest, furthest, curPos, FOVReduction, proxConfig));
    }
Пример #18
0
            public void Reset(int nCols, int nRows)
            {
                var oldColOverlaps = ColOverlaps;
                var oldRowOverlaps = RowOverlaps;
                var oldMasks       = Masks;
                var oldRects       = Rects;
                var oldOcclusions  = Occlusions;

                ColOverlaps = new float[nCols - 1];
                RowOverlaps = new float[nRows - 1];

                Gamma = 2.2f;

                Masks = new Mask[nCols * nRows];
                for (var i = 0; i < Masks.Length; i++)
                {
                    Masks[i] = new Mask(Vector2.zero, Vector2.one);
                }

                Rects = new float[4 * NUM_RECTS];

                Occlusions = new Occlusion[nCols * nRows];
                for (var i = 0; i < Occlusions.Length; i++)
                {
                    Occlusions[i] = new Occlusion();
                }

                if (oldColOverlaps != null)
                {
                    System.Array.Copy(oldColOverlaps, ColOverlaps, Mathf.Min(oldColOverlaps.Length, ColOverlaps.Length));
                }
                if (oldRowOverlaps != null)
                {
                    System.Array.Copy(oldRowOverlaps, RowOverlaps, Mathf.Min(oldRowOverlaps.Length, RowOverlaps.Length));
                }
                if (oldMasks != null)
                {
                    System.Array.Copy(oldMasks, Masks, Mathf.Min(oldMasks.Length, Masks.Length));
                }
                if (oldRects != null)
                {
                    System.Array.Copy(oldRects, Rects, Mathf.Min(oldRects.Length, Rects.Length));
                }
                if (oldOcclusions != null)
                {
                    System.Array.Copy(oldOcclusions, Occlusions, Mathf.Min(oldOcclusions.Length, Occlusions.Length));
                }
            }
Пример #19
0
 public void MarkOcclusion(Vector3 occlusionPos)
 {
     // 为 0 的时候取消标记,但必须保留一个,不然加载的时候出错
     if (_currentMarkCellWeight == 0 && _occlusionDictionary.Count > 1)
     {
         if (_occlusionDictionary.ContainsKey(occlusionPos.x.ToString() + '.' + occlusionPos.y.ToString()))
         {
             // 这里不一定 remove 也可以直接设置 weight 为 0
             _occlusionDictionary.Remove(occlusionPos.x.ToString() + '.' + occlusionPos.y.ToString());
         }
     }
     else
     {
         Occlusion occ = new Occlusion(GenerateMesh(), _currentMarkCellWeight);
         _occlusionDictionary[occlusionPos.x.ToString() + '.' + occlusionPos.y.ToString()] = occ;
     }
 }
Пример #20
0
 public virtual void Release()
 {
     if (Albedo != null)
     {
         Albedo.Release();
         Albedo = null;
     }
     if (Height != null)
     {
         Height.Release();
         Height = null;
     }
     if (Normal != null)
     {
         Normal.Release();
         Normal = null;
     }
     if (Metallic != null)
     {
         Metallic.Release();
         Metallic = null;
     }
     if (Roughness != null)
     {
         Roughness.Release();
         Roughness = null;
     }
     if (Occlusion != null)
     {
         Occlusion.Release();
         Occlusion = null;
     }
     if (Thickness != null)
     {
         Thickness.Release();
         Thickness = null;
     }
     if (Emission != null)
     {
         Emission.Release();
         Emission = null;
     }
 }
Пример #21
0
        private static void DisplayKeepStatus(BattleFrontKeep keep, Player plr)
        {
            plr.SendClientMessage($"Keep Status : {keep.KeepStatus}");
            plr.SendClientMessage($"Ram Deployed : {keep.RamDeployed}");
            plr.SendClientMessage($"Players killed in range : {keep.PlayersKilledInRange}");
            plr.SendClientMessage($"Players in range : {keep.PlayersInRange.Count}");
            foreach (var keepDoorRepairTimer in keep.DoorRepairTimers)
            {
                plr.SendClientMessage($"Door Repair Timer : {keepDoorRepairTimer.Key}:{keepDoorRepairTimer.Value.Value}/{keepDoorRepairTimer.Value.Length}");
            }

            foreach (var keepHardPoint in keep.HardPoints)
            {
                plr.SendClientMessage($"Siege : {keepHardPoint.CurrentWeapon} {keepHardPoint.SiegeType}");
            }
            keep.SendDiagnostic(plr);
            foreach (var door in keep.Doors)
            {
                plr.SendClientMessage($"DoorId : {door.Info.DoorId} Interact:{door.GameObject.InteractState} AutoAttack:{door.GameObject.CanAutoAttack}");
                plr.SendClientMessage("Occlusion_Visible:" + Occlusion.GetFixtureVisible(door.GameObject.DoorId));
            }
        }
Пример #22
0
        public string Occluded(Occlusion occlusion)
        {
            if (occlusion.eyeOccluded && occlusion.foreheadOccluded && occlusion.mouthOccluded)
            {
                return(" Also we have detected that eye, forehead and mouth are occluded.");
            }

            else if (occlusion.eyeOccluded && occlusion.foreheadOccluded && occlusion.mouthOccluded == false)
            {
                return(" Also we have detected that eyes and forehead are occluded.");
            }
            else if (occlusion.eyeOccluded && occlusion.foreheadOccluded == false && occlusion.mouthOccluded)
            {
                return(" Also we have detected that eyes and mouth are occluded.");
            }
            else if (occlusion.eyeOccluded == false && occlusion.foreheadOccluded && occlusion.mouthOccluded)
            {
                return(" Also we have detected that forehead and mouth are occluded.");
            }

            else if (occlusion.eyeOccluded && occlusion.foreheadOccluded == false && occlusion.mouthOccluded == false)
            {
                return(" Also we have detected that eyes are occluded.");
            }
            else if (occlusion.eyeOccluded == false && occlusion.foreheadOccluded && occlusion.mouthOccluded == false)
            {
                return(" Also we have detected that forehead is occluded.");
            }
            else if (occlusion.eyeOccluded == false && occlusion.foreheadOccluded == false && occlusion.mouthOccluded == false)
            {
                return(" Also we have detected that mouth is occluded.");
            }

            else
            {
                return("");
            }
        }
Пример #23
0
    /// <summary>
    /// Returns list of all points in viewField using oc for occlusion approximation.
    /// Will update occluded and notInView to lists of vertices in those categories.
    /// NOTE: clearing lists, resetting metadata must be done BEFORE calling method.
    /// </summary>
    public List <CachedVertex> AllInView(List <SurfacePoints> extras, List <bool> meshGuide, Frustum viewField, Occlusion oc)
    {
        for (int i = 0; i < extras.Count; i++)
        {
            // check visibility
            if (meshGuide[i])
            {
                for (int j = 0; j < extras[i].Wvertices.Count; j++)
                {
                    Vector3    pt   = extras[i].Wvertices[j];
                    Vector3    Pvec = Vector(viewField.Transform.position, pt);
                    ViewVector vv   = viewField.ViewVec(pt);

                    if (viewField.FOV.Contains(vv))
                    {
                        Vector2      coords = vv.Map <Occlusion.OcclusionCell>(oc.grid, viewField.FOV);
                        CachedVertex cv     = new CachedVertex(pt, i, j);

                        if (oc.grid[(int)coords.x, (int)coords.y].nullCell ||
                            Pvec.magnitude < oc.grid[(int)coords.x, (int)coords.y].distance)
                        {
                            oc.grid[(int)coords.x, (int)coords.y].closest  = cv;
                            oc.grid[(int)coords.x, (int)coords.y].distance = Pvec.magnitude;
                            oc.grid[(int)coords.x, (int)coords.y].nullCell = false;
                            NonOccludedVertices++;
                        }
                        VerticesInView++;
                    }
                    CheckedVertices++;
                }
            }
        }
        return(oc.Points());
    }
Пример #24
0
    /// <summary>
    /// Takes in raster, frustum and projects values onto point cloud. Returns list of point-values.
    /// oc: specs for occlusion approximation of point-cloud.
    /// extras: list containing point-clouds.
    /// meshGuide: guide to visibility of point-cloud sections.
    /// meshList: list of meshes whose colors are updated according to projection
    /// </summary>
    public List <PointValue <byte> > ProjectToVisible(byte[,] raster, Frustum viewField, Occlusion oc,
                                                      List <SurfacePoints> extras, List <bool> meshGuide)
    {
        // reset metadata
        CheckedVertices     = 0;
        VerticesInView      = 0;
        NonOccludedVertices = 0;

        // gather visible vertices from all meshes
        List <CachedVertex> visible = AllInView(extras, meshGuide, viewField, oc);

        // project to visible
        return(Project(visible, viewField, raster));
    }
Пример #25
0
        /// <summary>
        /// Opens door inside instance (uniqueID, instanceID, open=1/close=0)
        /// </summary>
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// <returns>True if command was correctly handled, false if operation was canceled</returns>
        public static bool InstanceOpenDoor(Player plr, ref List <string> values)
        {
            int uniqueID   = 0;
            int instanceId = 0;
            int open       = 1;

            if (values.Count >= 2)
            {
                int.TryParse(values[0], out uniqueID);
                int.TryParse(values[1], out instanceId);

                if (values.Count >= 3)
                {
                    int.TryParse(values[2], out open);
                }

                var Out = new PacketOut((byte)Opcodes.F_CREATE_STATIC);

                if (open == 0)
                {
                    Occlusion.SetFixtureVisible((uint)uniqueID, true);
                    Out.WritePacketString(@"|17 55 00 00 08 00 38 49 00 16 09 4B 00 |.<q.U....8I...K.|
                                        |0C B7 6C FF FF 1E 02 00 01 67 2E 00 00 06 00 00 |..l......g......|
                                        |00 00 52 BF 67 55 BB 00 00 00 00 0E 47 61 74 65 |..R.gU......Gate|
                                        |68 6F 75 73 65 20 44 6F 6F 72 04   |............... |");
                }
                else
                {
                    Occlusion.SetFixtureVisible((uint)uniqueID, false);
                    Out.WritePacketString(@"|17 55 00 01 08 00 38 49 00 16 09 4B 00 |.<q.U....8I...K.|
                                        |0C B7 6C FF FF 1E 02 00 01 67 2E 00 00 06 00 00 |..l......g......|
                                        |00 00 52 BF 67 55 BB 00 00 00 00 0E 47 61 74 65 |..R.gU......Gate|
                                        |68 6F 75 73 65 20 44 6F 6F 72 04   |............... |");
                }



                uint result = (uint)
                              (
                    (int)((uniqueID & 0xC000) << 16) |
                    (int)((plr.Zone.ZoneId & 0x3FF) << 20) |
                    (int)((uniqueID & 0x3FFF) << 6) |
                    (int)(0x28 + instanceId)
                              );

                Out.WriteUInt32(result);

                plr.DispatchPacket(Out, true);

                plr.SendClientMessage("DoorID=" + result);

                return(true);
            }
            return(false);
            //this does not correct, wont work for uniqueId above 16k, 2 high orrder bits neeed to go before zoneId

            //InstanceDoor door = null;

            //var objID = GetInt(ref values);
            //if (objID != 0 && plr.Region.GetObject((ushort)objID) is InstanceDoor)
            //{
            //    door = plr.Region.GetObject((ushort)objID) as InstanceDoor;
            //}
            //else
            //door = plr.GetInRange<InstanceDoor>(100).FirstOrDefault();

            //var t = plr.GetInRange<InstanceObject>(100);

            //if (door != null)
            //{
            //    door.IsOpen = !door.IsOpen;
            //}
            //return true;
        }
Пример #26
0
        static void Main(string[] args)
        {
            var q  = new Quaternion(new EulerAngle(Constants.PI / 6, Constants.PI / 12, 0));
            var ps = new List <List <Point3> >
            {
                new List <Point3>
                {
                    new Point3(0, 0, 0), new Point3(0, 0, 100)
                },
                new List <Point3>
                {
                    new Point3(0, 0, 100), new Point3(100, 0, 100)
                },
                new List <Point3>
                {
                    new Point3(100, 0, 100), new Point3(100, 0, 0)
                },
                new List <Point3>
                {
                    new Point3(100, 0, 0), new Point3(0, 0, 0)
                }
            };
            var plane = new FlatPlane(ps);
            var prism = new Prism(plane, new Vector3(0, 0, 0), new Vector3(0, 100, 0));

            prism = prism.Rotate(q);
            //var segs = Occlusion.Occlude(new List<Prism> { prism });

            var ps2 = new List <List <Point3> >
            {
                new List <Point3>
                {
                    new Point3(100.000000, 0, 150.000000),
                    new Point3(96.077045, 0, 149.845867),
                    new Point3(92.178277, 0, 149.384417),
                    new Point3(88.327732, 0, 148.618496),
                    new Point3(84.549150, 0, 147.552826),
                    new Point3(80.865828, 0, 146.193977),
                    new Point3(77.300475, 0, 144.550326),
                    new Point3(73.875072, 0, 142.632008),
                    new Point3(70.610737, 0, 140.450850),
                    new Point3(67.527598, 0, 138.020298),
                    new Point3(64.644661, 0, 135.355339),
                    new Point3(61.979702, 0, 132.472402),
                    new Point3(59.549150, 0, 129.389263),
                    new Point3(57.367992, 0, 126.124928),
                    new Point3(55.449674, 0, 122.699525),
                    new Point3(53.806023, 0, 119.134172),
                    new Point3(52.447174, 0, 115.450850),
                    new Point3(51.381504, 0, 111.672268),
                    new Point3(50.615583, 0, 107.821723),
                    new Point3(50.154133, 0, 103.922955),
                    new Point3(50.000000, 0, 100.000000),
                },
                new List <Point3>
                {
                    new Point3(50, 0, 100), new Point3(100, 0, 100),
                },
                new List <Point3>
                {
                    new Point3(100, 0, 100), new Point3(100, 0, 150)
                }
            };
            var plane2 = new FlatPlane(ps2);
            var prism2 = new Prism(plane2, new Vector3(0, 0, 0), new Vector3(0, 50, 0));

            prism2 = prism2.Rotate(q);
            var segs = Occlusion.Occlude(new List <Prism> {
                prism, prism2
            });

            var image = new Bitmap(600, 600);

            using (var g = Graphics.FromImage(image))
            {
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.Clear(Color.Lavender);
                Color[] colors =
                { Color.Black, Color.Blue, Color.Aqua, Color.Brown, Color.Chartreuse, Color.Chocolate, Color.DarkGreen, };
                var i = 0;
                foreach (var ds in segs)
                {
                    var pen = new Pen(colors[(i++ % colors.Length)], 2);
                    g.DrawLine(pen, new PointF((float)ds.P1.X + 300, -(float)ds.P1.Y + 300), new PointF((float)ds.P2.X + 300, -(float)ds.P2.Y + 300));
                }
                g.Save();
            }
            image.Save("test.bmp");
        }
Пример #27
0
    /// <summary>
    /// Takes in raster, frustum and projects values onto point cloud. Returns list of point-values.
    /// oc: specs for occlusion approximation of point-cloud.
    /// extras: list containing point-clouds.
    /// meshGuide: guide to visibility of point-cloud sections.
    /// meshList: list of meshes whose colors are updated according to projection
    /// </summary>
    public List <PointValue <byte> > ProjectToVisible(byte[,] raster, Frustum viewField, Occlusion oc,
                                                      List <SurfacePoints> extras, List <bool> meshGuide, ReadOnlyCollection <SpatialMappingSource.SurfaceObject> meshList,
                                                      Color32 color1, Color32 color2, Color32 defaultColor, byte value1, byte value2)
    {
        // reset metadata
        CheckedVertices     = 0;
        VerticesInView      = 0;
        NonOccludedVertices = 0;

        // gather visible vertices from all meshes
        List <CachedVertex> visible = AllInView(extras, meshGuide, viewField, oc);

        // project to visible
        return(Project(visible, viewField, raster, meshList, color1, color2, defaultColor, value1, value2));
    }
Пример #28
0
 public virtual void Release()
 {
     if (UI3DPreview.Instance != null)
     {
         var prev = UI3DPreview.Instance;
         if (Albedo != null && Albedo != prev.defaultBlack && Albedo != prev.defaultDarkGray && Albedo != prev.defaultGray && Albedo != prev.defaultWhite)
         {
             Albedo.Release();
             Albedo = null;
         }
         if (Height != null && Height != prev.defaultBlack && Height != prev.defaultDarkGray && Height != prev.defaultGray && Height != prev.defaultWhite)
         {
             Height.Release();
             Height = null;
         }
         if (Normal != null && Normal != prev.defaultBlack && Normal != prev.defaultDarkGray && Normal != prev.defaultGray && Normal != prev.defaultWhite)
         {
             Normal.Release();
             Normal = null;
         }
         if (Metallic != null && Metallic != prev.defaultBlack && Metallic != prev.defaultDarkGray && Metallic != prev.defaultGray && Metallic != prev.defaultWhite)
         {
             Metallic.Release();
             Metallic = null;
         }
         if (Roughness != null && Roughness != prev.defaultBlack && Roughness != prev.defaultDarkGray && Roughness != prev.defaultGray && Roughness != prev.defaultWhite)
         {
             Roughness.Release();
             Roughness = null;
         }
         if (Occlusion != null && Occlusion != prev.defaultBlack && Occlusion != prev.defaultDarkGray && Occlusion != prev.defaultGray && Occlusion != prev.defaultWhite)
         {
             Occlusion.Release();
             Occlusion = null;
         }
     }
     else
     {
         if (Albedo != null)
         {
             Albedo.Release();
             Albedo = null;
         }
         if (Height != null)
         {
             Height.Release();
             Height = null;
         }
         if (Normal != null)
         {
             Normal.Release();
             Normal = null;
         }
         if (Metallic != null)
         {
             Metallic.Release();
             Metallic = null;
         }
         if (Roughness != null)
         {
             Roughness.Release();
             Roughness = null;
         }
         if (Occlusion != null)
         {
             Occlusion.Release();
             Occlusion = null;
         }
     }
 }
Пример #29
0
        public override void ImportFromUsd()
        {
            Material mat = Material;

            if (DiffuseMap)
            {
                Debug.Log("here");
                mat.SetTexture("_BaseColorMap", DiffuseMap);
                mat.SetColor("_BaseColor", Color.white);
            }
            else
            {
                mat.SetColor("_BaseColor", Diffuse.GetValueOrDefault(mat.color));
            }

            // TODO: What about opacity map?

            if (!IsSpecularWorkflow)
            {
                // Robustness: It would be ideal if this parameter were provided by HDRP, however that
                // would require this asset package having a dependency on the HDRP package itself,
                // which is (yet) not desirable.
                mat.SetFloat("_MaterialID", /*Standard Metallic*/ 1);
            }
            else
            {
                mat.SetFloat("_MaterialID", /*Spec Color*/ 4);
                mat.EnableKeyword("_MATERIAL_FEATURE_SPECULAR_COLOR");
                mat.EnableKeyword("_SPECULARCOLORMAP");
            }

            // R=Metallic, G=Occlusion, B=Displacement, A=Roughness(Smoothness)
            var MaskMap = BuildMaskMap(!IsSpecularWorkflow ? MetallicMap : null, OcclusionMap, DisplacementMap, RoughnessMap);

            if (MaskMap)
            {
                mat.SetTexture("_MaskMap", MaskMap);
                mat.EnableKeyword("_MASKMAP");
            }

            if (!IsSpecularWorkflow)
            {
                if (!MetallicMap)
                {
                    mat.SetFloat("_Metallic", Metallic.GetValueOrDefault());
                }
            }
            else
            {
                if (SpecularMap)
                {
                    mat.SetTexture("_SpecularColorMap", SpecularMap);
                }
                else
                {
                    mat.SetColor("_SpecularColor", Specular.GetValueOrDefault());
                }
            }

            if (!RoughnessMap)
            {
                var smoothness = 1 - Roughness.GetValueOrDefault();
                mat.SetFloat("_Smoothness", smoothness);
                // HDRP Lit does not seem to respect smoothness, so just clamp to the correct value.
                mat.SetFloat("_SmoothnessRemapMin", smoothness);
                mat.SetFloat("_SmoothnessRemapMax", smoothness);
            }

            if (!OcclusionMap)
            {
                mat.SetFloat("_AORemapMin", Occlusion.GetValueOrDefault());
                mat.SetFloat("_AORemapMax", Occlusion.GetValueOrDefault());
            }

            // Single displacement scalar value not supported.

            if (ClearcoatMap)
            {
                mat.SetTexture("_CoatMaskMap", ClearcoatMap);
                mat.EnableKeyword("_MATERIAL_FEATURE_CLEAR_COAT");
            }
            mat.SetFloat("_CoatMask", ClearcoatRoughness.GetValueOrDefault());

            if (NormalMap)
            {
                mat.SetTexture("_NormalMap", NormalMap);
                mat.EnableKeyword("_NORMALMAP");
            }

            if (EmissionMap)
            {
                mat.SetTexture("_EmissionMap", EmissionMap);
                mat.EnableKeyword("_EMISSIVE_COLOR_MAP");
            }
            else
            {
                mat.SetColor("_EmissionColor", Emission.GetValueOrDefault());
            }
        }