From 760f1cf9ce710efd3cdee6b72699ac15f6d0ad01 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 29 Nov 2014 12:33:25 -0500 Subject: render: Delete scene module. * sly/render/scene.scm: Delete. * Makefile.am (SOURCES): Delete it. --- Makefile.am | 1 - sly/render/scene.scm | 91 ---------------------------------------------------- 2 files changed, 92 deletions(-) delete mode 100644 sly/render/scene.scm diff --git a/Makefile.am b/Makefile.am index 929f9ba..c184dfe 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,7 +51,6 @@ SOURCES = \ sly/render/model.scm \ sly/render/group.scm \ sly/render/texture.scm \ - sly/render/scene.scm \ sly/render/shader.scm \ sly/render/shape.scm \ sly/render/sprite.scm \ diff --git a/sly/render/scene.scm b/sly/render/scene.scm deleted file mode 100644 index 333d60b..0000000 --- a/sly/render/scene.scm +++ /dev/null @@ -1,91 +0,0 @@ -;;; Sly -;;; Copyright (C) 2014 David Thompson -;;; -;;; Sly is free software: you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by -;;; the Free Software Foundation, either version 3 of the License, or -;;; (at your option) any later version. -;;; -;;; Sly is distributed in the hope that it will be useful, but WITHOUT -;;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -;;; License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program. If not, see -;;; . - -;;; Commentary: -;; -;; Hierarchy of renderable objects using a directed acyclic graph -;; structure. -;; -;;; Code: - -(define-module (sly render scene) - #:use-module (ice-9 match) - #:use-module (srfi srfi-1) - #:use-module (srfi srfi-9) - #:use-module (srfi srfi-26) - #:use-module (sly signal) - #:use-module (sly math transform) - #:use-module (sly math vector) - #:use-module (sly render utils) - #:use-module (sly render camera) - #:use-module (sly render renderer) - #:export (scene-node make-scene-node - scene-node? - scene-node-object scene-node-transform - scene-node-visible? scene-node-children - draw-scene)) - -(define-record-type - (%make-scene-node transform visible? children) - scene-node? - (transform scene-node-transform) - (visible? scene-node-visible?) - (children scene-node-children)) - -(define* (make-scene-node #:optional #:key (transform identity-transform) - (visible? #t) (children '())) - "Create a new scene node containing OBJECT, a renderable object that -responds to the 'draw' method. The node has a local transformation -matrix TRANSFORM, and a list of CHILDREN. The VISIBLE? flag etermines -whether to draw the node and all of its children or not." - (%make-scene-node transform visible? children)) - -(define scene-node make-scene-node) - -(define (flatten lst) - "Return a list that recursively concatenates all sub-lists of LIST." - (fold-right - (match-lambda* - (((sub-list ...) memo) - (append (flatten sub-list) memo)) - ((elem memo) - (cons elem memo))) - '() lst)) - -(define (scene->renderer node context camera) - "Traverse the scene graph defined by NODE and its children, as seen -by CAMERA, and return a list of the render operations needed to -display the scene." - (define (iter node parent-transform) - (match (signal-ref-maybe node) - ((? scene-node? node) - (if (scene-node-visible? node) - (let ((transform (transform* parent-transform - (scene-node-transform node)))) - (map (cut iter <> transform) (scene-node-children node))) - '())) - (object - (draw object parent-transform)))) - - (make-renderer context - (list camera) - (flatten (iter node identity-transform)))) - -(define (draw-scene node context camera) - "Draw the scene defined by NODE, as seen by CAMERA." - (apply-viewport (camera-viewport camera)) - (render (scene->renderer node context camera))) -- cgit v1.2.3