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/compiler/translate.sml
ViewVC logotype

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

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

revision 1150, Sat May 7 23:19:46 2011 UTC revision 1151, Sun May 8 00:54:41 2011 UTC
# Line 284  Line 284 
284              letPRIM (vecVar, IR.T_VEC, IR.ADD_VEC, [result, psvToIRVar(env, pt)], stmt)              letPRIM (vecVar, IR.T_VEC, IR.ADD_VEC, [result, psvToIRVar(env, pt)], stmt)
285              )))))))))))))))))))              )))))))))))))))))))
286    
287            (* !FIXME! This isn't right. The values will be generated more towards
288             * the tip of the cone than the base. The scale needs to be adjusted based
289             * on the area of the base (although I don't know how). *)
290          | P.D_CONE{pt1, pt2, irad, orad} => let          | P.D_CONE{pt1, pt2, irad, orad} => let
291               val normVar = PSV.new("local_ht", PSV.T_VEC3F)               val normVar = PSV.new("local_ht", PSV.T_VEC3F)
292              in              in
# Line 336  Line 339 
339                    letPRIM("randVar", IR.T_FLOAT, IR.RAND, [], fn rand =>                    letPRIM("randVar", IR.T_FLOAT, IR.RAND, [], fn rand =>
340                    letPRIM("randScale", IR.T_FLOAT, IR.MULT, [rand, invRatio], fn randScale =>                    letPRIM("randScale", IR.T_FLOAT, IR.MULT, [rand, invRatio], fn randScale =>
341                    letPRIM("randVal", IR.T_FLOAT, IR.ADD, [randScale, ratio], fn randVal =>                    letPRIM("randVal", IR.T_FLOAT, IR.ADD, [randScale, ratio], fn randVal =>
342                    letPRIM("randValSq", IR.T_FLOAT, IR.MULT, [randVal, randVal], fn randValSq =>                    letPRIM("randValSq", IR.T_FLOAT, IR.SQRT, [randVal], fn randValSq =>
343                    letPRIM("radDiff", IR.T_FLOAT, IR.SUB, [psvToIRVar(env, orad), psvToIRVar(env, irad)], fn radDiff =>                    letPRIM("radDiff", IR.T_FLOAT, IR.SUB, [psvToIRVar(env, orad), psvToIRVar(env, irad)], fn radDiff =>
344                    letPRIM("randRadVal", IR.T_FLOAT, IR.MULT, [radDiff, randValSq], fn randRadVal =>                    letPRIM("randRadVal", IR.T_FLOAT, IR.MULT, [radDiff, randValSq], fn randRadVal =>
345                    letPRIM("rad", IR.T_FLOAT, IR.ADD, [psvToIRVar(env, irad), randRadVal], fn rad =>                    letPRIM("rad", IR.T_FLOAT, IR.ADD, [psvToIRVar(env, irad), randRadVal], fn rad =>
# Line 614  Line 617 
617            of P.D_PLANE{pt, normal} =>            of P.D_PLANE{pt, normal} =>
618               letPRIM("inVec", IR.T_VEC, IR.SUB_VEC, [psvToIRVar(env, pt), pos], fn inVec =>               letPRIM("inVec", IR.T_VEC, IR.SUB_VEC, [psvToIRVar(env, pt), pos], fn inVec =>
619               letPRIM("dotNorm", IR.T_FLOAT, IR.DOT, [psvToIRVar(env, normal), inVec], fn dotNorm =>               letPRIM("dotNorm", IR.T_FLOAT, IR.DOT, [psvToIRVar(env, normal), inVec], fn dotNorm =>
620               letPRIM("eqZero", IR.T_BOOL, IR.EQUALS, [dotNorm, IR.newConst("One", IR.C_FLOAT 0.0)], fn eqZero =>               letPRIM("absDot", IR.T_FLOAT, IR.ABS, [dotNorm], fn absDot =>
621               IR.mkIF(eqZero,               letPRIM("avoidZero", IR.T_FLOAT, IR.MAX, [psvToIRVar(env, epsilon), absDot], fn dot =>
622                   (*thenStmt*)           letPRIM("dnRecip", IR.T_FLOAT, IR.DIV, [IR.newConst("One", IR.C_FLOAT 1.0), dot], fn dnRecip =>
623                   gotoWithArgs(env, [psvToIRVar(env, normal)], nextBlk),           letPRIM("sign", IR.T_FLOAT, IR.MULT, [dnRecip, dotNorm], fn sign =>
              (*elseStmt*)  
              letPRIM("dnRecip", IR.T_FLOAT, IR.DIV, [IR.newConst("One", IR.C_FLOAT 1.0), dotNorm], fn dnRecip =>  
              letPRIM("absR", IR.T_FLOAT, IR.ABS, [dnRecip], fn absR =>  
              letPRIM("sign", IR.T_FLOAT, IR.MULT, [absR, dotNorm], fn sign =>  
624               letPRIM(retNorm, IR.T_VEC, IR.SCALE, [sign, psvToIRVar(env, normal)],               letPRIM(retNorm, IR.T_VEC, IR.SCALE, [sign, psvToIRVar(env, normal)],
625               fn newNormVar => gotoWithArgs(env, [newNormVar], nextBlk)))))               fn newNormVar => gotoWithArgs(env, [newNormVar], nextBlk)))))
626           ))))           )))
627    
628             | P.D_DISC{pt, normal, irad, orad} =>             | P.D_DISC{pt, normal, irad, orad} =>
629                normAtPoint(retNorm, P.D_PLANE{pt=pt, normal=normal}, env, pos, k)                normAtPoint(retNorm, P.D_PLANE{pt=pt, normal=normal}, env, pos, k)

Legend:
Removed from v.1150  
changed lines
  Added in v.1151

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