Exemple #1
0
 public MosaicRenderer(Game game)
 {
     this.game       = game;
     renderer        = game.Renderer;
     camera          = renderer.Camera;
     renderToTexture = new RenderToTexture(renderer.GraphicsDevice);
 }
Exemple #2
0
        public BoneSelector(Game game)
        {
            this.game           = game;
            this.graphicsDevice = game.GraphicsDevice;
            this.camera         = game.Camera;

            basicEffect       = new BasicEffect(graphicsDevice, null);
            vertexDeclaration = new VertexDeclaration(graphicsDevice, VertexPositionColor.VertexElements);
            viewMatrix        = Matrix.CreateLookAt(Vector3.UnitZ, Vector3.Zero, Vector3.Up);

            camera.CameraEvent += HandleCameraEvent;
            HandleWindowSizeChanged(graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height);

            spriteBatch = new SpriteBatch(game.GraphicsDevice);

            try {
                font = game.Content.Load <SpriteFont>("BoneSelectorFont");
            }
            catch (Exception ex) {
                string currDir    = Directory.GetCurrentDirectory();
                string contentDir = currDir + @"\Content";
                string fontFile   = contentDir + @"\BoneSelectorFont.spritefont";
                MessageBox.Show(ex.Message + "\n\n" +
                                "Current directory: " + currDir + "\n" +
                                "folder \"Content\": " + (Directory.Exists(contentDir) ? "FOUND" : "NOT FOUND") + "\n" +
                                "file \"Content\\BoneSelectorFont.spritefont\": " + (File.Exists(fontFile) ? "FOUND" : "NOT FOUND"),
                                "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
            }
        }
Exemple #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            CheckContentDirectory();

            textureManager = new TextureManager(this);

            camera = new CameraTurnTable(this.GraphicsDevice, this.Window);
            ResetCamera(camera);

            ModelLoader modelLoader = new ModelLoader(this);

            boneSelector = new BoneSelector(this);

            ResetLights();

            ForceShadersV3 = LightingParamsDialog.DefaultForceShadersV3;

            ResetPostProcessParams();

            renderer = new Renderer(this);
            renderer.Init();

            hud = new HUD(this);

            controlGUI = new ControlGUI(this);
            if (splash == null)
            {
                controlGUI.TopMost = controlGUI.PreferredAlwaysOnTop;
            }
            controlGUI.Show();
        }
Exemple #4
0
 public void ResetCamera(CameraTurnTable camera)
 {
     camera.SetClippingPlanes(0.05f, 150.0f);
     camera.FieldOfViewHorizontal = MathHelper.ToRadians(CameraParamsDialog.DefaultCameraFOV);
     camera.Target   = CameraParamsDialog.DefaultCameraTarget;
     camera.Distance = CameraParamsDialog.DefaultCameraDistance;
     camera.SetRotation(MathHelper.ToRadians(CameraParamsDialog.DefaultCameraRotationHoriz), MathHelper.ToRadians(CameraParamsDialog.DefaultCameraRotationVert));
 }
        private void LoadCamera(BinaryReader file, ushort versionMajor, ushort versionMinor, bool loadCamera)
        {
            float   cameraFov    = file.ReadSingle();
            Vector3 cameraTarget = new Vector3();

            cameraTarget.X = file.ReadSingle();
            cameraTarget.Y = file.ReadSingle();
            cameraTarget.Z = file.ReadSingle();
            float cameraDistance      = file.ReadSingle();
            float cameraRotationHoriz = file.ReadSingle();
            float cameraRotationVert  = file.ReadSingle();

            if (loadCamera)
            {
                CameraTurnTable camera = game.Camera;
                camera.FieldOfViewHorizontal = cameraFov;
                camera.Target   = cameraTarget;
                camera.Distance = cameraDistance;
                camera.SetRotation(cameraRotationHoriz, cameraRotationVert);
            }
        }
        private void SaveScene(string filename)
        {
            BinaryWriter file;

            try {
                file = new BinaryWriter(new FileStream(filename, FileMode.Create));
            }
            catch (Exception) {
                MessageBox.Show(this, "Could not save scene.",
                                "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // file format version
            file.Write((ushort)1);  // major
            file.Write((ushort)11); // minor

            // items
            file.Write(items.Count);
            foreach (Item item in items)
            {
                // type
                file.Write(item.Type.ToString());
                // directory name
                file.Write(item.DirName);
                // visibility
                file.Write(item.Model.IsVisible);
                // scale
                file.Write(item.Model.Armature.WorldScale.X);
                file.Write(item.Model.Armature.WorldScale.Y);
                file.Write(item.Model.Armature.WorldScale.Z);

                // pose
                Armature armature = item.Model.Armature;
                DataSet  dataSet  = dataSetDict[item];
                foreach (Armature.Bone bone in armature.Bones)
                {
                    BoneTransform boneTransform = dataSet.boneTransforms[bone.id];
                    file.Write(boneTransform.rotX);
                    file.Write(boneTransform.rotY);
                    file.Write(boneTransform.rotZ);
                    file.Write(boneTransform.moveX);
                    file.Write(boneTransform.moveY);
                    file.Write(boneTransform.moveZ);
                }

                // position
                Vector3 position = armature.WorldTranslation;
                file.Write(position.X);
                file.Write(position.Y);
                file.Write(position.Z);

                // accessories
                ExportModelParams(file, item.Model);

                // glow colors
                file.Write(item.ColorGlowLeft.X);
                file.Write(item.ColorGlowLeft.Y);
                file.Write(item.ColorGlowLeft.Z);
                file.Write(item.ColorGlowRight.X);
                file.Write(item.ColorGlowRight.Y);
                file.Write(item.ColorGlowRight.Z);
            }

            // camera
            CameraTurnTable camera = game.Camera;

            file.Write(camera.FieldOfViewHorizontal);
            file.Write(camera.Target.X);
            file.Write(camera.Target.Y);
            file.Write(camera.Target.Z);
            file.Write(camera.Distance);
            file.Write(camera.RotationHorizontal);
            file.Write(camera.RotationVertical);

            // light 1
            Vector3 light1Dir = game.Light1Direction;

            file.Write(light1Dir.X);
            file.Write(light1Dir.Y);
            file.Write(light1Dir.Z);
            file.Write(game.Light1Intensity);
            Color light1Color = game.Light1Color;

            file.Write(light1Color.R);
            file.Write(light1Color.G);
            file.Write(light1Color.B);
            file.Write(game.Light1ShadowDepth);

            // light 2
            Vector3 light2Dir = game.Light2Direction;

            file.Write(light2Dir.X);
            file.Write(light2Dir.Y);
            file.Write(light2Dir.Z);
            file.Write(game.Light2Intensity);
            Color light2Color = game.Light2Color;

            file.Write(light2Color.R);
            file.Write(light2Color.G);
            file.Write(light2Color.B);
            file.Write(game.Light2ShadowDepth);

            // light 3
            Vector3 light3Dir = game.Light3Direction;

            file.Write(light3Dir.X);
            file.Write(light3Dir.Y);
            file.Write(light3Dir.Z);
            file.Write(game.Light3Intensity);
            Color light3Color = game.Light3Color;

            file.Write(light3Color.R);
            file.Write(light3Color.G);
            file.Write(light3Color.B);
            file.Write(game.Light3ShadowDepth);

            // post-processing params
            file.Write(game.PostProcessBrightness);
            file.Write(game.PostProcessGamma);
            file.Write(game.PostProcessContrast);
            file.Write(game.PostProcessSaturation);

            // ground texture
            file.Write(game.DisplayGround);
            file.Write("data\\ground.png");

            // background color
            file.Write(game.BackgroundColor.R);
            file.Write(game.BackgroundColor.G);
            file.Write(game.BackgroundColor.B);

            // background image
            file.Write("");

            // skydome
            file.Write(game.DisplaySkyDome);
            file.Write(ItemType.SkyDome_Thailand_Sea.ToString());
            file.Write(game.SkyDomeRotation);
            file.Write(game.SkyDomeElevation);

            // canvas size
            file.Write(game.GameForm.WindowState == FormWindowState.Maximized);
            file.Write(game.GameForm.ClientSize.Width);
            file.Write(game.GameForm.ClientSize.Height);

            file.Close();
        }