• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

3D GMS2 - VERTEX BUILDER: element already written, must write the whole vertex first

G

GLTH

Guest
Hello. After several private projects, I thought it would be a good time to start tinkering in third dimension. For my first project, I'm trying to render a simple hexagonal block (6 sides + top + bottom), but after I try to test it, the compiler welcomes me with a message:
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object Block:

VERTEX BUILDER: element already written, must write the whole vertex first

at gml_Object_Block_Create_0 (line 39) - vertex_position_3d(v_buff_top, v_x[5], v_y[5], z + height);
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_Block_Create_0 (line 39)


I honestly have no idea what's wrong, especially that it crashes in create event during defining vertices. Here's create code:

vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_texcoord();
vertex_format_add_normal();
vertex_format_add_color();
v_format = vertex_format_end();

//top
v_buff_top = vertex_create_buffer();

vertex_begin(v_buff_top, v_format);
vertex_position_3d(v_buff_top, x, y, z + height);
vertex_position_3d(v_buff_top, v_x[5], v_y[5], z + height); < this line gives error?
vertex_position_3d(v_buff_top, v_x[0], v_y[0], z + height);
vertex_position_3d(v_buff_top, v_x[1], v_y[1], z + height);
vertex_position_3d(v_buff_top, v_x[2], v_y[2], z + height);
vertex_position_3d(v_buff_top, v_x[3], v_y[3], z + height);
vertex_position_3d(v_buff_top, v_x[4], v_y[4], z + height);
vertex_position_3d(v_buff_top, v_x[5], v_y[5], z + height);

vertex_end(v_buff_top);

v_buff_e = vertex_create_buffer();
(repeat for every side and bottom)

Is this because I'm on trial? Wanted to start tinkering in 3D in GMS2 because of reworked functions and it being faster according to people, but can't buy it at the moment. Then again, it would crash in one of earlier functions, right? I'm at a loss.

Thank you in advance.
 
L

Lonewolff

Guest
You need to write a vertex, then texcoord, then a normal, then a colour.

At this stage you are just firing vertices.
 
G

GLTH

Guest
Aah, that will be it. Simplified it by drawing a texture instead of a whole hexagonal cube, added texcoords, normals and colors and apart from messing up the order of vertices, it works.
What got me confused was actually a tutorial by DragoniteSpam and some posts on GMS reddit. Thank you for your help!
 
Top