Pages: 1
  Print  
Author Topic: Simple cube not working  (Read 2414 times)
Offline (Unknown gender) daz
Posted on: September 08, 2013, 05:14:31 PM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
I was playing around trying to get a very basic 3d scene setup for testing, and the code below works in GM but not Enigma for some reason and I can't figure out why.

Create event:
Code: [Select]
d3d_start();
d3d_set_lighting(1);

x = -20;
y = -20;
z = 10;

d3d_light_enable(1, true);
d3d_light_define_point(1, -10, -10, 12, 200, c_white);

Draw event:
Code: [Select]
draw_set_color(c_white);
d3d_set_projection(x, y, z, 0, 0, 0, 0, 0, 1);
d3d_draw_block(-5, -5, -5, 5, 5, 5, background_get_texture(background0), 1, 1);

Results: http://i.imgur.com/8hEnWoI.png

I can post project files if they're really necessary. Both used the same texture, named the same. On the enigma side I tried changing camera distance and setting texture to -1 as well as switching rendering engines (OGL1/3, DX9) but I could never see anything... And yes I added the object to the room.
Logged
Offline (Male) time-killer-games
Reply #1 Posted on: September 08, 2013, 05:35:32 PM

Contributor
Location: Virginia Beach
Joined: Jan 2013
Posts: 1166

View Profile Email
I think I remember trying d3d_draw_block before and I got the same issues, you should try d3d_model_block and d3d_model_draw I tested this and it worked, but in case I remembered wrong, what I am completely certain of that works is using the vertex and normals functions to make that equivalent cube, also loading external model files I confirm works because my current project uses this a ton.

Also it would make things easier on you when reproducing that cube model by using GM Model Creator, VModeler, SivModeler etc. These can be found on the YYG sandbox and at the Steam workshop.
« Last Edit: September 08, 2013, 05:39:55 PM by time-killer-games » Logged
Offline (Unknown gender) daz
Reply #2 Posted on: September 08, 2013, 07:18:59 PM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
Ah, interesting. Based on that hint, the below does work in enigma:
Code: [Select]
cube = d3d_model_create();
d3d_model_block(cube, -5, -5, -5, 5, 5, 5, 1, 1, true);
d3d_model_draw(cube, 0, 0, 0, background_get_texture(background0));

Also in enigma, d3d_model_block has one extra parameter, and will not work with NPO2 textures like GM will.
Logged
Offline (Male) time-killer-games
Reply #3 Posted on: September 08, 2013, 10:14:06 PM

Contributor
Location: Virginia Beach
Joined: Jan 2013
Posts: 1166

View Profile Email
So I guess at least until these bugs are solved you'll have to use the vertex/normals functions. GM Model creator has this nice feature that can create a cube, select it and then convert the faces to triangles and export to gml, which should help. :-)
Logged
Offline (Male) Goombert
Reply #4 Posted on: September 08, 2013, 11:41:03 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Whens the last time you guys updated the engine? Also, daz, non power of two textures is a limitation of the graphics API Direct3D and OpenGL just don't know how to handle them, so the GPU fills the textures with extra space.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) daz
Reply #5 Posted on: September 09, 2013, 09:02:32 AM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
Whens the last time you guys updated the engine? Also, daz, non power of two textures is a limitation of the graphics API Direct3D and OpenGL just don't know how to handle them, so the GPU fills the textures with extra space.
I downloaded enigma yesterday from the Windows portable exe.

Also, this does not work in Enigma (drawing lines)

Code: [Select]
d3d_set_lighting(false);
d3d_primitive_begin(pr_linelist);
d3d_vertex_color(0, 0, -100, c_blue, 1);
d3d_vertex_color(0, 0, 100, c_blue, 1);
d3d_vertex_color(-100, 0, 0, c_red, 1);
d3d_vertex_color(100, 0, 0, c_red, 1);
d3d_vertex_color(0, -100, 0, c_green, 1);
d3d_vertex_color(0, 100, 0, c_green, 1);
d3d_primitive_end();
Logged
Offline (Male) Goombert
Reply #6 Posted on: September 09, 2013, 09:41:45 AM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
@daz go to Build->Settings select the "API" tab and try different Graphics Systems. The only ones I was aware of being broke were d3d_primivitive in OGL 3.0 for some reason my model class don't like buffering them, I haven't looked into it yet.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) daz
Reply #7 Posted on: September 09, 2013, 10:54:11 AM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
Doesn't work with GL1 or 3, and with DX9 it causes the game to crash.
Logged
Offline (Male) Goombert
Reply #8 Posted on: September 09, 2013, 01:28:37 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Hrm, try one of these examples from the EDC that are 3D...
http://enigma-dev.org/edc/games.php?action=list
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) daz
Reply #9 Posted on: September 09, 2013, 01:42:56 PM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
None of them draw lines using the 3d system from what I can tell. Even the "vector conversion" uses fake 3d lines.
Logged
Offline (Male) Goombert
Reply #10 Posted on: September 09, 2013, 01:58:11 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
? No the vector conversion example uses a d3d model for the line grid, draw_line is used to point to the corners and draw text, but it definitely uses a pr_linelist and I just downloaded and test it and it works fine.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) daz
Reply #11 Posted on: September 09, 2013, 02:46:01 PM
Contributor
Joined: Jul 2010
Posts: 167

View Profile
OK I found what you mean. Yes, creating a model first and adding the linelist to the model and then drawing the model works. See the trend? That's what I had to do to get the cube to draw too. Thanks for the help though.
Logged
Offline (Male) Goombert
Reply #12 Posted on: September 09, 2013, 02:58:23 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
@daz, yes you should create a model before adding a primitive to it, but as for d3d_primitive and draw_primitive, those are not supposed to require you to create a model, I was only aware of them being broke in OpenGL 3 because my model class buffers and then clears them wrong somehow, but it should work in OpenGL 1 without creating a model.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: 1
  Print