コード例 #1
0
ファイル: Lights.cs プロジェクト: johtela/Compose3D
 public DirectionalLight(SceneGraph graph, Vec3 intensity, Vec3 direction, float maxShadowDepth)
     : base(graph)
 {
     Intensity      = intensity;
     MaxShadowDepth = maxShadowDepth;
     Direction      = direction.Normalized;
 }
コード例 #2
0
ファイル: Lights.cs プロジェクト: johtela/Compose3D
 public DirectionalLight(SceneGraph graph, Vec3 intensity, Vec3 direction, float maxShadowDepth)
     : base(graph)
 {
     Intensity = intensity;
     MaxShadowDepth = maxShadowDepth;
     Direction = direction.Normalized;
 }
コード例 #3
0
ファイル: MaterialWindow.cs プロジェクト: johtela/Compose3D
        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
ファイル: ControlPanel.cs プロジェクト: johtela/Compose3D
 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
ファイル: SceneNode.cs プロジェクト: johtela/Compose3D
 public SceneNode(SceneGraph graph)
 {
     if (graph == null)
     {
         throw new ArgumentNullException("graph");
     }
     Graph = graph;
 }
コード例 #7
0
ファイル: TransformNode.cs プロジェクト: johtela/Compose3D
 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
ファイル: Lights.cs プロジェクト: johtela/Compose3D
 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
ファイル: FighterWindow.cs プロジェクト: johtela/Compose3D
        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
ファイル: Skybox.cs プロジェクト: johtela/Compose3D
        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
ファイル: FighterWindow.cs プロジェクト: johtela/Compose3D
        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
ファイル: Lights.cs プロジェクト: johtela/Compose3D
 public Light(SceneGraph graph)
     : base(graph)
 {
 }
コード例 #17
0
ファイル: ControlPanel.cs プロジェクト: johtela/Compose3D
 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
ファイル: SceneGroup.cs プロジェクト: johtela/Compose3D
 public SceneGroup(SceneGraph graph)
     : base(graph)
 {
     _subNodes = new List<SceneNode> ();
 }
コード例 #19
0
ファイル: SceneNodeWrapper.cs プロジェクト: johtela/Compose3D
 public SceneNodeWrapper(SceneGraph graph, SceneNode node)
     : base(graph)
 {
     Node = node;
     Node.Parent = this;
 }
コード例 #20
0
ファイル: MaterialPanel.cs プロジェクト: johtela/Compose3D
 public MaterialPanel(SceneGraph graph, bool flipVertically, bool movable, Vec2i repeat)
     : base(graph, flipVertically, movable)
 {
     _repeat   = repeat;
     _renderer = PanelRenderer.Custom;
 }
コード例 #21
0
ファイル: LineSegment.cs プロジェクト: johtela/Compose3D
 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
ファイル: SceneGroup.cs プロジェクト: johtela/Compose3D
 public SceneGroup(SceneGraph graph, IEnumerable<SceneNode> subNodes)
     : this(graph)
 {
     Add (subNodes);
 }
コード例 #25
0
ファイル: Lights.cs プロジェクト: johtela/Compose3D
 public Light(SceneGraph graph) : base(graph)
 {
 }
コード例 #26
0
ファイル: SceneGroup.cs プロジェクト: johtela/Compose3D
 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
ファイル: SceneNode.cs プロジェクト: johtela/Compose3D
 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
ファイル: NodeWrapper.cs プロジェクト: johtela/Compose3D
 public NodeWrapper(SceneGraph graph, T node) : base(graph)
 {
     Node        = node;
     Node.Parent = this;
 }
コード例 #33
0
ファイル: MaterialPanel.cs プロジェクト: johtela/Compose3D
 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
ファイル: Lights.cs プロジェクト: johtela/Compose3D
        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
ファイル: Shadows.cs プロジェクト: johtela/Compose3D
        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);
        }