G3D Object – Giavapps 3D

 

G3D Object Initialization

 

g3d_object_init(G3DObjectIndex, G3DObjectTexture, G3DObjectStep, G3DObjectLength, G3DObjectShader) Initializes all G3D Object Local Variables and G3D Shader Uniforms for the instance.

G3DObjectIndex: A valid G3DObjectIndex obtained from g3d_object_load() function.
G3DObjectTexture: object texture obtained with GameMaker: Studio functions (background_get_texture() or sprite_get_texture() for example).
G3DObjectStep: starting object step for a G3D Animated Model (usually it’s 0).
G3DObjectLength: Refers to the animation length of a G3D Animated Model (it must be higher than G3DObjectStep).
G3DObjectShader: A valid G3DObjectShader (shader_giavapps_3d_model or shader_giavapps_3d_animation for example).

 

G3D Object Local Variables

 

After you called g3d_object init() function you can control the following Local Variables:

 

g3d_object_index You can set this variable to a valid G3DObjectIndex returned by g3d_object_load() functions. A G3DObjectIndex technically is just a ds_list which contains multiple frames of the animation or one frame for a non-animated model. This variable stores the id of the object drawn with g3d_object_draw_self() function.

 

g3d_object_texture This variable should be a valid Pointer to a Texture obtained with GameMaker: Studio functions (background_get_texture() or sprite_get_texture() for example). This variable determines the texture used with g3d_object_draw_self() function.

 

g3d_object_step Refers to the current Animation Step of a G3D Object. This variable is automatically updated when you call g3d_object_step_loop() or g3d_object_step_update() functions. It should be always less than g3d_object_length and determines the step (and the current frame) used for drawing the G3D Object.

 

g3d_object_length Indicates the Animation Length (duration in steps) of a G3D Object. Actually this can be considered as the Animation Speed. You can set this variable to an higher value for slowing down the animation or you can use a lower value for speeding up the animation. This variable should be always higher than g3d_object_step. It determines the length used with g3d_object_draw_self() function.

 

g3d_object_shader This variable should be a valid G3DObjectShader (shader_giavapps_3d_model or shader_giavapps_3d_animation for example). This variable stores the id of the shader used with g3d_object_draw_self() function.

 

g3d_object_frame This variable stores the current frame drawn with g3d_object_draw_self() function.

 

g3d_object_frames This variable stores the total number of frames of the G3D Object.

 

g3d_uniform_vertex_index This variable stores the Index of the Vertex Shader Uniform used with g3d_object_draw_self() function. This is for advanced users only.

 

g3d_uniform_vertex This is an array which stores all data passed through the G3DObjectShader used with g3d_object_draw_self() function. This is for advanced users only.

 

G3D Object Functions

 

g3d_object_step_loop() This function updates and loops the g3d_object_step variable automatically from 0 to g3d_object_length. This function is useful for updating and looping the Animation Step of the G3D Object.

 

g3d_object_step_update() This function increments the g3d_object_step value until it reaches the g3d_object_length value. This function gives you more control over the Animation Step of the G3D Object.

g3d_object_step_update() function returns one of the following values:

G3D_OBJECT_STEP_UPDATE Means that the g3d_object_step (the current step) has changed.

G3D_OBJECT_STEP_FRAME_UPDATE Means that the g3d_object_step (the current step) and the g3d_object_frame (the current frame) have changed.

G3D_OBJECT_STEP_END Means that the g3d_object_step (the current step) reached the g3d_object_length (the current length).

 

g3d_object_draw_self() This function draws a G3D Object using the Local Variables previously specified for the instance. This function is limited to G3D Object Local Variables assigned to the instance.

 

g3d_object_draw(G3DObjectIndex, G3DObjectTexture, G3DObjectStep, G3DObjectLength, G3DObjectShader, G3DUniformVertexIndex, G3DUniformVertex, G3DUniformFragmentIndex) Advanced users can use this function for having more control over the G3D Object drawn or for manually drawing multiple G3D Objects.

G3DObjectIndex: A valid G3D Object Index or g3d_object_index local variable.
G3DObjectTexture: A valid G3D Object Texture or g3d_object_texture local variable.
G3DObjectStep: A value lower than G3DObjectLength or g3d_object_step local variable.
G3DObjectLength: A value higher than G3DObjectStep or g3d_object_length local variable.
G3DObjectShader: A valid G3DObjectShader (shader_giavapps_3d_model or shader_giavapps_3d_animation for example).
G3DUniformVertexIndex: A valid Vertex Shader Uniform Index.
G3DUniformVertex: A valid G3DUniformVertex array which stores all data for Giavapps 3D Vertex Shader.
G3DUniformFragmentIndex: A valid Fragment Shader Uniform Index.

 

g3d_object_get_frame_current(G3DObjectIndex, G3DObjectStep, G3DObjectLength) This function calculates and returns the Current Frame of the specified G3D Object.

G3DObjectIndex: A valid G3D Object Index or g3d_object_index local variable.
G3DObjectStep: A value lower than G3DObjectLength or g3d_object_step local variable.
G3DObjectLength: A value higher than G3DObjectStep or g3d_object_length local variable.

 

g3d_object_get_frame_count(G3DObjectIndex) Returns the total number of Frames for the specified G3D Object.

G3DObjectIndex: A valid G3DObjectIndex or g3d_object_index local variable.

 

g3d_object_get_tweening_value(G3DObjectIndex, G3DObjectStep, G3DObjectLength) This function calculates and returns the Tweening Value (from 0 to 1).

G3DObjectIndex: A valid G3D Object Index or g3d_object_index local variable.
G3DObjectStep:
A value lower than G3DObjectLength or g3d_object_step local variable.
G3DObjectLength: A value higher than G3DObjectStep or g3d_object_length local variable.

 

Code Examples

 

Creating and Drawing a G3D Object

 

Create Event

 

var animation = g3d_object_load("animation.g3d", 1);//loads the .G3D file
g3d_object_init(animation, sprite_get_texture(sprite_texture,0), 0, room_speed*2, shader_giavapps_3d_animation);//initializes the instance

 

Step Event

 

g3d_object_step_loop();//updates and loops the animation

 

Room End

 

g3d_object_delete(g3d_object_index);//frees the memory occupied by the resource

 

Draw Event

 

GMS 2

g3d_transform_set(0, 0, 0, 0, 0, 0, 32, 32, 32);//you could apply your transformations here
g3d_object_draw_self
();//draws the G3D Object previously assigned to the instance
g3d_transform_set_identity();//you could reset transformations here
//With few lines of code you have your 3D Animated Model running!
//Giavapps 3D Extension will handle all the complicated tasks for you at an awesome speed!
//This documentation doesn’t cover how to set up a 3D Projection: please read the GameMaker Studio 2 manual for that!

GMS 1.4

d3d_transform_set_scaling(32, 32, 32);//you could apply your transformations here
g3d_object_draw_self
();//draws the G3D Object previously assigned to the instance
d3d_transform_set_identity();//you could reset transformations here
//With few lines of code you have your 3D Animated Model running!
//Giavapps 3D Extension will handle all the complicated tasks for you at an awesome speed!
//This documentation doesn’t cover how to set up a 3D Projection: please read the GameMaker Studio manual for that!

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*