G3D Particle – Giavapps 3D

G3D Particle Creation

 

g3d_particle_start() Starts creating a new G3D Particle and returns a G3DParticleIndex which you can use with other functions.

 

g3d_particle_add(G3DParticleIndex, Delay, MotionSpeed, RotationSpeed, DirectionXY, DirectionZ, GravityX, GravityY, GravityZ) Adds a new particle to the specified G3D Particle.

G3DParticleIndex: A valid G3DParticleIndex obtained from g3d_particle_start() function.
Delay: delay (in steps) which indicates when the particle should start moving
MotionSpeed: motion speed of the particle or 0 for not moving.
RotationSpeed: rotation speed of the particle or 0 for not rotating
DirectionXY: direction of the particle (in degrees) along the X and Y axis.
DirectionZ: direction of the particle (in degrees) along the Z axis.
GravityX: gravity of the particle along the X axis or 0 for not applying gravity along this axis.
GravityY: gravity of the particle along the Y axis or 0 for not applying gravity along this axis.
GravityZ: gravity of the particle along the Z axis or 0 for not applying gravity along this axis.

 

g3d_particle_end(G3DParticleIndex) Ends the creation of a new G3D Particle.

G3DParticleIndex: A valid G3DParticleIndex obtained from g3d_particle_start() function.

 

g3d_particle_delete(G3DParticleIndex) Frees memory occupied by the specified G3DParticleIndex.

G3DParticleIndex: A valid G3DParticleIndex obtained from g3d_particle_start() function.

 

G3D Particle Initialization

 

g3d_particle_init(G3DParticleIndex, G3DParticleTexture, G3DParticleStep, G3DParticleLength, G3DParticleStatus, G3DParticleShader) Initializes all G3D Particle Local Variables and G3D Shader Uniforms for the instance.

G3DParticleIndex: A valid G3DParticleIndex obtained from g3d_particle_start() function.
G3DParticleTexture: Particle texture obtained with GameMaker: Studio functions (background_get_texture() or sprite_get_texture() for example).
G3DParticleStep: Starting particle step for a G3D Particle (usually it’s 0).
G3DParticleLength: Length (duration in steps) for a G3D Particle (it must be higher than G3DParticleStep).
G3DParticleStatus: status of the particle.
G3DParticleShader: A valid G3DObjectShader (shader_giavapps_3d_particle for example).

G3DParticleStatus can be one of the following values:

G3D_PARTICLE_STATUS_PAUSE Means that G3D Particle is paused.

G3D_PARTICLE_STATUS_PLAY Means that G3D Particle is playing.

 

G3D Particle Local Variables

 

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

 

g3d_particle_index You can set this variable to a valid G3DParticleIndex returned by g3d_particle_start() functions. A G3DParticleIndex technically is a vertex buffer which contains data about the G3D Particle. This variable stores the id of the particle drawn with g3d_particle_draw_self() function.

 

g3d_particle_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_particle_draw_self() function.

 

g3d_particle_status Refers to the current Status of a G3D Particle. This variable should be set to G3D_PARTICLE_STATUS_PLAY or G3D_PARTICLE_STATUS_PAUSE and controls if the step value of the G3D Particle should increase or not.

 

g3d_particle_shader This variable should be a valid G3DParticleShader (shader_giavapps_3d_particle for example). This variable stores the id of the shader used with g3d_particle_draw_self() function.

 

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

 

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

 

G3D Particle Functions

 

g3d_particle_step_update() This function updates and increments the particle step value (only if the particle is not paused).

 

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

 

g3d_particle_draw(G3DParticleIndex, G3DParticleTexture, G3DParticleShader, G3DUniformVertexIndex, G3DUniformVertex) Advanced users can use this function for having more control over the G3D Particle drawn or for manually drawing multiple G3D Particles.

G3DParticleIndex: A valid G3DParticleIndex obtained from g3d_particle_start() function.
G3DParticleTexture: Particle texture obtained with GameMaker: Studio functions (background_get_texture() or sprite_get_texture() for example).
G3DParticleShader: A valid G3DObjectShader (shader_giavapps_3d_particle for example).
G3DUniformVertexIndex: A valid Vertex Particle Shader Uniform Index.
G3DUniformVertex: A valid G3DUniformVertex array which stores all data for Giavapps 3D Vertex Particle Shader.

 

g3d_particle_set_start_colour(Object, Red, Green, Blue, Alpha) Sets the starting colour for the given G3D Particle.

Object: A valid GameMaker: Studio Object ID.
Red: Red component value from 0 to 1+.
Green: Green component value from 0 to 1+.
Blue: Blue component value from 0 to 1+.
Alpha: Alpha component value from 0 to 1+.

 

g3d_particle_get_start_colour(Object, RedGreenBlueOrAlpha) Returns the starting colour assigned to the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.
RedGreenBlueOrAlpha: colour component to return.

RedGreenBlueOrAlpha argument can be one of the following values:

G3D_RED Returns the Red component.

G3D_GREEN Returns the Green component.

G3D_BLUE Returns the Blue component.

G3D_ALPHA Returns the Alpha component.

 

g3d_particle_set_start_scale(Object, X, Y) Sets the starting scale for the given G3D Particle.

Object: A valid GameMaker: Studio Object ID.
X: Scale along the X axis.
Y: Scale along the Y axis.

 

g3d_particle_get_start_scale(Object, XOrY) Returns the starting scale assigned to the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.
XOrY: indicates the value to return.

XOrY argument can be one of the following values:

G3D_X Returns the scaling along the X axis.

G3D_Y Returns the scaling along the Y axis.

 

g3d_particle_set_end_colour(Object, Red, Green, Blue, Alpha) Sets the ending colour for the given G3D Particle.

Object: A valid GameMaker: Studio Object ID.
Red: Red component value from 0 to 1+.
Green: Green component value from 0 to 1+.
Blue: Blue component value from 0 to 1+.
Alpha: Alpha component value from 0 to 1+.

 

g3d_particle_get_end_colour(Object, RedGreenBlueOrAlpha) Returns the ending colour assigned to the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.
RedGreenBlueOrAlpha: colour component to return.

RedGreenBlueOrAlpha argument can be one of the following values:

G3D_RED Returns the Red component.

G3D_GREEN Returns the Green component.

G3D_BLUE Returns the Blue component.

G3D_ALPHA Returns the Alpha component.

 

g3d_particle_set_end_scale(Object, X, Y) Sets the ending scale for the given G3D Particle.

Object: A valid GameMaker: Studio Object ID.
X: Scale along the X axis.
Y: Scale along the Y axis.

 

g3d_particle_get_end_scale(Object, XOrY) Returns the ending scale assigned to the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.
XOrY: indicates the value to return.

XOrY argument can be one of the following values:

G3D_X Returns the scaling along the X axis.

G3D_Y Returns the scaling along the Y axis.

 

g3d_particle_play(Object) Plays the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.

 

g3d_particle_pause(Object) Pauses the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.

 

g3d_particle_playing(Object) Returns true if the given G3D Particle is playing or false otherwise.

Object: A valid GameMaker: Studio Object ID.

 

g3d_particle_paused(Object) Returns true if the given G3D Particle is paused or false otherwise.

Object: A valid GameMaker: Studio Object ID.

 

g3d_particle_set_step(Object, Step) Sets the current step value for the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.
Step: Particle step for a G3D Particle.

 

g3d_particle_get_step(Object) Returns the current step value for the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.

 

g3d_particle_set_length(Object, Length) Sets the length for the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.
Length: Length (duration in steps) for a G3D Particle.

 

g3d_particle_get_length(Object) Returns the length of the specified G3D Particle.

Object: A valid GameMaker: Studio Object ID.

 

Code Examples

 

Creating a G3D Particle

 

Create Event

 

//CREATES A RANDOM PARTICLE EFFECT

z = 0;//Sets the Z coordinate
g3d_particle_index = g3d_particle_start();//Starts creating a new G3D Particle

//Adds 60 particles to the G3D Particle
for(var i=0; i<60; i++)
{
g3d_particle_add(g3d_particle_index, i, random(0.3), random_range(-0.3, 0.3), irandom_range(0, 360), irandom_range(0, 360), random(0.1), random(0.1), random(0.1));
}

g3d_particle_end(g3d_particle_index);//Ends the creation of the G3D Particle

//Initializes the G3D Particle object
g3d_particle_init(g3d_particle_index, sprite_get_texture(sprite_texture, 0), 0, room_speed, G3D_PARTICLE_STATUS_PLAY, shader_giavapps_3d_particle);

//Sets starting and ending effects
g3d_particle_set_start_colour(id, 1, 0, 0, 1);
g3d_particle_set_start_scale(id, 1, 1);
g3d_particle_set_end_colour(id, 1, 1, 1, 0);
g3d_particle_set_end_scale(id, 0, 0);

 

Step Event

 

g3d_particle_step_update();//Updates the particles

 

Room End

 

g3d_particle_delete(g3d_particle_index);//frees the memory occupied by the resource

 

Draw Event

GMS 2

g3d_transform_set(x, y, z, 0, 0, 0, 32, 32, 32);//Sets transformation
g3d_particle_draw_self();//Draws the G3D Particle
g3d_transform_set_identity();//Resets transformations

GMS 1.4

d3d_transform_set_scaling(32, 32, 32);//Sets scaling
d3d_transform_add_translation(x, y, z);//Sets translation
g3d_particle_draw_self();//Draws the G3D Particle
d3d_transform_set_identity();//Resets transformations

 

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.

Comments are closed.