Primitive Object Functions

From Danmakufu Wiki
Jump to: navigation, search

ObjPrim_Create

Arguments:
 1) object type (real)

Returns: object ID (real)

Creates a Primitive object. Object types are:

  • OBJ_PRIMITIVE_2D: primitive (triangle) in the 2D space
  • OBJ_SPRITE_2D: rectangle in the 2D space (usable by the ObjSprite2D_ functions).
  • OBJ_SPRITE_LIST_2D: list of rectangles in the 2D space (usable by the ObjSpriteList2D_ functions).
  • OBJ_PRIMITIVE_3D: primitive (triangle) in the 3D space
  • OBJ_SPRITE_3D: rectangle in the 3D space (usable by the ObjSprite3D_ functions).

ObjPrim_SetPrimitiveType

Arguments:
 1) object ID (real)
 2) primitive type (real)

Sets the vertex layout for the object among the following:

  • PRIMITIVE_TRIANGLELIST
  • PRIMITIVE_TRIANGLESTRIP
  • PRIMITIVE_TRIANGLEFAN

Pictures of primitive types

In addition, there are three undocumented vertex layouts:

  • PRIMITIVE_LINELIST
  • PRIMITIVE_LINESTRIP
  • PRIMITIVE_POINT_LIST

ObjPrim_SetVertexCount

Arguments:
 1) object ID (real)
 2) number of vertices (real)

Sets the number of vertices the object contains.

ObjPrim_GetVertexCount

Arguments:
 1) object ID (real)

Returns: vertices count (real)

Returns the number of vertices the object contains.

ObjPrim_SetTexture

Arguments:
 1) object ID (real)
 2) path of the texture file (char)

Sets the specified texture on the object. Loads the texture file if it has not already been loaded.

ObjPrim_SetVertexPosition

Arguments:
 1) object ID (real)
 2) vertex index (real)
 3) x-coordinate (real)
 4) y-coordinate (real)
 5) z-coordinate (real)

Sets the position of the specified vertex.

ObjPrim_GetVertexPosition

Arguments:
 1) object ID (real)
 2) vertex index (real)

Returns the position of the specified vertex in an array [x,y,z].

ObjPrim_SetVertexUV

Arguments:
 1) object ID (real)
 2) vertex index (real)
 3) texture x-coordinate (real)
 4) texture y-coordinate (real)

Sets the UV-coordinates for the specified vertex. The value for the coordinates must be in the range (0.0-1.0).

For instance, if you want a vertex to be at the center-top of a 512*512 texture, you have to set x to 0.5 and y to 1.0.

As it may be troublesome to convert pixels into a 0.0-1.0 value, ObjPrim_SetVertexUVT is recommended.

ObjPrim_SetVertexUVT

Arguments:
 1) object ID (real)
 2) vertex index (real)
 3) texture x-coordinate (real)
 4) texture y-coordinate (real)

Sets the UV-coordinates for the specified vertex. You must set the object's texture using ObjPrim_SetTexture beforehand.

ObjPrim_SetVertexColor

Arguments:
 1) object ID (real)
 2) vertex index (real)
 3) R (real)
 4) G (real)
 5) B (real)

Sets the color of the specified vertex (0-255).

ObjPrim_SetVertexAlpha

Arguments:
 1) object ID (real)
 2) vertex index (real)
 3) alpha value (real)

Sets the alpha value of the specified vertex (0-255).