示例#1
0
 public DirectionalLight(SceneGraph graph, Vec3 intensity, Vec3 direction, float maxShadowDepth)
     : base(graph)
 {
     Intensity      = intensity;
     MaxShadowDepth = maxShadowDepth;
     Direction      = direction.Normalized;
 }
示例#2
0
 public DirectionalLight(SceneGraph graph, Vec3 intensity, Vec3 direction, float maxShadowDepth)
     : base(graph)
 {
     Intensity = intensity;
     MaxShadowDepth = maxShadowDepth;
     Direction = direction.Normalized;
 }
示例#3
0
        private void CreateSceneGraph()
        {
            _sceneGraph = new SceneGraph ();

            _camera = new Camera (_sceneGraph,
                position: new Vec3 (0f, 0f, 1f),
                target: new Vec3 (0f, 0f, 0f),
                upDirection: new Vec3 (0f, 1f, 0f),
                frustum: new ViewingFrustum (FrustumKind.Perspective, 1f, 1f, -1f, -10000f),
                aspectRatio: 1f);

            var rect = Quadrilateral<MaterialVertex>.Rectangle (100f, 100f);
            rect.ApplyTextureFront (1f, new Vec2 (0f), new Vec2 (1f));
            rect.UpdateTangents (BeginMode.Triangles);

            _signalTexture = new Texture (TextureTarget.Texture2D);
            var infoWindow = ControlPanel<TexturedVertex>.Movable (_sceneGraph, SignalTextureUI (),
                new Vec2i (650, 550), new Vec2 (-0.99f, 0.99f));
            var textureWindow = Panel<TexturedVertex>.Movable (_sceneGraph, false, _signalTexture,
                new Vec2 (0.25f, 0.75f), new Vec2i (2));

            _diffuseMap = new Texture (TextureTarget.Texture2D);
            _normalMap = new Texture (TextureTarget.Texture2D);

            _mesh = new Mesh<MaterialVertex> (_sceneGraph, rect);
            _sceneGraph.Root.Add (_camera, _mesh,
                infoWindow, textureWindow);
        }
示例#4
0
 public TransformNode(SceneGraph graph, T node, Vec3 offset, Vec3 orientation, Vec3 scale)
     : base(graph, node)
 {
     _offset      = offset;
     _orientation = orientation;
     _scale       = scale;
     UpdateTransform();
 }
示例#5
0
 public ControlPanel(SceneGraph graph, Control control, Vec2i size, bool movable)
     : base(graph, true, movable)
 {
     Control = control;
     _size   = size;
     _visual = control.ToVisual(new SizeF(size.X, size.Y));
     CreateBitmap();
 }
示例#6
0
 public SceneNode(SceneGraph graph)
 {
     if (graph == null)
     {
         throw new ArgumentNullException("graph");
     }
     Graph = graph;
 }
示例#7
0
 public TransformNode(SceneGraph graph, SceneNode node, Vec3 offset, Vec3 orientation, Vec3 scale)
     : base(graph, node)
 {
     _offset = offset;
     _orientation = orientation;
     _scale = scale;
     UpdateTransform ();
 }
示例#8
0
 public Camera(SceneGraph graph, Vec3 position, Vec3 target, Vec3 upDirection, ViewingFrustum frustum,
               float aspectRatio) : base(graph)
 {
     Position    = position;
     Target      = target;
     UpDirection = upDirection;
     Frustum     = frustum;
 }
示例#9
0
 public PointLight(SceneGraph graph, Vec3 intensity, Vec3 position, float linearAttenuation,
                   float quadraticAttenuation) : base(graph)
 {
     Intensity            = intensity;
     Position             = position;
     LinearAttenuation    = linearAttenuation;
     QuadraticAttenuation = quadraticAttenuation;
 }
示例#10
0
        public Panel(SceneGraph graph, bool flipVertically, bool movable)
            : base(graph)
        {
            _rectangle = Quadrilateral <V> .Rectangle(1f, 1f).Translate(0.5f, -0.5f);

            _flipVertically = flipVertically;
            _movable        = movable;
        }
示例#11
0
        public static void UpdateAll(SceneGraph sceneGraph, GameWindow window, Vec2i viewportSize)
        {
            InputState.Update(window);
            var panels = sceneGraph.Root.Traverse().OfType <Panel <V> > ();

            foreach (var panel in panels)
            {
                panel.Update(viewportSize, window.Mouse);
            }
        }
示例#12
0
        public FighterWindow()
            : base(256, 256, GraphicsMode.Default, "Compose3D", GameWindowFlags.Default, 
				DisplayDevice.Default, 4, 0, GraphicsContextFlags.Default)
        {
            _rotation = new Vec2 ();
            _zoom = 20f;
            _sceneGraph = CreateSceneGraph ();
            SetupRendering ();
            SetupCameraMovement ();
            //AddShadowWindow ();
        }
示例#13
0
        public static Reaction<Camera> Renderer(SceneGraph sceneGraph, Vec3 skyColor)
        {
            _skyboxShader = new GLProgram (VertexShader (), FragmentShader ());
            _skybox = new Skybox (_skyboxShader);
            _skyColor = skyColor;
            var cube = Extrusion.Cube<PositionalVertex> (_cubeSize, _cubeSize, _cubeSize).Center ();
            _vertices = new VBO<PositionalVertex> (cube.Vertices, BufferTarget.ArrayBuffer);
            _indices = new VBO<int> (cube.Indices, BufferTarget.ElementArrayBuffer);
            var environmentMap = Texture.CubeMapFromFiles (
                _paths.Map (s => string.Format (@"Textures/{0}.bmp", s)), 0)
                .LinearFiltering ().ClampToEdges (Axes.All);
            sceneGraph.GlobalLighting.DiffuseMap = environmentMap;

            return React.By<Camera> (_skybox.Render)
                .BindSamplers (new Dictionary<Sampler, Texture> ()
                {
                    { !_skybox.cubeMap, environmentMap }
                })
                .Culling (CullFaceMode.Front)
                .Program (_skyboxShader);
        }
示例#14
0
        private SceneGraph CreateSceneGraph()
        {
            var sceneGraph = new SceneGraph ();
            _dirLight = new DirectionalLight (sceneGraph,
                intensity: new Vec3 (1f),
                direction: new Vec3 (0.7f, 1f, -0.7f),
                maxShadowDepth: 200f);

            _camera = new Camera (sceneGraph,
                position: new Vec3 (0f, 10f, 10f),
                target: new Vec3 (0f, 10f, -1f),
                upDirection: new Vec3 (0f, 1f, 0f),
                frustum: new ViewingFrustum (FrustumKind.Perspective, 1f, 1f, -1f, -400f),
                aspectRatio: 1f);

            sceneGraph.GlobalLighting = new GlobalLighting ()
            {
                AmbientLightIntensity = new Vec3 (0.1f),
                MaxIntensity = 1f,
                GammaCorrection = 1.8f,
            };

            _terrainScene = new Terrain.Scene (sceneGraph);
            var fighterGeometry = new FighterGeometry<EntityVertex, PathNode> ();
            _fighter = new Mesh<EntityVertex> (sceneGraph, fighterGeometry.Fighter.RotateY (0f).Compact ())
                .OffsetOrientAndScale (new Vec3 (0f, 15f, -10f), new Vec3 (0f, 0f, 0f), new Vec3 (1f));

            _infoWindow = new ControlPanel<TexturedVertex> (sceneGraph,
                Container.Vertical (true, false,
                    Label.Static ("Options", FontStyle.Bold),
                    new ListView (React.Ignore <IVisualizable> (),
                        new Visualizable (() => Visual.Label (string.Format ("FPS: {0}", _fps))),
                        new Visualizable (() => Visual.Label (
                            string.Format ("Mouse: {0}", new Vec2i (Mouse.X , Mouse.Y)))))),
                new Vec2i (180, 64), false);
            sceneGraph.Root.Add (_dirLight, _camera, _terrainScene.Root, _fighter,
                _infoWindow.Offset (new Vec3 (-0.95f, 0.95f, 0f)));
            return sceneGraph;
        }
示例#15
0
 public StaticMesh(SceneGraph graph, Geometry <V> geometry, params Texture[] textures)
     : base(graph, geometry, textures)
 {
 }
示例#16
0
 public Light(SceneGraph graph)
     : base(graph)
 {
 }
示例#17
0
 public static SceneNode Movable(SceneGraph graph, Control control, Vec2i size, Vec2 pos)
 {
     return(new ControlPanel <V> (graph, control, size, true)
            .Offset(new Vec3(pos, 0f)));
 }
示例#18
0
 public SceneGroup(SceneGraph graph)
     : base(graph)
 {
     _subNodes = new List<SceneNode> ();
 }
示例#19
0
 public SceneNodeWrapper(SceneGraph graph, SceneNode node)
     : base(graph)
 {
     Node = node;
     Node.Parent = this;
 }
示例#20
0
 public MaterialPanel(SceneGraph graph, bool flipVertically, bool movable, Vec2i repeat)
     : base(graph, flipVertically, movable)
 {
     _repeat   = repeat;
     _renderer = PanelRenderer.Custom;
 }
示例#21
0
 public LineSegment(SceneGraph graph, Path <P, V> path) : base(graph)
 {
     Path = path;
 }
示例#22
0
 public SceneGroup(SceneGraph graph, params SceneNode[] subNodes) : this(graph)
 {
     Add(subNodes);
 }
示例#23
0
 public SceneGroup(SceneGraph graph) : base(graph)
 {
     _subNodes = new List <SceneNode> ();
 }
示例#24
0
 public SceneGroup(SceneGraph graph, IEnumerable<SceneNode> subNodes)
     : this(graph)
 {
     Add (subNodes);
 }
示例#25
0
 public Light(SceneGraph graph) : base(graph)
 {
 }
示例#26
0
 public SceneGroup(SceneGraph graph, params SceneNode[] subNodes)
     : this(graph)
 {
     Add (subNodes);
 }
示例#27
0
 public SceneGroup(SceneGraph graph, IEnumerable <SceneNode> subNodes) : this(graph)
 {
     Add(subNodes);
 }
示例#28
0
 public SceneNode(SceneGraph graph)
 {
     if (graph == null)
         throw new ArgumentNullException ("graph");
     Graph = graph;
 }
示例#29
0
 public TerrainMesh(SceneGraph graph, Vec2i start, Vec2i size, float amplitude, float frequency,
                    int octaves, float amplitudeDamping, float frequencyMultiplier) : base(graph)
 {
     Patch = new TerrainPatch <V> (start, size, amplitude, frequency, octaves,
                                   amplitudeDamping, frequencyMultiplier);
 }
示例#30
0
 public Panel(SceneGraph graph, bool flipVertically, bool movable, Texture texture)
     : this(graph, flipVertically, movable)
 {
     Texture = texture;
 }
示例#31
0
文件: Mesh.cs 项目: johtela/Compose3D
 public Mesh(SceneGraph graph, Geometry <V> geometry, params Texture[] textures)
     : base(graph)
 {
     Geometry = geometry;
     Textures = textures;
 }
示例#32
0
 public NodeWrapper(SceneGraph graph, T node) : base(graph)
 {
     Node        = node;
     Node.Parent = this;
 }
示例#33
0
 public static TransformNode <MaterialPanel <V> > Movable(SceneGraph graph, bool flipVertically,
                                                          Vec2 pos, Vec2i repeat)
 {
     return(new MaterialPanel <V> (graph, flipVertically, true, repeat)
            .Offset(new Vec3(pos, 0f)));
 }
示例#34
0
        public PointLight(SceneGraph graph, Vec3 intensity, Vec3 position, float linearAttenuation, 
			float quadraticAttenuation)
            : base(graph)
        {
            Intensity = intensity;
            Position = position;
            LinearAttenuation = linearAttenuation;
            QuadraticAttenuation = quadraticAttenuation;
        }
示例#35
0
 public static SceneNode Movable(SceneGraph graph, bool flipVertically, Texture texture, Vec2 pos)
 {
     return(new Panel <V> (graph, flipVertically, true, texture)
            .Offset(new Vec3(pos, 0f)));
 }
示例#36
0
        public static Reaction<Camera> Renderer(SceneGraph scene,
			int mapSize, ShadowMapType type, bool cascaded)
        {
            var depthFramebuffer = new Framebuffer (FramebufferTarget.Framebuffer);
            _shadowShader = cascaded ?
                new GLProgram (
                    VertexShaderCascaded (),
                    GeometryShaderCascaded (),
                    DepthFragmentShader ()) :
                new GLProgram (
                    VertexShader (),
                    type == ShadowMapType.Depth ? DepthFragmentShader () : VarianceFragmentShader ());

            _instance = new Shadows (_shadowShader, cascaded);

            Texture depthTexture;
            var render =React.By<Camera> (_instance.Render);
            if (type == ShadowMapType.Depth || cascaded)
            {
                depthTexture = cascaded ?
                    new Texture (TextureTarget.Texture2DArray, PixelInternalFormat.DepthComponent16,
                        mapSize, mapSize, CascadedShadowUniforms.MapCount, PixelFormat.DepthComponent,
                        PixelType.Float, IntPtr.Zero) :
                    new Texture (TextureTarget.Texture2D, PixelInternalFormat.DepthComponent16,
                        mapSize, mapSize, PixelFormat.DepthComponent, PixelType.Float, IntPtr.Zero);
                depthFramebuffer.AddTexture (FramebufferAttachment.DepthAttachment, depthTexture);
            }
            else
            {
                depthTexture = new Texture (TextureTarget.Texture2D, PixelInternalFormat.Rg32f,
                    mapSize, mapSize, PixelFormat.Rg, PixelType.Float, IntPtr.Zero);
                depthFramebuffer.AddTexture (FramebufferAttachment.ColorAttachment0, depthTexture);
                depthFramebuffer.AddRenderbuffer (FramebufferAttachment.DepthAttachment,
                    RenderbufferStorage.DepthComponent16, mapSize, mapSize);
                var gaussTexture = new Texture (TextureTarget.Texture2D, PixelInternalFormat.Rg32f,
                    mapSize / 2, mapSize / 2, PixelFormat.Rg, PixelType.Float, IntPtr.Zero);
                render = render.And (GaussianFilter.Both ().MapInput ((Camera cam) =>
                    Tuple.Create (depthTexture, gaussTexture)));
            }
            scene.GlobalLighting.ShadowMap = depthTexture;

            return render
                .DrawBuffer (type == ShadowMapType.Depth ? DrawBufferMode.None : DrawBufferMode.Front)
                .DepthTest ()
                .Culling ()
                .Viewport (new Vec2i (mapSize, mapSize))
                .Program (_shadowShader)
                .Texture (depthTexture)
                .Framebuffer (depthFramebuffer);
        }