private void SetCamera()
        {
            Camera3DObject o = (Camera3DObject)MyCamera.get();

            if (o != null)
            {
                DrawCamera = o.MyCamera;
                DrawCamera.SetSize(WindowSize);
            }
        }
示例#2
0
 public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
 {
     if (ParentLevel.LevelForEditing)
     {
         PointEffect.SetFromCamera(camera);
         PointEffect.SetFromObject(this);
         Render.DrawModel(PointModel, PointEffect.MyEffect);
         base.Draw3D(camera, DrawTag);
     }
 }
示例#3
0
 public static void DrawModel(Model model, EffectValue effect, Camera3D camera, Basic3DObject obj)
 {
     if (model != null && effect.get() != null)
     {
         _3DEffect effect3D = (_3DEffect)effect.Holder;
         effect3D.SetFromObject(obj);
         effect3D.SetFromCamera(camera);
         DrawModel(model, effect3D.MyEffect);
     }
 }
 public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
 {
     if (EditorSelected)
     {
         RingEffect.SetFromCamera(camera);
         RingEffect.SetFromObject(this);;
         Render.DrawModel(RingModel, RingEffect.MyEffect);
         base.Draw3D(camera, DrawTag);
     }
 }
示例#5
0
        public static void Draw(Camera3D DrawCamera)
        {
            foreach (int i in DrawIdList)
            {
                DrawItems[i].DrawInstanced(SortedChildren[i], DrawCamera);
            }

            WallInstancer.Draw(DrawCamera);

            bulletInstancer.DrawInstanced(DrawCamera);
        }
示例#6
0
 public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
 {
     Game1.graphicsDevice.BlendState        = Additive.get() ? BlendState.Additive : BlendState.Opaque;
     Game1.graphicsDevice.DepthStencilState = DepthRead.get() ? DepthStencilState.DepthRead : DepthStencilState.Default;
     if (!Applied)
     {
         Applied = true;
         ApplyEffects();
     }
     base.Draw3D(camera, DrawTag);
 }
示例#7
0
 public void SetUV(Camera3D camera)
 {
     if (UVOffset != null)
     {
         UVOffset.SetValue(camera.Offset);
     }
     if (UVMult != null)
     {
         UVMult.SetValue(camera.Mult);
     }
 }
 public void SetCamera(Camera3D camera, Vector2 WindowSize)
 {
     Render.ViewWidth  = MyView.Width;
     Render.ViewHeight = MyView.Height;
     if (camera != null)
     {
         camera.SetSize(new Vector2(MyView.Width, MyView.Height));
         camera.SetMult(UVMult);
         //camera.SetOffset((WindowSize / 2 - (new Vector2(MyView.X, MyView.Y) + new Vector2(MyView.Width, MyView.Height) / 2)) * UVOffsetMult / WindowSize);
         camera.SetOffset(UVOffset);
     }
 }
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (!Sphere.get())
            {
                ShapeRenderer.DrawCube(WorldMatrix, camera, drawColor);
            }
            else
            {
                ShapeRenderer.DrawSphere(WorldMatrix, camera, drawColor);
            }

            base.Draw3D(camera, DrawTag);
        }
示例#10
0
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (ColorParameter != null)
            {
                ColorParameter.SetValue(OldColor * FlickerMult);
            }
            if (SpecularParameter != null)
            {
                SpecularParameter.SetValue(OldSpecular * FlickerMult);
            }

            base.Draw3D(camera, DrawTag);
        }
示例#11
0
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (lightState == BasicLight.LightState.Dead || MyEffect.get() != null)
            {
                base.Draw3D(camera, DrawTag);
                return;
            }

            MyEffect.get().CurrentTechnique.Passes[0].Apply();
            FullscreenQuad.Draw();

            base.Draw3D(camera, DrawTag);
        }
示例#12
0
        public void Draw3D(Camera3D camera)
        {
            Camera3DObject c = (Camera3DObject)ParentScene.MyCamera.get();

            if (c != null)
            {
                Vector3 Result  = Vector3.Zero;
                bool    Success = false;
                Basic3DObject.GetAveragePosition(ParentScene.SelectedGameObjects, ref Result, ref Success);

                WorldMatrix = c.ScaleMatrix * Matrix.CreateTranslation(Result);
                ColorEffectHolder.SetWorld(WorldMatrix);
                ColorEffectHolder.SetFromCamera(camera);

                foreach (EffectPass pass in ColorEffectHolder.MyEffect.CurrentTechnique.Passes)
                {
                    pass.Apply();


                    Game1.graphics.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>(
                        PrimitiveType.LineList,
                        PointList,
                        0,             // vertex buffer offset to add to each element of the index buffer
                        PointCount,    // number of vertices in pointList
                        Indicies,      // the index buffer
                        0,             // first index element to read
                        PointCount / 2 // number of primitives to draw
                        );
                }


                ColorSetEffectHolder.Collection["Color"].SetValue(Color.LightGray.ToVector4());
                ColorSetEffectHolder.SetFromCamera(camera);
                ColorSetEffectHolder.SetWorld(WorldMatrix);
                Render.DrawModel(CubeModel, ColorSetEffectHolder.MyEffect);
                Vector3 ScreenPos = WorldViewer.self.MyViewport.Project(Vector3.Zero, camera.ProjectionMatrix, camera.ViewMatrix, WorldMatrix);
                ScreenPositions[3] = new Vector2(ScreenPos.X, ScreenPos.Y);


                Model EndModel = controlMode == ControlMode.Move ? ArrowModel :
                                 controlMode == ControlMode.Rotate ? BallModel : CubeModel;
                for (int i = 0; i < 3; i++)
                {
                    ColorSetEffectHolder.Collection["Color"].SetValue(PointColors[i].ToVector4());
                    ColorSetEffectHolder.SetWorld(ModelMatricies[i] * WorldMatrix);
                    Render.DrawModel(EndModel, ColorSetEffectHolder.MyEffect);
                    ScreenPos          = WorldViewer.self.MyViewport.Project(Vector3.Zero, camera.ProjectionMatrix, camera.ViewMatrix, ModelMatricies[i] * WorldMatrix);
                    ScreenPositions[i] = new Vector2(ScreenPos.X, ScreenPos.Y);
                }
            }
        }
示例#13
0
        private void DMakeLightMap()
        {
            Game1.graphicsDevice.SetRenderTargets(null);
            Game1.graphicsDevice.SetRenderTarget(LightMap);
            Game1.graphicsDevice.Clear(Color.Transparent);
            Game1.graphicsDevice.BlendState        = LightMapBS;
            Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;


            Game1.graphicsDevice.Textures[0]      = GBufferTargets[0].RenderTarget;
            Game1.graphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;

            Game1.graphicsDevice.SamplerStates[1] = SamplerState.PointWrap;
            Game1.graphicsDevice.Textures[1]      = GBufferTargets[1].RenderTarget;

            MasterManager.SetViewportToFullscreen();

            foreach (GameObject g in OverLightingChildren)
            {
                g.Draw3D(DrawCamera, GameObjectTag._3DDeferredOverLighting);
            }

#if EDITOR && WINDOWS
            if (ParentLevel.LevelForEditing && DrawCamera != null)
            {
                DrawCamera.MakeInverse();
                foreach (GameObject g in WorldLightingChildren)
                {
                    g.Draw3D(DrawCamera, GameObjectTag._3DDeferredOverLighting);
                }
            }
            else
#endif
            {
                int      i             = 0;
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Render.ViewIndex = i++;
                    s.getSceneView().Set();
                    currentCamera = s.getCamera();

                    currentCamera.MakeInverse();
                    foreach (GameObject g in WorldLightingChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DDeferredOverLighting);
                    }
                }
            }
        }
        public override void DrawSingle(Vector3 Position, float Size, Vector4 Color, Camera3D DrawCamera)
        {
            WorldParam.SetValue(ModelTransformMatrix * Matrix.CreateScale(Size) * Matrix.CreateTranslation(Position));
            ViewParam.SetValue(DrawCamera.ViewMatrix);
            ProjectionParam.SetValue(DrawCamera.ProjectionMatrix);
            ViewPosParam.SetValue(DrawCamera.Position);
            ColorParameter.SetValue(Color);
            ShipEffect.CurrentTechnique = ForwardTechnique;

            Render.DrawModel(ShipModel, ShipEffect);

            ColorParameter.SetValue(DrawColor * ColorMult);
            WorldParam.SetValue(ModelTransformMatrix);
        }
示例#15
0
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (MyModel.get() != null && MyEffect.get() != null)
            {
                Game1.graphicsDevice.BlendState = BlendState.AlphaBlend;
                _3DEffect effect3D = (_3DEffect)MyEffect.Holder;

                effect3D.SetFromObject(this);
                effect3D.SetFromCamera(camera);

                Render.DrawModel(MyModel.get(), MyEffect.get());
            }
            base.Draw3D(camera, DrawTag);
        }
        public void Draw(Camera3D DrawCamera)
        {
            foreach (UIParticleBasic part in Particles)
            {
                part.Draw();
            }

            WaveManager.Draw(ParentShip.getSceneView());

            foreach (HudBox b in HudBoxes)
            {
                b.PreDraw();
            }
        }
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (lightState == BasicLight.LightState.Dead)
            {
                base.Draw3D(camera, DrawTag);
                return;
            }

            if (DrawTag == GameObjectTag._3DPreDraw)
            {
                if (RealtimeShadows.get())
                {
                    DrawShadows();
                }
            }
            else
            {
#if EDITOR && WINDOWS
                if (DrawTag == GameObjectTag._3DForward)
                {
                    if (EditorSelected)
                    {
                        Vector4 Col = Vector4.One;
                        ShapeRenderer.DrawSphere(WorldMatrix, camera, Col);
                    }
                    if (ShadowCube != null)
                    {
                        ShapeRenderer.DrawSphere(WorldMatrix, camera, ShadowCube.Value);
                    }
                }
                else
#endif
                if (MyEffect.Holder != null)
                {
                    Game1.graphicsDevice.RasterizerState = RasterizerState.CullClockwise;
                    DeferredLightEffect effect3D = (DeferredLightEffect)MyEffect.Holder;

                    effect3D.SetTextureSize(ParentScene.WindowSize);
                    effect3D.SetUV(camera);
                    effect3D.SetInverseCamera(camera);
                    effect3D.SetLight(Position.get(), Scale.get() / 2);
                    effect3D.SetFromObject(this);
                    effect3D.SetFromCamera(camera);
                    effect3D.MyEffect.CurrentTechnique.Passes[0].Apply();
                    Render.DrawModel(SphereModel, MyEffect.get());
                }
            }
            base.Draw3D(camera, DrawTag);
        }
        public static void PreDraw(Camera3D camera)
        {
            if (!Ready)
            {
                ringSystem.ReadyDraw();
                foreach (BasicParticleSystem r in ParticleSystems)
                {
                    r.Ready();
                }

                Ready = true;
            }

            ringSystem.Draw(camera);
        }
 public void SetFromCamera(Camera3D camera)
 {
     if (View != null)
     {
         View.SetValue(camera.ViewMatrix);
     }
     if (Projection != null)
     {
         Projection.SetValue(camera.ProjectionMatrix);
     }
     if (CameraPosition != null)
     {
         CameraPosition.SetValue(camera.Position);
     }
 }
示例#20
0
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            Lit3DEffect effect3D = (Lit3DEffect)effect.Holder;

            if (effect3D != null)
            {
                effect3D.SetForwardTechnique();
                effect3D.SetAmbientLight(AmbientLightColor.get());
                effect3D.SetLightOne(LightOneColor.get(), Vector3.Normalize(LightOneDirection.get()));
                effect3D.SetLightTwo(LightTwoColor.get(), Vector3.Normalize(LightTwoDirection.get()));

                Render.DrawModel(model, effect, camera, this);
            }
            base.Draw3D(camera, DrawTag);
        }
        public override void Create()
        {
            CameraSpeed    = new FloatValue("Camera Speed", 0.1f);
            CameraDistance = new FloatValue("Camera Distance", 100);

            AddTag(GameObjectTag.Update);
            AddTag(GameObjectTag.WorldViewer);
            MyCamera = new Camera3D(MathHelper.PiOver4, 0.1f, 1000000);

            TimeSpeed = new FloatValue("TimeSpeed", 1);

            WorldCameraInterpolation = 1;
            MyPoint = new PolorPoint();

            base.Create();
        }
 private void CreateCameras()
 {
     if (ShadowCameras == null)
     {
         ShadowCameras = new Camera3D[6];
         for (int i = 0; i < 6; i++)
         {
             ShadowCameras[i] = new Camera3D(90 * 3.14159265f / 180, 0.1f, 50000, new Vector2(512));
         }
     }
     ShadowCameras[0].SetLookAt(Position.get(), Position.get() + new Vector3(1000, 0, 0), Vector3.Up);
     ShadowCameras[1].SetLookAt(Position.get(), Position.get() + new Vector3(-1000, 0, 0), Vector3.Up);
     ShadowCameras[2].SetLookAt(Position.get(), Position.get() + new Vector3(0, 1000, 0), Vector3.Forward);
     ShadowCameras[3].SetLookAt(Position.get(), Position.get() + new Vector3(0, -1000, 0), Vector3.Backward);
     ShadowCameras[4].SetLookAt(Position.get(), Position.get() + new Vector3(0, 0, 1000), Vector3.Up);
     ShadowCameras[5].SetLookAt(Position.get(), Position.get() + new Vector3(0, 0, -1000), Vector3.Up);
 }
示例#23
0
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (lightState == BasicLight.LightState.Dead || MyEffect.Holder != null)
            {
                base.Draw3D(camera, DrawTag);
                return;
            }

            DeferredLightEffect effect3D = (DeferredLightEffect)MyEffect.Holder;

            effect3D.SetTextureSize(ParentScene.WindowSize);
            effect3D.SetInverseCamera(camera);
            effect3D.MyEffect.CurrentTechnique.Passes[0].Apply();
            FullscreenQuad.Draw();

            base.Draw3D(camera, DrawTag);
        }
        public override void Create()
        {
            ModelCount             = new IntValue("Model Count");
            ModelCount.ChangeEvent = ModelCountChange;

            LineFlares   = new IntValue("Line Flares", 100);
            RandomFlares = new IntValue("Random Flare", 100);
            MaxItemTime  = new IntValue("Item Time", 10000);

            CameraSpeed = new FloatValue("Camera Speed", 0.1f);
            AddTag(GameObjectTag.Update);
            AddTag(GameObjectTag.WorldViewer);
            MyCamera = new Camera3D(MathHelper.PiOver4, 0.1f, 1000000);

            WorldCameraInterpolation = 1;

            base.Create();
        }
示例#25
0
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            if (MyModel.get() != null && MyEffect.get() != null)
            {
                Deferred3DEffect effect3D = (Deferred3DEffect)MyEffect.Holder;
                switch (DrawTag)
                {
                case GameObjectTag._3DDeferredGBuffer:
                {
                    effect3D.SetWorldViewIT(camera, this);
                    effect3D.SetFromObject(this);
                    effect3D.SetFromCamera(camera);
                    effect3D.SetDeferredTechnique();
                    break;
                }

                case GameObjectTag._3DShadow:
                {
                    effect3D.SetFromObject(this);
                    effect3D.SetFromCamera(camera);
                    effect3D.SetShadowTechnique();
                    effect3D.SetLight(Transfer.LightPosition, Transfer.LightDistance);
                    break;
                }

                default:
                {
                    effect3D.SetFromCamera(camera);
                    effect3D.SetUV(camera);

                    if (!UseDeferred.get())
                    {
                        effect3D.SetFromObject(this);
                    }

                    effect3D.SetForwardTechnique();
                    break;
                }
                }

                Render.DrawModel(MyModel.get(), MyEffect.get());
            }
            base.Draw3D(camera, DrawTag);
        }
 public void SetInverseCamera(Camera3D camera)
 {
     if (InverseView != null)
     {
         InverseView.SetValue(camera.InverseView);
     }
     if (InverseViewProjection != null)
     {
         InverseViewProjection.SetValue(camera.InverseViewProjection);
     }
     if (CameraPosition != null)
     {
         CameraPosition.SetValue(camera.Position);
     }
     if (ViewProjection != null)
     {
         ViewProjection.SetValue(camera.ViewMatrix * camera.ProjectionMatrix);
     }
 }
示例#27
0
        public void Draw(Camera3D DrawCamera, int CurrentTime)
        {
            float AlphaMult = 1 - (CurrentTime - StartingTime) / (float)TextParticleSystem.ParticleLifeTime;

            Vector3 Position3 = Game1.graphicsDevice.Viewport.Project(Position, DrawCamera.ProjectionMatrix, DrawCamera.ViewMatrix, Matrix.Identity);
            Vector2 Position2 = new Vector2(Position3.X, Position3.Y) - Render.CurrentView.Position;

            Position2.X -= TextOffset;
            Position2.Y -= (1 - AlphaMult) * TextParticleSystem.ParticleMoveAmount - TextParticleSystem.ParticleYOffset;

            //Render.DrawOutlineRect(Position2 + ULBox, Position2 + LRBox, 1, Col);

            if (Icon != null)
            {
                Game1.spriteBatch.Draw(Icon, Position2 + IconOffset, Color.White * AlphaMult);
            }

            Render.DrawShadowedText(TextParticleSystem.TextParticleFont, Text, Position2, Vector2.One,
                                    color * AlphaMult, Color.Black * AlphaMult);
        }
        public override void Draw3D(Camera3D camera, GameObjectTag DrawTag)
        {
            ColorEffectHolder.SetFromObject(this);
            ColorEffectHolder.SetFromCamera(camera);

            foreach (EffectPass pass in ColorEffectHolder.MyEffect.CurrentTechnique.Passes)
            {
                pass.Apply();


                Game1.graphics.GraphicsDevice.DrawUserIndexedPrimitives <VertexPositionColor>(
                    PrimitiveType.LineList,
                    PointList,
                    0,             // vertex buffer offset to add to each element of the index buffer
                    PointCount,    // number of vertices in pointList
                    Indicies,      // the index buffer
                    0,             // first index element to read
                    PointCount / 2 // number of primitives to draw
                    );
            }
        }
        public override void PreDraw()
        {
            Game1.graphicsDevice.SetRenderTarget(FinalTarget);
            Game1.graphicsDevice.Clear(Color.Black);

#if EDITOR && WINDOWS
            if (!ParentLevel.LevelForEditing)
#endif
            {
                Camera3D currentCamera = null;

                foreach (WorldViewer3D s in WorldViewerChildren)
                {
                    Game1.graphicsDevice.BlendState        = BlendState.Opaque;
                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;
                    Render.CurrentWorldViewer3D            = s;

                    s.getSceneView().Set();
                    Render.CurrentView          = s.getSceneView();
                    currentCamera               = s.getCamera();
                    StarshipScene.CurrentCamera = currentCamera;

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.Default;
                    Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;

                    foreach (GameObject g in ForwardChildren)
                    {
                        g.Draw3D(currentCamera, GameObjectTag._3DForward);
                    }

                    ParticleManager.PreDraw(currentCamera);
                    ParticleManager.Draw(currentCamera);

                    Game1.graphicsDevice.DepthStencilState = DepthStencilState.None;
                    Game1.graphicsDevice.BlendState        = BlendState.AlphaBlend;
                }

                MasterManager.SetViewportToFullscreen();
            }
        }
        public static void Draw(Camera3D DrawCamera)
        {
            if (FirstParticle > LastParticle)
            {
                for (int i = LastParticle; i < FirstParticle; i++)
                {
                    ParticleArray[i].Draw(DrawCamera, CurrentTime);
                }
            }
            else if (FirstParticle < LastParticle)
            {
                for (int i = LastParticle; i < ParticleCount; i++)
                {
                    ParticleArray[i].Draw(DrawCamera, CurrentTime);
                }

                for (int i = 0; i < FirstParticle; i++)
                {
                    ParticleArray[i].Draw(DrawCamera, CurrentTime);
                }
            }
        }