3D GMS2 - Draw model without setting camera as 3D

T

trentallain

Guest
How do I draw a model so it is basically like a sprite (just with more angles)?
I am using gamemaker studio 2 and the model is a .obj with a .mtl and .png file for texture and colours.
 
M

MishMash

Guest
The first thing you need to do is just take a bit more time to try and understand what you want to achieve.

First of all, for a bit of background information. A "Camera" is a series of matrices that apply transformations to the model geometry in order to render it in a specific position. There are two main matrices that make up a camera: The view matrix, which moves the objects relative to the position of the camera (to create the illusion of a moving camera); and the Projection matrix, which defines a number of other properties about your scene such as the relative scale/draw distance, field of view and aspect ratio.
Both of these are required whenever you are doing any sort of rendering, because it is simply a mathematical means of moving something to where you want it to be. It is important to think of matrices (the camera) as a tool for manipulating what you are rendering. Under the hood, GameMaker views are also implemented as a "camera" matrix, which applies a universal offset to things as the view moves.

Now, getting onto what you are trying to achieve, you pretty much have two options:

1) Use a camera and d3d transformations to render the object in a given position. If you want your object to be affected by lighting and have a "proper" 3D style, this is essential. Bear in mind, you have plenty of options for where you can position a camera, or what a camera can do. There exists a form of Projection matrix called an orthographic matrix. This sets the matrix up in such a way that scaling is preserved over distance. So no matter how far away an object is, its scaling will be the same as one close-up. (This is normally how 2D game's are rendered). (The other form is called perspective rendering, wherein further away objects appear smaller as per real life)

2) You could pre-render the sprites at set angles from a piece of 3D animation software. The benefit of this is that you can still program your game in an entirely 2D manner, and simply use sprites for 3D. You can also render higher-quality versions without having to worry about performance. The downside is that you have to create sprites for every possible angle you could want, and don't have the benefit of being able to use 3D shading/lighting.

I know this isn't exactly an answer to what you were asking, however I chose to reply in this way because I believe your question demonstrates a lack of understanding of rendering fundamentals, and therefore you aren't really going to be able to reason about what sort of system you want to achieve, until you have taken the time to understand what is actually going on when you render something.
 
T

trentallain

Guest
The first thing you need to do is just take a bit more time to try and understand what you want to achieve.

First of all, for a bit of background information. A "Camera" is a series of matrices that apply transformations to the model geometry in order to render it in a specific position. There are two main matrices that make up a camera: The view matrix, which moves the objects relative to the position of the camera (to create the illusion of a moving camera); and the Projection matrix, which defines a number of other properties about your scene such as the relative scale/draw distance, field of view and aspect ratio.
Both of these are required whenever you are doing any sort of rendering, because it is simply a mathematical means of moving something to where you want it to be. It is important to think of matrices (the camera) as a tool for manipulating what you are rendering. Under the hood, GameMaker views are also implemented as a "camera" matrix, which applies a universal offset to things as the view moves.

Now, getting onto what you are trying to achieve, you pretty much have two options:

1) Use a camera and d3d transformations to render the object in a given position. If you want your object to be affected by lighting and have a "proper" 3D style, this is essential. Bear in mind, you have plenty of options for where you can position a camera, or what a camera can do. There exists a form of Projection matrix called an orthographic matrix. This sets the matrix up in such a way that scaling is preserved over distance. So no matter how far away an object is, its scaling will be the same as one close-up. (This is normally how 2D game's are rendered). (The other form is called perspective rendering, wherein further away objects appear smaller as per real life)

2) You could pre-render the sprites at set angles from a piece of 3D animation software. The benefit of this is that you can still program your game in an entirely 2D manner, and simply use sprites for 3D. You can also render higher-quality versions without having to worry about performance. The downside is that you have to create sprites for every possible angle you could want, and don't have the benefit of being able to use 3D shading/lighting.

I know this isn't exactly an answer to what you were asking, however I chose to reply in this way because I believe your question demonstrates a lack of understanding of rendering fundamentals, and therefore you aren't really going to be able to reason about what sort of system you want to achieve, until you have taken the time to understand what is actually going on when you render something.
Thanks for this. It's expanded my knowledge on this a bit further than what I knew before. I think my main problem is I don't know when and where to use the different functions to achieve what I want. Which is preferably drawing of the model as a model (using whatever the GMS2 version of d3d is) with a top down or overhead angle (so I can see some of the side facing the bottom of the screen) and perspective only on the model.
 
Last edited:
T

trentallain

Guest
The first thing you need to do is just take a bit more time to try and understand what you want to achieve.

First of all, for a bit of background information. A "Camera" is a series of matrices that apply transformations to the model geometry in order to render it in a specific position. There are two main matrices that make up a camera: The view matrix, which moves the objects relative to the position of the camera (to create the illusion of a moving camera); and the Projection matrix, which defines a number of other properties about your scene such as the relative scale/draw distance, field of view and aspect ratio.
Both of these are required whenever you are doing any sort of rendering, because it is simply a mathematical means of moving something to where you want it to be. It is important to think of matrices (the camera) as a tool for manipulating what you are rendering. Under the hood, GameMaker views are also implemented as a "camera" matrix, which applies a universal offset to things as the view moves.

Now, getting onto what you are trying to achieve, you pretty much have two options:

1) Use a camera and d3d transformations to render the object in a given position. If you want your object to be affected by lighting and have a "proper" 3D style, this is essential. Bear in mind, you have plenty of options for where you can position a camera, or what a camera can do. There exists a form of Projection matrix called an orthographic matrix. This sets the matrix up in such a way that scaling is preserved over distance. So no matter how far away an object is, its scaling will be the same as one close-up. (This is normally how 2D game's are rendered). (The other form is called perspective rendering, wherein further away objects appear smaller as per real life)

2) You could pre-render the sprites at set angles from a piece of 3D animation software. The benefit of this is that you can still program your game in an entirely 2D manner, and simply use sprites for 3D. You can also render higher-quality versions without having to worry about performance. The downside is that you have to create sprites for every possible angle you could want, and don't have the benefit of being able to use 3D shading/lighting.

I know this isn't exactly an answer to what you were asking, however I chose to reply in this way because I believe your question demonstrates a lack of understanding of rendering fundamentals, and therefore you aren't really going to be able to reason about what sort of system you want to achieve, until you have taken the time to understand what is actually going on when you render something.
What I was previously doing was basically 2D drawing a 3D voxel model by doing:
for (var i = 0; i < image_number; i += 1)
{
draw_sprite_ext(sprite_index, i, x-600, y-200 + i*scale, scale, scale, -angle+90, c_white, 1);
}
Where each sub image is a layer view (So that when drawn, would look 3D)
What I want to do is recreate this with the model so that I have more freedom of movement for it, such as flips/barrel rolls etc.
 
Last edited:
T

trentallain

Guest
The first thing you need to do is just take a bit more time to try and understand what you want to achieve.

First of all, for a bit of background information. A "Camera" is a series of matrices that apply transformations to the model geometry in order to render it in a specific position. There are two main matrices that make up a camera: The view matrix, which moves the objects relative to the position of the camera (to create the illusion of a moving camera); and the Projection matrix, which defines a number of other properties about your scene such as the relative scale/draw distance, field of view and aspect ratio.
Both of these are required whenever you are doing any sort of rendering, because it is simply a mathematical means of moving something to where you want it to be. It is important to think of matrices (the camera) as a tool for manipulating what you are rendering. Under the hood, GameMaker views are also implemented as a "camera" matrix, which applies a universal offset to things as the view moves.

Now, getting onto what you are trying to achieve, you pretty much have two options:

1) Use a camera and d3d transformations to render the object in a given position. If you want your object to be affected by lighting and have a "proper" 3D style, this is essential. Bear in mind, you have plenty of options for where you can position a camera, or what a camera can do. There exists a form of Projection matrix called an orthographic matrix. This sets the matrix up in such a way that scaling is preserved over distance. So no matter how far away an object is, its scaling will be the same as one close-up. (This is normally how 2D game's are rendered). (The other form is called perspective rendering, wherein further away objects appear smaller as per real life)

2) You could pre-render the sprites at set angles from a piece of 3D animation software. The benefit of this is that you can still program your game in an entirely 2D manner, and simply use sprites for 3D. You can also render higher-quality versions without having to worry about performance. The downside is that you have to create sprites for every possible angle you could want, and don't have the benefit of being able to use 3D shading/lighting.

I know this isn't exactly an answer to what you were asking, however I chose to reply in this way because I believe your question demonstrates a lack of understanding of rendering fundamentals, and therefore you aren't really going to be able to reason about what sort of system you want to achieve, until you have taken the time to understand what is actually going on when you render something.
Could you help me do this for what I need?
 
Last edited:
T

trentallain

Guest
check this.
https://forum.yoyogames.com/index.p...-animation-now-compatible-with-gms-1-4.19806/

I believe he's got a obj model import in there, and likely the method the draw it without using his animation system....
I can't figure out how to use it unfortunately... I especially don't know how to load in the models. If someone can show me how to load in a .obj (or even how to convert to a supported format) with material (.mtl) and colours (.png) so that I can draw the model, I think I would have a general idea of where to go from there.
 
Last edited:
Top