public DirectionalLight(SceneGraph graph, Vec3 intensity, Vec3 direction, float maxShadowDepth) : base(graph) { Intensity = intensity; MaxShadowDepth = maxShadowDepth; Direction = direction.Normalized; }
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); }
public TransformNode(SceneGraph graph, T node, Vec3 offset, Vec3 orientation, Vec3 scale) : base(graph, node) { _offset = offset; _orientation = orientation; _scale = scale; UpdateTransform(); }
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(); }
public SceneNode(SceneGraph graph) { if (graph == null) { throw new ArgumentNullException("graph"); } Graph = graph; }
public TransformNode(SceneGraph graph, SceneNode node, Vec3 offset, Vec3 orientation, Vec3 scale) : base(graph, node) { _offset = offset; _orientation = orientation; _scale = scale; UpdateTransform (); }
public Camera(SceneGraph graph, Vec3 position, Vec3 target, Vec3 upDirection, ViewingFrustum frustum, float aspectRatio) : base(graph) { Position = position; Target = target; UpDirection = upDirection; Frustum = frustum; }
public PointLight(SceneGraph graph, Vec3 intensity, Vec3 position, float linearAttenuation, float quadraticAttenuation) : base(graph) { Intensity = intensity; Position = position; LinearAttenuation = linearAttenuation; QuadraticAttenuation = quadraticAttenuation; }
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; }
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); } }
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 (); }
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); }
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; }
public StaticMesh(SceneGraph graph, Geometry <V> geometry, params Texture[] textures) : base(graph, geometry, textures) { }
public Light(SceneGraph graph) : base(graph) { }
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))); }
public SceneGroup(SceneGraph graph) : base(graph) { _subNodes = new List<SceneNode> (); }
public SceneNodeWrapper(SceneGraph graph, SceneNode node) : base(graph) { Node = node; Node.Parent = this; }
public MaterialPanel(SceneGraph graph, bool flipVertically, bool movable, Vec2i repeat) : base(graph, flipVertically, movable) { _repeat = repeat; _renderer = PanelRenderer.Custom; }
public LineSegment(SceneGraph graph, Path <P, V> path) : base(graph) { Path = path; }
public SceneGroup(SceneGraph graph, params SceneNode[] subNodes) : this(graph) { Add(subNodes); }
public SceneGroup(SceneGraph graph) : base(graph) { _subNodes = new List <SceneNode> (); }
public SceneGroup(SceneGraph graph, IEnumerable<SceneNode> subNodes) : this(graph) { Add (subNodes); }
public SceneGroup(SceneGraph graph, params SceneNode[] subNodes) : this(graph) { Add (subNodes); }
public SceneGroup(SceneGraph graph, IEnumerable <SceneNode> subNodes) : this(graph) { Add(subNodes); }
public SceneNode(SceneGraph graph) { if (graph == null) throw new ArgumentNullException ("graph"); Graph = graph; }
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); }
public Panel(SceneGraph graph, bool flipVertically, bool movable, Texture texture) : this(graph, flipVertically, movable) { Texture = texture; }
public Mesh(SceneGraph graph, Geometry <V> geometry, params Texture[] textures) : base(graph) { Geometry = geometry; Textures = textures; }
public NodeWrapper(SceneGraph graph, T node) : base(graph) { Node = node; Node.Parent = this; }
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))); }
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))); }
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); }