grt-talk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [grt-talk] Some suggestions.


From: Anton N. Mescheryakov
Subject: Re: [grt-talk] Some suggestions.
Date: Mon, 05 May 2003 09:46:19 +0400
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4a) Gecko/20030401


3) *scene* is evil. Let's do 'with-scene, please? Something like
allegro-serve 'html macro:

The scene-creation interface is a tough one. Originally it wen't something
like this:

(let ((scene (make-scene :backgound-color +black+)))
  (scene-add scene (sphere 1.0 +O+))
  ...)

The explicit provision of the scene to insert things into turned out to be
a major pain. *scene* and the scene -function are a slightly less painfull
(but admittedly ugly) alternative.

I like the with-scene, though. This needs thinking about, and I'm somewhat
hesitant to turn the basic scene-creation method into a giant macro.
There is also the question of less than trivial scenes (say anything with
over 1000 lines of code): the interface has to be nice for them as well.

Hey, guy! Why 1000 lines of code? 11 looks enough!

(defmacro form-scene  (&rest forms)
 `(make-scene :background-color ,(second (assoc ':background forms))
          :ambient-light ,(second (assoc ':ambient forms))
          :objects (list ,@(collect-forms ':object forms))
          :lights (list ,@(collect-forms ':light forms))))

(defun collect-forms (key forms)
 (cond ((null forms)
    ())
   ((eq (car (first forms)) key)
    (cons (second (first forms)) (collect-forms key (rest forms))))
   (t (collect-forms key (rest forms)))))

I know it's ugly and not as elegant as mr. Graham's stuff, but it works!
So your classic-demo transforms into something like:

(defun classic-demo-1 (&key (file "classic-demo-1.ppm") screen
             (width 400)
             (height 300))
 (let ((scene (form-scene
       (:ambient +white+)
       (:background +skyblue+)
       (:light (light :location '(0 15 -15)))
       (:object (plane
             +Y+ '(0 0.01 0)
             :pigment (make-pigment :pattern (function checker)
                        :list `(,+white+ ,+black+))
             :reflection (make-solid 0.2)
             :ambient 0.2
             :diffuse 0.8))
       (:object (sphere
             1.0 '(0 1 0)
             :pigment (make-pigment :solid +red+)
             :filter (make-solid 0.5)
             :reflection (make-solid 0.2)
             :ior 1.4)))))
   (render
    :file (concatenate 'string "examples/" file)
    :camera (camera :location '(2 3.5 -10)
            :look-at '(0 1 0))
    :scene scene
    :depth 6
    :keep-open 1
    :screen screen
:width width :height height)))

So you setf tax is much reduced, according to "On Lisp" great rule.

BTW. It looks like background isn't accounted in reflections, or I'm wrong? Another BTW: math.lisp and color.lisp both have much in common, agree? Just the same operations with grt-float triples. Why don't merge?

This is the stuff I'm currently thinking or working on:
1. Pattern mapping. That is, explicit, planar, spherical etc. Just transforms object coords into pattern space. Almost obligatory for image patterns.
2. Pattern blending. That's why my previous question about RGBA arises.
3. Patterned background/environmental mapping.

Suggestions?

Best regards,
   Anton.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]