Saturday, December 31, 2016

Tutorial Post 3: Data Organisation.

Tutorial Post 3: Data Organisation.


Data organisation determines what can be designed.
Consider the following simple example with a model consisting of a single line segment and a single triangle:
Mki3d is written in JavaScript, so its data are being saved in JSON format:

The shape of the designed object is defined by "model". The model consists of "segments" and  "triangles":

  • "segments" is an array of elements, where each element is an array of two endpoints. 
  •  "triangles" is an array of elements, where each element is an array of three endpoints. 
Each endpoint has following attributes:
  • "position" - array of X,Y,Z coordinates in the model space
  • "color" - array of R,G,B color components of the endpoint
  • "set" - integer index of the set (used for auxiliary classification of the endpoints)
Note that each endpoint has its own attributes and is independent on other endpoints. A segment or triangle can have different colors and different set indices at different endpoints. Also the endpoints having the same position are not considered to be the same 'vertex'.

Besides "model" there are some other data:

  • "view" describes the observer's position and orientation relative to the model space. From the observer's point of view the "focusPoint" of the model is first moved to oberver, then the model is rotated by rotation matrix, and finally the model is shifted by  "screenShift" vector.
  • "projection" defines the so called 'view frustum' - parameters of perspective projection. 
  • "backgroundColor"  is RGB background color.
  • "light" defines direction vector of diffuse lighting component and what is the fraction of ambient light component. (Light is white and-in the editor-the diffuse directional light is emited in both  directions: "vector" and  -"vector".)
  • "cursor" describes the position and color of the cursor. Since markers are used for inserting segments and triangles together with the cursor, they are listed inside "cursor" object. 
  • "clipMaxVector", "clipMinVector",  define the corners of clipping box.
  • "set" stores the value of "current" set index.

No comments:

Post a Comment