Class: head


API

Source Code

class head : avatarParts ( headx,heady,headz,headr, # Head coodinate, radius of the head neckx,necky,neckz,neckh,neckt,neckb, # Neck coor. and other info. on neck m1,m2,m3,m4, # stuff for talking effect counter, # Internal counter to manage talking on-off romx,romy, romz, # rotation matrix for x and z axis ch ) method render(face, color, choice) ch:=choice counter:=0 # Neck if (color[*color-3:*color+1] == ".gif")|(color[*color-3:*color+1] == ".GIF") then WAttrib("texmode=on","texture="||color) else { WAttrib("texmode=off") Fg("ambient "||color)} DrawCylinder(neckx, necky, neckz, neckh, neckt, neckb) # Head PushMatrix() if (color[*color-3:*color+1] == ".gif")|(color[*color-3:*color+1] == ".GIF") then WAttrib("texmode=on","texture="||color) else { WAttrib("texmode=off") Fg("ambient "||color)} # # Egg Shape or Putting picture on a box # if choice == 2 then { PushMatrix() initRMatrix() WAttrib("texmode=on","texture="||face) Rotate(270,1,0,0) Scale(1,1,1.2) PushMatrix() Translate(headx,0,0.55) DrawSphere(0, 0, 0, headr) WAttrib("texmode=off") Fg("ambient red") Rotate(90,1,0,0) m1:=DrawCylinder(-headx,-heady+heady*0.7,0,0.03,0.01,0.01) m2:=DrawCylinder(-headx,-heady+heady*0.7,0,0.05,0.015,0.015) m3:=DrawCylinder(-headx,-heady+heady*0.7,0,0.08,0.02,0.02) m4:=DrawCylinder(-headx,-heady+heady*0.7,0,0.12,0.03,0.03) PopMatrix() PopMatrix() } else { PushMatrix() Translate(headx, heady, headz) initRMatrix() DrawSphere(0,0,0, headr) WAttrib("texmode=on","texture="||face,"texcoord=auto") # Face cube 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] sz := headr*1.3 / 2.0 coords := [ 0 , 0, 0, 0 , 2 * sz, 0, 2* sz , 2 * sz, 0, 2* sz , 0, 0 ] # Face polygon # formerly a cube PushMatrix() Translate( -sz, -heady/2, headr ) WAttrib("texmode=on", "texture="|| face , "texcoord="||tmp) FillPolygon ! coords WAttrib("texmode=off") PopMatrix() Fg("ambient red") m1:=DrawCylinder(-headx,-heady+heady*0.7,0,0.03,0.01,0.01) m2:=DrawCylinder(-headx,-heady+heady*0.7,0,0.05,0.015,0.015) m3:=DrawCylinder(-headx,-heady+heady*0.7,0,0.08,0.02,0.02) m4:=DrawCylinder(-headx,-heady+heady*0.7,0,0.12,0.03,0.03) PopMatrix() } PopMatrix() end method talkingOn() if counter=0 then { if ch == 1 then { m1.z:=0.5 m2.z:=0.55 m3.z:=0.6 m4.z:=0.68 } else { m1.z:=0.5 m2.z:=0.55 m3.z:=0.6 m4.z:=0.68 } counter:=1} else { if ch == 1 then { m1.z:=0 m2.z:=0 m3.z:=0 m4.z:=0 } else { m1.z:=0 m2.z:=0 m3.z:=0 m4.z:=0 } counter:=0} end method talkingOff() if ch == 1 then { m1.z:=0 m2.z:=0 m3.z:=0 m4.z:=0 } else { m1.z:=0 m2.z:=0 m3.z:=0 m4.z:=0 } counter:=0 end initially() headx := 0 heady := 0.6 headz := 0 headr := 0.5 neckx := 0 necky := 0 neckz := 0 neckh := 0.1 neckt := 0.1 neckb := 0.1 end