» Back To Index
Demoniak3D/LUA API: primitives management functions
The
HYP_Primitive library performs general operation on primitives.
HYP_Primitive.SetBoxSize
HYP_Primitive.SetBoxVertexPosition
HYP_Primitive.GetBoxVertexPosition
HYP_Primitive.SetBoxVertexColor
HYP_Primitive.GetBoxVertexColor
HYP_Primitive.PushBoxVertices
HYP_Primitive.PopBoxVertices
HYP_Primitive.SetQuadVertexPosition
HYP_Primitive.GetQuadVertexPosition
HYP_Primitive.SetQuadVertexColor
HYP_Primitive.GetQuadVertexColor
HYP_Primitive.CreateLine
HYP_Primitive.SetLineVertexPosition
HYP_Primitive.GetLineVertexPosition
HYP_Primitive.SetLineVertexColor
HYP_Primitive.GetLineVertexColor
HYP_Primitive.CreateBox
HYP_Primitive.SetBoxVertexTexCoords
HYP_Primitive.GetBoxVertexTexCoords
HYP_Primitive.CreateQuad
HYP_Primitive.SetQuadVertexTexCoords
HYP_Primitive.GetQuadVertexTexCoords
HYP_Primitive.CreateTriangle
HYP_Primitive.SetTriangleVertexPosition
HYP_Primitive.GetTriangleVertexPosition
HYP_Primitive.SetTriangleVertexColor
HYP_Primitive.GetTriangleVertexColor
HYP_Primitive.SetTriangleVertexTexCoords
HYP_Primitive.GetTriangleVertexTexCoords
HYP_Primitive.CreateDisc
HYP_Primitive.SetDiscParams
HYP_Primitive.GetDiscParams
HYP_Primitive.CreateSphere
HYP_Primitive.SetSphereParams
HYP_Primitive.GetSphereParams
HYP_Primitive.Destroy
SetBoxSize
SetBoxSize allows to change the dimensions of a BOX type primitive
Syntax
HYP_Primitive.SetBoxSize( name | id, w, h, d );
- name - [STR127] - character string representing the primitive name as specified in the XML script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- w - [REAL] - width.
- h - [REAL] - height.
- d - [REAL] - depth.
PushBoxVertices
PushBoxVertices allows to save the 8 vertices of the box primtive before applying transformations.
In the current version, the backup stack has only one level. Therefore, the second call to HYP_PrimitiveBoxPushVertices()
will have no effect.
Syntax
HYP_Primitive.PushBoxVertices( name | id );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
Example
-- First restore the vertices.
--
HYP_Primitive.PopBoxVertices( "myBox" );
-- Save them.
--
HYP_Primitive.PushBoxVertices( "myBox" );
-- Apply the transformations:
index=0;
x=0.0;
y=15.0;
z=10.0;
HYP_Primitive.SetBoxVertexPosition("myBox", index, x, y, z );
PopBoxVertices
BoxPopVertices allows to restore the 8 vertices of the box primitive after applying tranformations.
In the current version, the backup stack has only one level. Therefore, the second call to HYP_PrimitiveBoxPopVertices()
will have no effect.
Syntax
HYP_Primitive.PopBoxVertices( name | id );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
SetBoxVertexPosition
SetBoxVertexPosition allows to change the position of a particular vertex of a BOX type primitive.
Syntax
HYP_Primitive.SetBoxVertexPosition( name | id, index, x, y, z );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- x - [REAL] - new X coordinate.
- y - [REAL] - new Y coordinate.
- z - [REAL] - new Z coordinate.
GetBoxVertexPosition
GetBoxVertexPosition allows to get the position of a particular vertex of a BOX type primitive.
Syntax
x, y, z = HYP_Primitive.GetBoxVertexPosition( name | id, index );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- x - [REAL] - X coordinate.
- y - [REAL] - Y coordinate.
- z - [REAL] - Z coordinate.
SetBoxVertexColor
SetBoxVertexColor allows to change the color of a particular vertex of a BOX type primitive.
Syntax
HYP_Primitive.SetBoxVertexColor( name | id, index, r, g, b, a );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
GetBoxVertexColor
GetBoxVertexColor allows to get the color of a particular vertex of a BOX type primitive.
Syntax
r, g, b, a = HYP_Primitive.GetBoxVertexColor( name | id, index );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
SetQuadVertexPosition
SetQuadVertexPosition allows to change the position of a particular vertex of a QUAD type primitive..
Syntax
HYP_Primitive.SetQuadVertexPosition( name | id, index, x, y, z );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- x - [REAL] - new X coordinate.
- y - [REAL] - new Y coordinate.
- z - [REAL] - new Z coordinate.
GetQuadVertexPosition
GetQuadVertexPosition allows to get the position of a particular vertex of a QUAD type primitive.
Syntax
x, y, z = HYP_Primitive.GetQuadVertexPosition( name | id, index );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- x - [REAL] - X coordinate.
- y - [REAL] - Y coordinate.
- z - [REAL] - Z coordinate.
SetQuadVertexColor
SetQuadVertexColor allows to change the color of a particular vertex of a QUAD type primitive.
Syntax
HYP_Primitive.SetQuadVertexColor( name | id, index, r, g, b, a );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
GetQuadVertexColor
GetQuadVertexColor allows to get the color of a particular vertex of a QUAD type primitive.
Syntax
r, g, b, a = HYP_Primitive.GetQuadVertexColor( name | id, index );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
CreateLine
CreateLine permet allows to create a line type primitive.
Syntax
id = HYP_Primitive.CreateLine( [name] );
- name - [STR127] - character string representing the name of the primitive. Optional.
- id - [INTEGER] - numerical identifier of the created primitive.
SetLineVertexPosition
SetLineVertexPosition permet de changer la position d'un des deux vertices d'une primitive ligne.
Syntax
HYP_Primitive.SetLineVertexPosition( name | id, index, x, y, z );
- name - [STR127] - character string representing the name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index to be changed. Value: 0 or 1.
- x - [REAL] - new X coordinate.
- y - [REAL] - new Y coordinate.
- z - [REAL] - new Z coordinate.
GetLineVertexPosition
GetLineVertexPosition allows to get the position of on of the two vertices of a line primitive.
Syntax
x, y, z = HYP_Primitive.GetLineVertexPosition( name | id, index );
- name - [STR127] - character string representing the name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index to be changed. Value: 0 or 1.
- x - [REAL] - X coordinate.
- y - [REAL] - Y coordinate.
- z - [REAL] - Z coordinate.
SetLineVertexColor
SetLineVertexColor allows to change the color of a LINE type primitive vertices.
Syntax
HYP_Primitive.SetLineVertexColor( name | id, index, r, g, b, a );
- name - [STR127] - character string representing the name of the primitive as specified in the xml script by the name attribute.
- id - [INTEGER] - numerical identifier of the object.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 7.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
GetLineVertexColor
GetLineVertexColor allows to get the color of a LINE type primitive vertices.
Syntax
r, g, b, a = HYP_Primitive.GetLineVertexColor( name | id, index );
- name - [STR127] - nom of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index to be changed. Value: 0 or 1.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
CreateBox
CreateBox allows to create a BOX type primitive.
Syntax
id = HYP_Primitive.CreateBox( [name] );
- name - [STR127] - character string representing the name of the primitive. Optional.
- id - [INTEGER] - numerical identifier of the created primitive.
SetBoxVertexTexCoords
SetBoxVertexTexCoords allows to change the u and v texture coordinates of a BOX type primitive.
Syntax
HYP_Primitive.SetBoxVertexTexCoords( name | id, index, texture_unit, u, v );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index. Value: 0 to 8.
- texture_unit - [INTEGER] - texture unit. Value: 0 to 8.
- u - [REAL] - new u coordinate.
- v - [REAL] - new v coordinate.
GetBoxVertexTexCoords
GetBoxVertexTexCoords allows to get the u and v texture coordinates of the vertices of a BOX type primitive.
Syntax
u, v = HYP_Primitive.GetBoxVertexTexCoords( name | id, index, texture_unit );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index. Value: 0 to 8.
- texture_unit - [INTEGER] - texture unit. Value: 0 to 8.
- u - [REAL] - new u coordinate.
- v - [REAL] - new v coordinate.
CreateQuad
CreateQuad allows to create a QUAD type primitive.
Syntax
id = HYP_Primitive.CreateQuad( [name] );
- name - [STR127] - character string representing the name of the primitive. Optional.
- id - [INTEGER] - numerical identifier of the created primitive.
SetQuadVertexTexCoords
SetQuadVertexTexCoords allows to change the u and v texture coordinates of a QUAD type primitive.
Syntax
HYP_Primitive.SetQuadVertexTexCoords( name | id, index, texture_unit, u, v );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index. Value: 0 to 4.
- texture_unit - [INTEGER] - texture unit. Value: 0 to 8.
- u - [REAL] - new u coordinate.
- v - [REAL] - new v coordinate.
GetQuadVertexTexCoords
GetQuadVertexTexCoords allows to get the u and v texture coordinates of the vertices of a QUAD type primitive.
Syntax
u, v = HYP_Primitive.GetQuadVertexTexCoords( name | id, index, texture_unit );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index. Value: 0 to 4.
- texture_unit - [INTEGER] - texture unit. Value: 0 to 8.
- u - [REAL] - new u coordinate.
- v - [REAL] - new v coordinate.
CreateTriangle
CreateTriangle allows to create a TRIANGLE type primitive.
Syntax
id = HYP_Primitive.CreateTriangle( [name] );
- name - [STR127] - character string representing the name of the primitive. Optional.
- id - [INTEGER] - numerical identifier of the created primitive.
SetTriangleVertexTexCoords
SetTriangleVertexTexCoords allows to change the u and v texture coordinates of a TRIANGLE type primitive.
Syntax
HYP_Primitive.SetTriangleVertexTexCoords( name | id, index, texture_unit, u, v );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index. Value: 0 to 3.
- texture_unit - [INTEGER] - texture unit. Value: 0 to 8.
- u - [REAL] - new u coordinate.
- v - [REAL] - new v coordinate.
GetTriangleVertexTexCoords
GetTriangleVertexTexCoords allows to get the u and v texture coordinates of the vertices of a TRIANGLE type primitive.
Syntax
u, v = HYP_Primitive.GetTriangleVertexTexCoords( name | id, index, texture_unit );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index. Value: 0 to 2.
- texture_unit - [INTEGER] - texture unit. Value: 0 to 8.
- u - [REAL] - new u coordinate.
- v - [REAL] - new v coordinate.
SetTriangleVertexPosition
SetTriangleVertexPosition allows to change the position of a TRIANGLE type PRIMITIVE.
Syntax
HYP_Primitive.SetTriangleVertexPosition( name | id, index, x, y, z );
- name - [STR127] - character string representing the name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index à changer. Value: 0 to 2.
- x - [REAL] - new X coordinate.
- y - [REAL] - new Y coordinate.
- z - [REAL] - new Z coordinate.
GetTriangleVertexPosition
GetTriangleVertexPosition allows to get the vertices position of a TRIANGLE type PRIMITIVE.
Syntax
x, y, z = HYP_Primitive.GetTriangleVertexPosition( name | id, index );
- name - [STR127] - character string representing the name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - vertex index to be changed. Value: 0 to 2.
- x - [REAL] - X coordinate.
- y - [REAL] - Y coordinate.
- z - [REAL] - Z coordinate.
SetTriangleVertexColor
SetTriangleVertexColor allows to change the vertice color of a TRIANGLE type primitive.
Syntax
HYP_Primitive.SetTriangleVertexColor( name | id, index, r, g, b, a );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 2.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
GetTriangleVertexColor
GetTriangleVertexColor allows to get the vertice color of a TRIANGLE type primitive.
Syntax
r, g, b, a = HYP_Primitive.GetTriangleVertexColor( name | id, index );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- index - [INTEGER] - index of the vertex to be changed. Value ranging between 0 and 2.
- r - [CLAMPED_REAL] - red component of the color.
- g - [CLAMPED_REAL] - green component of the color.
- b - [CLAMPED_REAL] - blue component of the color.
- a - [CLAMPED_REAL] - alpha component of the color.
CreateDisc
CreateDisc allows to create a DISC type primitive.
Syntax
id = HYP_Primitive.CreateDisc( [name] );
- name - [STR127] - character string representing the name of the primitive. Optional.
- id - [INTEGER] - numerical identifier of the created primitive.
SetDiscParams
SetDiscParams allows to change the parameters of a DISC type primitive.
Syntax
HYP_Primitive.SetDiscParams( name | id, inner_radius, outer_radius, num_sides );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- inner_radius - [REAL] - inner radius of the disc.
- outer_radius - [REAL] - outer radius of the disc.
- num_sides - [INTEGER] - number of segments that form the circumference of the disc.
GetDiscParams
GetDiscParams allows to get the parameters of a DISC type primitive.
Syntax
inner_radius, outer_radius, num_sides = HYP_Primitive.GetDiscParams( name | id );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- inner_radius - [REAL] - inner radius of the disc.
- outer_radius - [REAL] - outer radius of the disc.
- num_sides - [INTEGER] - number of segments that form the circumference of the disc.
CreateSphere
CreateSphere allows to create a SPHERE type primitive.
Syntax
id = HYP_Primitive.CreateSphere( [name] );
- name - [STR127] - character string representing the name of the primitive. Optional.
- id - [INTEGER] - numerical identifier of the created primitive.
SetSphereParams
SetSphereParams allows to change the parameters of a SPHERE type primitive.
Syntax
HYP_Primitive.SetSphereParams( name | id, inner_radius, outer_radius, num_slices );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- inner_radius - [REAL] - inner radius of the sphere.
- outer_radius - [REAL] - outer radius of the sphere.
- num_slices - [INTEGER] - number of disc that form the sphere.
GetSphereParams
GetSphereParams allows to get the parameters of a SPHERE type primitive.
Syntax
inner_radius, outer_radius, num_sides = HYP_Primitive.GetSphereParams( name | id );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.
- inner_radius - [REAL] - inner radius of the sphere.
- outer_radius - [REAL] - outer radius of the sphere.
- num_slices - [INTEGER] - number of disc that form the sphere.
Destroy
Destroy allows to destroy any kind of primitive that has been statically ceated in the XML script or
dynamically in the LUA code.
Syntax
HYP_Primitive.Destroy( name | id );
- name - [STR127] - name of the primitive.
- id - [INTEGER] - numerical identifier of the primitive.