3D [RESOLVED]3D: how use Vertex?

C

cambalinho

Guest
the Light, the Models, the Drawing and Transformations have, too, Vertex. but how use them?
i never use them, i don't know what them.
 
D

dannyjenn

Guest
The overall idea is:
- A vertex is a point with an x, y, and z value. By changing the x, y, and z then you can move the vertex.
- You can join three vertices together to make a triangle. You can then join two or more triangles together to make the other polygons, or four or more triangles together to make the polyhedra or whatever model you want to make. (Pretty sure that GameMaker requires that you work with triangles, which is a lot different from real life. In real life a simple cube is made up of 6 squares, but in GameMaker it needs to be made up of 12 triangles.)
- Lastly, you can translate/rotate/scale the triangles/polygons/polyhedra/models in all three dimensions by changing the x, y, and z of each of its three vertices by the correct value. Or you can distort the triangle/polygon/polyhedron/model by changing only some of the vertices' x, y, and z values.

But I personally haven't worked with these things enough to give you any sort of actual sample code.
 
Last edited by a moderator:
Don't forget there are also line and point primitives, in addition to triangle primitivies.

Anyway, it's a pretty big topic, is there something specific that you want to know about?
 
C

cambalinho

Guest
i'm trying draw a rectangle with a color, but i can't see it(i even tryied change the Alpha without sucess).
Code:
d3d_primitive_begin(pr_pointlist);
d3d_vertex_colour(x,y,z,c_yellow,1);
d3d_vertex_colour(x,y,z+p,c_yellow,1);
d3d_vertex_colour(x,y+h,z+p,c_yellow,1);
d3d_vertex_colour(x,y+h,z,c_yellow,1);
d3d_vertex_colour(x,y,z,c_yellow,1);
d3d_primitive_end();
'p' it's the Z size.
what i'm doing wrong?
 
D

dannyjenn

Guest
Also, just pointing out, if you're using GMS2, there are no d3d functions anymore.
 
C

cambalinho

Guest
i'm using GMS1.
to be honesty, i will never understand why they 'give up' on 3D :(

finally it's working, i have notice that for all vertices, we must create 2 Vertex:
Code:
d3d_primitive_begin(pr_linelist);

//vertical left line:
d3d_vertex_colour(x,y,z,c_yellow,1); //start line
d3d_vertex_colour(x,y,z+p,c_yellow,1);//end line

//horizontal up line:
d3d_vertex_colour(x,y,z+p,c_yellow,1);
d3d_vertex_colour(x,y+h,z+p,c_yellow,1);

//vertical right line:
d3d_vertex_colour(x,y+h,z+p,c_yellow,1);
d3d_vertex_colour(x,y+h,z,c_yellow,1);

//horizontal bottom line:
d3d_vertex_colour(x,y+h,z,c_yellow,1);
d3d_vertex_colour(x,y,z,c_yellow,1);

d3d_primitive_end();
the pr_pointlist, just draw the points nothing more:
Code:
d3d_primitive_begin(pr_pointlist);

d3d_vertex_colour(x,y,z,c_yellow,1);
d3d_vertex_colour(x,y,z+p,c_yellow,1);

//d3d_vertex_colour(x,y,z+p,c_yellow,1);
d3d_vertex_colour(x,y+h,z+p,c_yellow,1);

//d3d_vertex_colour(x,y+h,z+p,c_yellow,1);
d3d_vertex_colour(x,y+h,z,c_yellow,1);

//d3d_vertex_colour(x,y+h,z,c_yellow,1);
d3d_vertex_colour(x,y,z,c_yellow,1);
//like you see i just commented the double line code
d3d_primitive_end();
these is the Draw code... but these work on same way for light and others, right?
 
i have notice that for all vertices, we must create 2 Vertex:
I hate to sound like a jerk repeating myself, but you should once again look up the pr_* constants in the manual. That's expected behaviour for the type of primitive you're creating :p

If you were to use a strip instead of a list, you wouldn't need to double up on the vertices. The difference between a list and a strip is like using four draw_line() functions versus draw_rectangle() respectively.
 
C

cambalinho

Guest
hey. i have notice that you are realy help me. but don't felt on that way by 2 reasons:
1 - i'm Portuguese, but i'm learning English by experience;
2 - i never worked with Vertex.
the Game Maker Studio tutorial is more technic than explicit :(
thanks for all to all.
thank you so much
 
D

dannyjenn

Guest
i'm using GMS1.
to be honesty, i will never understand why they 'give up' on 3D :(
They didn't give up on 3D. They just changed the way it's done (no more d3d, but now there are vertex buffers and stuff). No idea why they changed it, but I'm guessing the new way is more efficient or more powerful or something.
I suppose I'm lucky I haven't bothered to learn 3D yet, because now I don't need to go back and relearn anything.
 
C

cambalinho

Guest
to be honest i love the Game Maker, because we can use actions(maybe create more) and GML.
we can create games in little hours. even 3D games... well the 3D Sprites and animation it can give us more work, but we can do it with libraries or even another programs.
the Game Maker have several effects like Surface, Shaders, Particles and more. so the limitation is our imagination ;)
i love programming i did some learning(speaking on me) programs on VB, C\C++ and find the Game Maker was the best ;)
thanks for all to all
 
hey. i have notice that you are realy help me. but don't felt on that way by 2 reasons:
1 - i'm Portuguese, but i'm learning English by experience;
2 - i never worked with Vertex.
the Game Maker Studio tutorial is more technic than explicit :(
thanks for all to all.
thank you so much
My insistence on using the manual wasn't to push you away, it was because the page on primitives gives an actual picture on what each primitive type does, making it easier to figure out which one you needed to use both now and in the future.
 
C

cambalinho

Guest
and i must say thanks for all
please see these Vertex Texture:
Code:
text=background_get_texture(bkgAbove);
d3d_primitive_begin_texture(pr_trianglefan,text);
    d3d_vertex_texture(x, y+h, z, 0, 0);
     d3d_vertex_texture(x+w, y+h, z, 1, 0);
     d3d_vertex_texture(x+w, y+h, z+p, 1, 1);
     d3d_vertex_texture(x, y+h, z+p, 0, 1);
d3d_primitive_end();
the panel is drawed, but with black color and not the Texture. why the texture isn't drawed? what i'm doing wrong?
 
D

dannyjenn

Guest
Did you remember to enable the texture for 3D? (I think there's a checkbox in the background editor)
 
C

cambalinho

Guest
the problem wasn't that.
i was using the light. when i disabled the light, i was seen the texture.
so what the light have to do with texture?
 
You're using the basic primitives that have no normals, which is what the triangles need in order to properly accept lighting. You'll have to switch to d3d_vertex_normal_texture(). With that, I recommend Googling normals to understand what they are.
 
C

cambalinho

Guest
finally i did:
Code:
draw_set_colour(c_white);
text=background_get_texture(bkgAbove);
d3d_primitive_begin_texture(pr_trianglefan,text);
    d3d_vertex_normal_texture(x, y+h, z,0.5, 0.5, -0.5, 0, 0);
    d3d_vertex_normal_texture(x+w, y+h, z,0.5, 0.5, -0.5, 1, 0);
    d3d_vertex_normal_texture(x+w, y+h, z+p,0.5, 0.5, -0.5, 1, 1);
    d3d_vertex_normal_texture(x, y+h, z+p,0, 0.5, -0.5, 0, 1);        
d3d_primitive_end();


d3d_primitive_begin_texture(pr_trianglefan,text);
    d3d_vertex_normal_texture(x+w, y-2+h, z,0.5, 0.5, -0.5, 0, 0);
    d3d_vertex_normal_texture(x, y-2+h, z,0.5, 0.5, -0.5, 1, 0);
    d3d_vertex_normal_texture(x, y-2+h, z+p,0.5, 0.5, -0.5, 1, 1);
    d3d_vertex_normal_texture(x+w, y-2+h, z+p,0, 0.5, -0.5, 0, 1);        
d3d_primitive_end();
but i need some advice: i see the texture on front(the 1st vertex), but on back it's black. so i created the 2nd vertex. but i don't see the texture. so how can i mirror(for i see on back too) the vertex?
 
Top