Home My Page Projects Code Snippets Project Openings 3D graphics for Standard ML
Summary Activity SCM

SCM Repository

[sml3d] Diff of /trunk/sml3d/src/particles/particles.sml
ViewVC logotype

Diff of /trunk/sml3d/src/particles/particles.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1106, Thu Mar 31 15:17:40 2011 UTC revision 1107, Wed Apr 6 22:46:51 2011 UTC
# Line 499  Line 499 
499    
500      datatype renderer = REND of {      datatype renderer = REND of {
501        prim : PSysIR.renderer,        prim : PSysIR.renderer,
502        sv_gens : generator list        sv_gens : generator list,
503          names : string PSV.SVMap.map
504      }      }
505    
506      fun points {colors as (sv, exp_color)} = REND {      fun points {colors as (sv, exp_color)} = REND {
507        prim = PSysIR.POINTS,        prim = PSysIR.POINTS,
508        sv_gens = [ GEN { var = sv, exp = exp_color } ]        sv_gens = [ GEN { var = sv, exp = exp_color } ],
509          names = PSV.SVMap.singleton (sv, "color")
510      }      }
511    
512      fun texQuads {textureList, sizes, rotations} = let      fun texQuads {textureList, sizes, rotations} = let
513          val sing = PSV.SVMap.singleton
514          val union = PSV.SVMap.unionWith (fn x => raise Fail("Adding the same variable."))
515        val (sv_sz, exp_sz) = sizes        val (sv_sz, exp_sz) = sizes
516        val (sv_rot, exp_rot) = rotations        val (sv_rot, exp_rot) = rotations
517       in       in
# Line 516  Line 520 
520          sv_gens = [          sv_gens = [
521            GEN { var = sv_sz, exp = exp_sz },            GEN { var = sv_sz, exp = exp_sz },
522            GEN { var = sv_rot, exp = exp_rot }            GEN { var = sv_rot, exp = exp_rot }
523          ]          ],
524            names = union (sing (sv_sz, "size"), sing (sv_rot, "rotation"))
525        }        }
526       end       end
527    
# Line 525  Line 530 
530            act : action,            act : action,
531            render : PSysIR.renderer,            render : PSysIR.renderer,
532            vars : VSet.set,            vars : VSet.set,
533            state_vars : SVSet.set            state_vars : SVSet.set,
534              render_vars : string PSV.SVMap.map
535      }      }
536    
537      fun create {emit, act, render} = let      fun create {emit, act, render} = let
# Line 635  Line 641 
641          | getVs(ASSIGN (sv, exp)) = extractVars(exp)          | getVs(ASSIGN (sv, exp)) = extractVars(exp)
642          | getVs(DIE) = VSet.empty          | getVs(DIE) = VSet.empty
643    
644        val REND{prim, sv_gens=rend_sv_gens} = render        val REND{prim, sv_gens=rend_sv_gens, names} = render
645        val EMIT{freq, sv_gens} = emit        val EMIT{freq, sv_gens} = emit
646    
647        val gens = sv_gens @ rend_sv_gens        val gens = sv_gens @ rend_sv_gens
# Line 643  Line 649 
649        fun getVsFromGen(GEN{var, exp}) = extractVars(exp)        fun getVsFromGen(GEN{var, exp}) = extractVars(exp)
650        fun getSVsFromGen(GEN{var, exp})        fun getSVsFromGen(GEN{var, exp})
651          = SVSet.union( SVSet.singleton var, extractStateVars(exp) )          = SVSet.union( SVSet.singleton var, extractStateVars(exp) )
652    
653          val union = PSV.SVMap.unionWith (fn x => raise Fail("Adding the same variable."))
654          val preDefVars = [PSV.numDead, PSV.timeStep]
655       in       in
656        PG{        PG{
657          emit = EMIT{ freq = freq, sv_gens = gens },          emit = EMIT{ freq = freq, sv_gens = gens },
658          act = act,          act = act,
659          render = prim,          render = prim,
660          vars = List.foldl VSet.union VSet.empty (getVs act :: (List.map getVsFromGen gens)),          vars = List.foldl VSet.union VSet.empty ([getVs act, VSet.fromList preDefVars] @ (List.map getVsFromGen gens)),
661          state_vars = List.foldl  SVSet.union SVSet.empty (getSVs act :: (List.map getSVsFromGen gens))          state_vars = List.foldl  SVSet.union SVSet.empty (getSVs act :: (List.map getSVsFromGen gens)),
662            render_vars = union (PSV.SVMap.singleton (sv_pos, "position"), names)
663        }        }
664       end (* create *)       end (* create *)
665    

Legend:
Removed from v.1106  
changed lines
  Added in v.1107

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0