UTS Data Arena
  • home
  • projects
  • dive in
  • about
  • calendar
UTS Data Arena
projectsdive inaboutcalendar

Wiki


No pages

Transferring the Data

The transmission of the geometry from MATLAB to Omegalib can be easily performed by sending specified commands followed by the geometry data. These commands consist of a a flag and a value as seen in the table below.

Flag Value Followed data Explanation
H_MODEL_NAME The name of the model required, must be the first
H_TYPE The type of the model, POINTS, TRIANGLES or QUADS required, must be the second
H_CAM_POS The camera position optional
H_CAM_UP The up-vector optional
D_VERTEX The number of vertices n vertices as nx3 matrix required
D_VERTEX_NORMAL The number of vertex normals vertex normals as nx3 matrix optional
D_COLOR The number of vertex colors vertex colors as nx4 matrix in RGBA(red, green, blue, alpha) in [0,1] format optional
D_FACE The number of faces m faces as mx3 matrix required for type TRIANGLES and QUADS
D_FACE_NORMAL The number of face normals face normals as mx3 matrix optional
H_CLEAR Clears the geometry that was sent last, optional
H_NEXT Prepares to add further primitives to the ModelGeometry, optional
H_ADD Adds the ModelGeometry to the queue, required

All commands are sent as char arrays! Therefore, the matrices containing vertices or faces must be converted to char arrays, e.g. with function num2str(…).

Start Transmission: H_MODEL_NAME, H_TYPE, H_CAM_POS, H_CAM_UP

The name and type of the model must be transmitted first. Otherwise the geometry cannot be built properly.

The camera position and the camera up-vector are not required, but it is highly recommended to use custom values. The default values for camera position and camera up-vector are [0 0 0] and [0 0 1], respectively.

Data Transmission: D_VERTEX, D_FACE, D_VERTEX_NORMAL, D_FACE_NORMAL, D_COLOR

To send geometry data like vertices or faces, the corresponding flag with the number of vectors as a value must be transmitted first. Afterwards, the matrices containing the geometry data can be sent row by row.

Finish Transmission: H_ADD, H_NEXT, H_CLEAR

The H_CLEAR command clears the current ModelGeometry object; hence new geometry data can be sent. Both H_ADD and H_NEXT commands add the current geometry data (the primitive set) to the ModelGeometry object. The H_ADD yields a new ModelGeometry object in the next transmission whereas the H_NEXT flag leads to adding future geometry data to the current ModelGeometry object. The H_NEXT flag should only be used with similar geometries.

That’s it. Want to see some examples?

Last updated 20 Aug 2019
MATLAB Module Tutorial
Examples