public override void Init()
        {
            Content.ContentPath = "Data";
            Instance = this;

            scene = new Scene();
            scene.View = this;
            scene.Camera = new LookatCartesianCamera()
            {
                Position = new Vector3(10, 10, 10),
                Lookat = Vector3.Zero,
                ZFar = 100,
                AspectRatio = AspectRatio
            };
            //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100);
            texture = new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>(new Graphics.Software.Texel.A8R8G8B8[250, 250]);

            scene.Add(ground = new TestGround
            {
                Size = new SizeF(100, 100),
                //Texture = new SingleColorTexture(Color.Orange),
                NPieces = new Size(20, 20),

            });
            ground.ConstructPieces();

            dxTexture = texture.ToTexture9(Device9);

            ground.Texture = new UnmanagedResource<SlimDX.Direct3D9.Texture, SlimDX.Direct3D10.Texture2D> { Resource9 = dxTexture };

            groundTextureEditor = new Graphics.Editors.GroundTextureEditor
            {
                Camera = scene.Camera,
                Viewport = Viewport,
                SoftwareTexture = new[] {texture},
                Texture9 = new[] {dxTexture},
                Position = ground.Translation,
                Size = ground.Size,
                GroundIntersect = new WorldViewProbe(this, scene.Camera)
                {
                    WorldProbe = new GroundProbe()
                },
                Pencil = new Graphics.Editors.GroundTexturePencil
                {
                    Color = new Vector4(0, 0, 1, 0),
                    Radius = 5,
                    Type = Graphics.Editors.GroundTexturePencilType.AddSaturate
                }
            };
            groundTextureEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) =>
            {
            });
            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera = (LookatCartesianCamera)scene.Camera,
                InputHandler = groundTextureEditor,
            };

            renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) };
            renderer.Initialize(this);

            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Renderer = renderer,
                Scene = scene
            };
            sceneRendererConnector.Initialize();
        }
示例#2
0
        public override void Init()
        {
            Content.ContentPath = "Data";
            Instance            = this;

            scene        = new Scene();
            scene.View   = this;
            scene.Camera = new LookatCartesianCamera()
            {
                Position    = new Vector3(10, 10, 10),
                Lookat      = Vector3.Zero,
                ZFar        = 100,
                AspectRatio = AspectRatio
            };
            //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100);
            texture = new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>(new Graphics.Software.Texel.A8R8G8B8[250, 250]);

            scene.Add(ground = new TestGround
            {
                Size = new SizeF(100, 100),
                //Texture = new SingleColorTexture(Color.Orange),
                NPieces = new Size(20, 20),
            });
            ground.ConstructPieces();

            dxTexture = texture.ToTexture9(Device9);

            ground.Texture = new UnmanagedResource <SlimDX.Direct3D9.Texture, SlimDX.Direct3D10.Texture2D> {
                Resource9 = dxTexture
            };

            groundTextureEditor = new Graphics.Editors.GroundTextureEditor
            {
                Camera          = scene.Camera,
                Viewport        = Viewport,
                SoftwareTexture = new[] { texture },
                Texture9        = new[] { dxTexture },
                Position        = ground.Translation,
                Size            = ground.Size,
                GroundIntersect = new WorldViewProbe(this, scene.Camera)
                {
                    WorldProbe = new GroundProbe()
                },
                Pencil = new Graphics.Editors.GroundTexturePencil
                {
                    Color  = new Vector4(0, 0, 1, 0),
                    Radius = 5,
                    Type   = Graphics.Editors.GroundTexturePencilType.AddSaturate
                }
            };
            groundTextureEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) =>
            {
            });
            InputHandler = new WalkaroundCameraInputHandler
            {
                Camera       = (LookatCartesianCamera)scene.Camera,
                InputHandler = groundTextureEditor,
            };

            renderer = new Graphics.Renderer.Renderer(Device9)
            {
                Scene = scene, StateManager = new Device9StateManager(Device9)
            };
            renderer.Initialize(this);

            sceneRendererConnector = new SortedTestSceneRendererConnector
            {
                Renderer = renderer,
                Scene    = scene
            };
            sceneRendererConnector.Initialize();
        }