indexing description: "[ This interface represents 3d objects that can be drawn to the framebuffer. ]" date: "$Date$" revision: "$Revision$" deferred class EM_3D_OBJECT inherit GL_FUNCTIONS export {NONE} all end feature -- Commands draw is -- Draws the object to the framebuffer at the 'origin' position -- with a given rotation and scales it with the 'scale' vector do gl_push_matrix -- Translate to origin gl_translated (origin.x, origin.y, origin.z) -- Around which axis do we have to rotate? if angle_x /= 0 then gl_rotated (angle_x, 1, 0, 0) end if angle_y /= 0 then gl_rotated (angle_y, 0, 1, 0) end if angle_z /= 0 then gl_rotated (angle_z, 0, 0, 1) end -- Do we have to scale? if scale.x /= 1 or scale.y /= 1 or scale.z /= 1 then gl_scalef (scale.x, scale.y, scale.z) end draw_object gl_pop_matrix end set_origin (a_x: DOUBLE; a_y: DOUBLE; a_z: DOUBLE) is -- Specify the origin do origin.set (a_x, a_y, a_z) ensure origin_x_set: origin.x = a_x origin_y_set: origin.y = a_y origin_z_set: origin.z = a_z end set_scale (a_x: DOUBLE; a_y: DOUBLE; a_z: DOUBLE) is -- Specify the scale vector require a_x /= 0 a_y /= 0 a_z /= 0 do -- update bounding box width := width * a_x / scale.x height := height * a_y / scale.y depth := depth * a_z / scale.z scale.set (a_x, a_y, a_z) ensure scale_x_set: scale.x = a_x scale_y_set: scale.y = a_y scale_z_set: scale.z = a_z -- width_updated: width = old (width) * a_x / old (scale.x) -- height_updated: height = old (height) * a_y / old (scale.y) -- depth_updated: depth = old (depth) * a_z / old (scale.z) end set_rotation (a_x: DOUBLE; a_y: DOUBLE; a_z: DOUBLE) is -- Specify the rotation do angle_x := a_x angle_y := a_y angle_z := a_z ensure angle_x_set: angle_x = a_x angle_y_set: angle_y = a_y angle_z_set: angle_z = a_z end feature -- Status width: DOUBLE -- The size of the bounding box in x-direction height: DOUBLE -- The size of the bounding box in y-direction depth: DOUBLE -- The size of the bounding box in z-direction origin: EM_3D_VECT -- The start coordinates of the object scale: EM_3D_VECT -- The scale vector of the object angle_x: DOUBLE -- The angle between the x-axis and our direction angle_y: DOUBLE -- The angle between the y-axis and our direction angle_z: DOUBLE -- The angle between the z-axis and our direction feature {EM_3D_OBJECT} -- Deferred features to be implemented draw_object is -- Draws the object to the framebuffer at the current position deferred end invariant width_correct: width >= 0 height_correct: height >= 0 depth_correct: depth >= 0 scale_x_not_0: scale.x /= 0 scale_y_not_0: scale.y /= 0 scale_z_not_0: scale.z /= 0 end