• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

3d model issues

E

Ed420

Guest
Hello,
I am currently setting up a 3d enviroment with gms.
so far i can draw models within gms but i am having trouble with importing models from 3d studio max.
i have tried several converters and managed to get it to work at one time then it stopped working properly.
the model shows up as invisible or transparent.
if i draw a box behind it it makes it possible to see through the box.
basically its drawing the texture as the background image or something along those lines.
i am currently at work so can not get pictures or video of the problem.
any advice?
 

wadaltmon

Member
I assume you're using GMS1.4 and not 2? (I know this is in the 1.4 section, but it's worth checking)

First make sure that your models are converted, rotated, and UV mapped properly. Looking at this tutorial should give you an idea:


Then, make sure that you have culling on before and after your draw call.

Code:
d3d_set_culling(1);
//draw model
d3d_set_culling(1);
Normally this would not be necessary, but if you are experiencing some contingency, this may fix it.
 
T

The Sentient

Guest
Sounds like the opposite.

I'd try turning culling off

Code:
d3d_set_culling(0);
 
E

Ed420

Guest
Very informative.
I was culling the backs yes but only before. I will place it after aswell.
I'm very well adjusted to the 2d aspect of 1.4
But wanted to try something new.
I haven't had the chance to learn much of gms2 yet.
I did not return uv on the first model I tried but the second I did while it was obj
I am using model fixer aswell to transfer to d3d.
The model does appear in fixer just fine. The sides facing correct and everything.
I will try to culling later to see if that helps.
 
E

Ed420

Guest
here is my draw event

Code:
///3D Projection
var xcos = x + cos(degtorad(direction));
var ysin = y - sin(degtorad(direction));
var ztan = z + zto + tan(degtorad(pitch));

d3d_set_projection_ext(x,y,z + zto, xcos, ysin, ztan, 0, 0, 1, 80, ratio, 1, 99999);

var model = terrain[0,1], maxi = array_height_2d(model), i = 0;
for (i = 0; i < maxi; i += 1)
{
    d3d_model_draw(model[i,0], model[i,1], model[i,2], model[i,3], model[i,4]);
}

show_debug_overlay(true);
if (MenuStage == 6)
{
    ///draw the gun models
    //d3d_set_culling(true); //cull the model (back side)
    //d3d_set_hidden(true); //hide models behind it even if the are drawn later
    draw_set_color(image_blend); //set the color. If model has vertex color and alpha, this will not do anything
    //draw_set_colour(c_red);
    draw_set_alpha(image_alpha); //set the alpha. If model has vertex color and alpha, this will not do anything
    d3d_transform_set_identity();
    d3d_transform_set_rotation_z(203);
    d3d_transform_add_translation(4,2,-3);
    d3d_transform_add_rotation_y(pitch);
    d3d_transform_add_rotation_z(direction);
    d3d_transform_add_translation(x, y, z + zto);
    d3d_model_draw(guns[0, 1], -5, -10, -5, guns[0, 2]) //draw
    d3d_transform_set_identity();
    //draw_set_colour(c_white);
}


sorry was stuck at work so did not have access to my development pc.
as u can see the box has an object that seems to make a cut in the screen causing it to disappear where my model sits.
im not really sure why it is this way tho
 
E

Ed420

Guest
i had shared but due to needing 5 posts it is under review.
hopefully its up there tomorrow.
 
M

Multimagyar

Guest
Does not sound like a culling issue to me. if the faces would be inverted you would see the inside of your model. if your box is see through with the model's shape it's more likely an alpha issue. I'm not sure if d3d_model_draw is affected by it but I almost certain vertex_submit is affected by draw_set_alpha are you drawing something transparent and not resetting it? is the texture itself a transparent texture? how are you setting the texture?
 
T

The Sentient

Guest
Now a culling issue is ruled out, either of four options remain.

1) you are drawing it as a triangle_strip when it should be a triangle_list (or vice versa).
2) incorrect model format when you define the FVF in your create event.
3) the model is not exported correctly.
4) you don't have the depth buffer enabled.
 
M

Multimagyar

Guest
okay I expected a new post not an edit. You can rule out the 1st and assuming it is a gun and I don't seem to see the inside the box somewhere incorrectly zbuffer seems to be active. I would check the model it seems to have incorrect alpha and colour values. It still seems to be an alpha issue to me not a drawing or a depth issue. unless the gun meant to be behind the box then you would also have some ordering issue and logic issues. because why would you want your gun behind a box.

(Edit.: thank god you did not enable alpha testing it would be way harder to tell what's going on)

oh yeah either your texture is transparent or the vertex data on the alpha position is transparent
 
E

Ed420

Guest
i dont think its an alpha issue. the guns texture is a dark grey. i can understand it if this is the only model causing it.
in the scene displayed i have a large terrain mesh that has 0 alpha to the texture or model.
and it is having the same issue.
i can see the issue being an incorrect model format or something.
or a z buffer issue.
but i dont understand how to fix it within the code.
 
M

Multimagyar

Guest
okay so if you use d3d_model_load and the file is incorrect, you would not see the peak of the gun because if I recall correctly GMS1.4 just finishes the buffer in an empty state. either that or throws an error. if it would be zbuffer the gun would be visible but GMS would have no idea which triangle draw first or last. so everything triangle would be drawn on the screen in the order they are in the buffer. If it would be zbuffer you could simply fix it with d3d_set_zwriteenable(true).
The reason I insist on alpha issue here because the gun's outline is clearly visible on the box but triangles no-way is present so the model is loaded in but not visible. But because invisible triangles are still triangles they are being drawn. That's why culling could not be the issue because culling does not draw the triangle from one side. at all. so it's just not see through but not even there.If I'm correct in theory draw_set_alpha_test(true); draw_set_alpha_test_ref_value(0.5) would make the gun's outline be gone.

Also note that something having 0 alpha means it's completely see through.
 
E

Ed420

Guest
using draw_set_alpha_test(true); it goes away completely. theres no gun reference anywhere.
in model fixer it works fine. no issues anywhere. i dont see any alpha issues.
try changin alpha stuff around but no luck.
i can share a picture of it being displayed with proper texture in GMModelFix.exe
 
M

Multimagyar

Guest
Can you share the model file instead? As I said if the gun just goes away it is just that your gun is transparent for some reason and just being drawn that way. Also if I recall GMModelFix is made with an earlier version of GM? so it might interpret what you need differently. you might have lines in that model file that starts with 9s and add 0 colour and alpha values. draw_set_alpha_test discards certain levels of alpha so they are not being drawn straight in the shader.
 
E

Ed420

Guest
Yes I can. I'm not home currently but I shall share it here once I am
 
M

Multimagyar

Guest
Alright throw it at me or us or how ever you wish when you are able to do so.
 
E

Ed420

Guest
has 2 uzi models and one floor model. the grass terrain is what i planned to temp texture the floor with.
both models are open source and free to use.
each only took a few minutes to make lol
 
M

Multimagyar

Guest
I don't even need to look deeper into your d3d models are full with 9 lines with 0 transparency. You are drawing triangles you can see through and as I said that's why you can't see the model "9 5.424700 0.000000 2.021400 1.000000 0.000000 0.000000 0.500000 0.000000 197379.000000 0.000000" like this line. 9 is the type of vertex you will insert into the next 3 number is the point location in the 3D space then the normal and then the UV coordinates then the last two with the incredible high value and then 0 is the colour and then alpha. It's a white colour and full transparency. The reason why gmmodelfix shows it as normal model because during the load it completely ignores the alpha value.
if you want it to be exported correctly with that software I think it's possible you just have to save it as, go with all GM distribution, and then when it asks if you want to save colour and alpha say no to it. it will gives you 8 lines with the last values being 0 0 but will not read them instead it will use white colour with full alpha value.
I quickly tried to replace replace all the 9 lines with 8s and remove the white colour as I said.
https://www.dropbox.com/s/kv5fgkp4t0pd3z6/Uzi_edit.d3d?dl=0
It should work. if it still does not you still have to look around in your alpha set things.
 
E

Ed420

Guest
ok had a second to look at it. here is what i see:

Code:
9 5.424700 0.000000 2.021400 1.000000 0.000000 0.000000 0.500000 0.000000 197379.000000 0.000000
is 197379.000000 supposed to be the color or alpha?
 
M

Multimagyar

Guest
197379.000000 is the colour alpha comes after ([triangle info][[x y z] [nx ny nz] [u v] [colour alpha]] this is the order) Alpha is 0 and so is with every triangle. So all of them are transparent.
 
E

Ed420

Guest
Ok cool. Will write a quick converter for the models.
Just to be sure it's either 1 for visible then 0 for invisible?
 
M

Multimagyar

Guest
yes 1 visible 0 invisible (anything in between for different level of transparency)
 
E

Ed420

Guest
ok just an update.
im having issues with not enough memory to write a converter within gms1.4.
so what im going to have to do is write it in c++ using visual studio.
i had removed visual studio so waiting for it to reinstall.
i have managed to make the model visible tho.
using notepad i opened the model and copied the last 2 numbers of the 3rd line then did find/replace to replace the last number to 1.0000.
i loaded the model into the game and everythign looks fine.
i think i may have missed one or 2 triangles cause i have a very thin line that is still gone.


not really sure why my texture is coming out completely black either.
when i get a conversion setup and working i will post a drop box link here for those that may have this issue in the future.
Thank you all for ur help
 

Nux

GameMaker Staff
GameMaker Dev.
if your colour is actually "197379.000000", then if you convert that into hexadecimal you get this colour, so obviously your gun will be black, since you're drawing it completely black. change it to "16777215", which should be white so you can see your texture
 
E

Ed420

Guest
also where and how do i do the conversion for the hexadecimal colour.
i googled but didnt help lol
 

Bingdom

Googledom
I do believe it goes like this
Windows calculator -> programmer mode -> type in number -> change to hex

Pretty sure google would've told you that. ;)

Then use something like notepad++ and do search and replace.

Make sure before you draw your model, set draw colour to white (draw_set_colour)
 
A

Aggropop

Guest
if you are open to work with blender, i am recommending this:
http://martincrownover.com/blender-addon-gm3d/
you have full controll over the export parameters, you can have the model as gamemaker model file, or text. pointlist, linelist, raw vertex data...i cannot overstate how good it is. if something doesnt work, maybe the model is not located at global zero, scaling is off, textures, normals... you can see it in the txt file, fix it, embed it in an object, a script, an array. you can use models as data structure...basically use blender as a very powerful editor. for example bake textures to model, export mesh, export UVs and texture, it changed my life.
 
E

Ed420

Guest
if you are open to work with blender, i am recommending this:
http://martincrownover.com/blender-addon-gm3d/
you have full controll over the export parameters, you can have the model as gamemaker model file, or text. pointlist, linelist, raw vertex data...i cannot overstate how good it is. if something doesnt work, maybe the model is not located at global zero, scaling is off, textures, normals... you can see it in the txt file, fix it, embed it in an object, a script, an array. you can use models as data structure...basically use blender as a very powerful editor. for example bake textures to model, export mesh, export UVs and texture, it changed my life.
Hmmm i would have to look into blender more. I've only used blender a couple times. Not very good with it either lol
 
Top