Class: avatarParts
API
a. createNameTag (name, len, x, y, z) FUNC: creates a nametag at given (x,y,z) + name : string to be written + len : length of nametag + x,y,z: x-y-z coordinate of center of name tag b. initRMatrix () FUNC: initialize rotation matrix, romx,romy, and romz c. setAngleComplex(xangle, yangle, zangle) FUNC: rotates along xangle, yangle and zangle using romz, romy, and romz + xangle, yangle, zangle: input angles d. setAngle (angle, dir) FUNC: simple but limited way to do the same thing as setAngleComplex()... legacy method + angle: angle to be rotated by + dir : string either "s" for side or "fb" for forward-backSource Code
class avatarParts ( romx, romy, romz #rotation matrix for setAngleComplex() ) method initRMatrix() romx:=Rotate(0,0,0,0) romy:=Rotate(0,0,0,0) romz:=Rotate(0,0,0,0) end method setAngleComplex(xangle, yangle, zangle) romx.angle:=xangle romy.angle:=yangle romz.angle:=zangle romx.x:=1 romx.y:=0 romx.z:=0 romy.x:=0 romy.y:=1 romy.z:=0 romz.x:=0 romz.y:=0 romz.z:=1 end # # setAngle (Angle, Dir) # Purpose: to move the arm and hand # method setAngle(angle, dir) # # fb stands for forward-back # s stands for side-side # if dir == "fb" then { romx.angle:=angle # set the angle romx.x:=1 # update the angle of the arm romx.y:=0 # to be rotated by; along X- romx.z:=0 # axis } else if dir == "s" then { romz.angle:=angle # set the angle romz.x:=0 # update the angle of the arm romz.y:=0 # along Z-axis romz.z:=1 } end method createNameTag(name,len,x,y,z) local i, txcoords, tmp, interval, ls i:=0 ls:=len/*name interval:=-(x+len/2) WAttrib("texmode=off") while i < *name do { txcoords := [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0 ] tmp := txcoords[1] || "," || txcoords[2] || "," || txcoords[3] || "," tmp := tmp || txcoords[4] || "," || txcoords[5] || "," || txcoords[6] || "," tmp := tmp || txcoords[7] || "," || txcoords[8] coords := [ 0 , 0 , 0, 0 , ls, 0, ls, ls, 0, ls, 0 , 0 ] PushMatrix() Translate(interval,y,z) WAttrib("texmode=on","texture=.\\letters\\"||name[i+1]||".GIF", "texcoord="||tmp) FillPolygon ! coords WAttrib("texmode=off") DrawCube(ls/2,ls/2,-ls/2-0.001,ls) PopMatrix() interval:=interval+ls i:=i+1 } WAttrib("texmode=off") end end