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 870, Fri Apr 30 17:21:32 2010 UTC revision 873, Wed May 5 20:18:00 2010 UTC
# Line 139  Line 139 
139                  letPRIM ("pt2s", IR.T_VEC, IR.SCALE, [randInv, psvToIRVar(env, pt2)], fn pt2ScaleVec =>                  letPRIM ("pt2s", IR.T_VEC, IR.SCALE, [randInv, psvToIRVar(env, pt2)], fn pt2ScaleVec =>
140                  letPRIM (vecVar, IR.T_VEC, IR.ADD_VEC, [pt1ScaleVec, pt2ScaleVec], stmt)))))                  letPRIM (vecVar, IR.T_VEC, IR.ADD_VEC, [pt1ScaleVec, pt2ScaleVec], stmt)))))
141    
142            (* This is a bit more complicated if we're trying to avoid accessing              | P.D_BOX{max, min} =>
143             * the vector variables themselves. Basically the way we can do it is to                  (* Extract the componentwise vector variables *)
144             * decompose the vector connecting min and max into the basis vectors,                  letPRIM("minX", IR.T_FLOAT, IR.EXTRACT_X, [psvToIRVar(env, min)], fn minX =>
145             * scale them independently, and then add them back together.                  letPRIM("maxX", IR.T_FLOAT, IR.EXTRACT_X, [psvToIRVar(env, max)], fn maxX =>
146             *                  letPRIM("minY", IR.T_FLOAT, IR.EXTRACT_Y, [psvToIRVar(env, min)], fn minY =>
147             * !FIXME! Actually do that. Don't have time right now...                  letPRIM("maxY", IR.T_FLOAT, IR.EXTRACT_Y, [psvToIRVar(env, max)], fn maxY =>
148             *)                  letPRIM("minZ", IR.T_FLOAT, IR.EXTRACT_Z, [psvToIRVar(env, min)], fn minZ =>
149              | P.D_BOX{max, min} => raise Fail "Cannot generate point in D_BOX."                  letPRIM("maxZ", IR.T_FLOAT, IR.EXTRACT_Z, [psvToIRVar(env, max)], fn maxZ =>
150    
151                    (* Find the distance in each component *)
152                    letPRIM("distX", IR.T_FLOAT, IR.SUB, [maxX, minX], fn distX =>
153                    letPRIM("distY", IR.T_FLOAT, IR.SUB, [maxY, minY], fn distY =>
154                    letPRIM("distZ", IR.T_FLOAT, IR.SUB, [maxZ, minZ], fn distZ =>
155    
156                    (* Get three random numbers for each of the components *)
157                    letPRIM("randX", IR.T_FLOAT, IR.RAND, [], fn randX =>
158                    letPRIM("randY", IR.T_FLOAT, IR.RAND, [], fn randY =>
159                    letPRIM("randZ", IR.T_FLOAT, IR.RAND, [], fn randZ =>
160    
161                    (* Scale the distances by these random numbers *)
162                    letPRIM("scaledX", IR.T_FLOAT, IR.MULT, [randX, distX], fn scaledX =>
163                    letPRIM("scaledY", IR.T_FLOAT, IR.MULT, [randY, distY], fn scaledY =>
164                    letPRIM("scaledZ", IR.T_FLOAT, IR.MULT, [randZ, distZ], fn scaledZ =>
165    
166                    (* Add them to the minimum vec in order to create a new vec inside
167                     * of the box.
168                     *)
169                    letPRIM("newX", IR.T_FLOAT, IR.ADD, [minX, scaledX], fn newX =>
170                    letPRIM("newY", IR.T_FLOAT, IR.ADD, [minY, scaledY], fn newY =>
171                    letPRIM("newZ", IR.T_FLOAT, IR.ADD, [minZ, scaledZ], fn newZ =>
172    
173                    (* Gen the vector *)
174                    letPRIM(vecVar, IR.T_VEC, IR.GEN_VEC, [newX, newY, newZ], stmt
175    
176                    )))))))))))))))))))
177    
178    
179              | P.D_TRIANGLE{pt1, pt2, pt3} =>              | P.D_TRIANGLE{pt1, pt2, pt3} =>
180                  letPRIM ("pt1ToPt2", IR.T_VEC, IR.SUB_VEC, [psvToIRVar(env, pt2), psvToIRVar(env, pt1)], fn pt1ToPt2 =>                  letPRIM ("pt1ToPt2", IR.T_VEC, IR.SUB_VEC, [psvToIRVar(env, pt2), psvToIRVar(env, pt1)], fn pt1ToPt2 =>
# Line 316  Line 344 
344              genVecVar("ps_col", env, colDomain, fn newCol =>              genVecVar("ps_col", env, colDomain, fn newCol =>
345              letSPRIM ("ps_size", IR.T_FLOAT, IR.RAND, [], fn newSize =>              letSPRIM ("ps_size", IR.T_FLOAT, IR.RAND, [], fn newSize =>
346              letSPRIM ("ps_isDead", IR.T_BOOL, IR.COPY, [IR.newConst("fbool", IR.C_BOOL false)], fn newIsDead =>              letSPRIM ("ps_isDead", IR.T_BOOL, IR.COPY, [IR.newConst("fbool", IR.C_BOOL false)], fn newIsDead =>
347                k(PS{pos = newPos, vel = newVel, size = newSize, isDead = newIsDead, color = newCol, dummy = IR.newConst("dmy", IR.C_FLOAT 0.01)}))))))                k(PS{pos = newPos,
348                       vel = newVel,
349                       size = newSize,
350                       isDead = newIsDead,
351                       color = newCol,
352                       dummy = IR.newConst("dmy", IR.C_FLOAT 0.01)})
353                )))))
354    
355      (* Find the normal at the given position of the particle for the specified      (* Find the normal at the given position of the particle for the specified
356       * domain. Note, that the particle doesn't necessarily need to be on the       * domain. Note, that the particle doesn't necessarily need to be on the

Legend:
Removed from v.870  
changed lines
  Added in v.873

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