Duke Wiki  logo

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3


Code Block
TCube>>initBounds
 boundSphere  := TBoundSphere  localPosition:  location radius:  (extent length)/2.

boundSphere  frame:  self.



The boundSphere is constructed using the TBoundSphere class with arguments of location - the same location described above - an the radius of the resulting sphere, which in this case will be the same as from the center of the box to any one of the corners. Finally, we set: boundSphere frame: self to have the new boundSphere point back to the original TFrame object.

5. We set the changed variable to be true to indicate that we have modified the shape of the TCube.

6. Finally, we send: self update to construct the structure of the TCube to prepare it to be rendered. The #update method, though somewhat long, does nothing more than constructs the vertices, faces, normals and texture coordinates required to render the new TCube.

Code Block
TCube>>#update




  dx dy  dz x y  z



dx  := extent x/2.0. dy  := extent y/2.0. dz  := extent z/2.0. x := location  x.

y  := location y. z  :=  location z.
 
vertices := Vector3Array  new:  8.

vertices at:  1  put:  (Vector3 x:  x+(dx negated)  y: y+(dy negated)  z: z+dz).

vertices at:  2  put:  (Vector3 x:  x+dx y:  y+(dy  negated)  z: z+dz).
 
vertices at:  3  put:  (Vector3 x:  x+dx y:  y+ dy  z: z+dz).

vertices at:  4  put:  (Vector3 x:  x+(dx negated)  y: y+dy  z: z+dz).

dz  := dz negated.

vertices at:  5  put:  (Vector3 x:  x+(dx negated)  y: y+(dy negated)  z: z+dz).

vertices at:  6  put:  (Vector3 x:  x+dx y:  y+(dy  negated)  z: z+