• 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!

Creating 3d models in 2d basic camera!

Dupletor

Member
[WARNING: You do NOT require knowledge around 3d manipulation to use this tool for 3d modelling, but you DO require knowledge about files manipulation and it is very limited to models that do not mesh with eachother.]

I am happy to announce the open project for the modelling of basic 3d structures for interaction with a 2d world inside of the main camera, without any need of reconfigure camera perspective.

Inspired by Toby Fox's Deltarune fight against Jevil:


I had to do for school a project with 3d modelling, but I did not want it to be useless for my gamemaker projects, so I made a way to develop arbitrary 3d models inside of the 2d engine.



And now it is open source, here:

https://github.com/Dupletor/3D-Mountain

Ignore the last two commits, the hole object and the player object.They are not useful for you unless you have my personal model, and it was the last commit before I integrated the system into my own project. :p

How does it work?
The system loads two files: One file made of contour lines, and a second one made of direct triangles.
The file made of contour lines must exist with at least a single contour line with at least 0 dots for a model to be loaded. Also, the triangles files probably also must exist, which must be either in the executable folder or in the sandbox, inside of Local/.

You can then change the files while the project is running and press "L" to reload the file after you modify it without need of recompiling.

But you can't change the colors of the model without changing the code... Feel free to find a way to save and load colors, and I will accept the PR.

To get the same effect, I changed the color pallet to a doubled "colors = [c_blue, c_blue, c_aqua c_aqua];", in order to make two following triangles have the same colors, and doubled the amount of dots in the connected cone base, so the triangles connected to the next dot would still have alternated colors.
So, for example, I recreated the model with a different color pallet. You can do many models, but avoid using planes on the same height, as there is no way to know which planes are above which when they are at the same height, and height difference is important for knowing what is the drawing order of triangles.

Could mess around and get a more precise representation of what Toby Fox did, but it's nearly the same solid, made in about 4 minutes (after 2 months developing the tool), and by spinning around the Y axis it gets the same animation. Also, the technology allows me to build nearly anything that is not round, and I might use it later for many environmental objects. The red squares are objects that do not serve a purpose for the 3d model, but will in the latter project.

upload_2019-6-17_11-31-24.png

In order to load the model, the program follows the following logic:

Y_POSITION_OF_CONTOUR_LINE NUMBER_OF_DOTS_OF_CONTOUR_LINE
X_DOT_1 Z_DOT_1 X_DOT_2 Z_DOT_2.... (up to NUMBER_OF_DOTS_OF_CONTOUR_LINE)
for example, this model was generated by the file:
Code:
190 1
0 0
200 8
500 0 350 350 0 500 -350 350 -500 0 -350 -350 0 -500 350 -350
200 8
100 0 50 50 0 100 -50 50 -100 0 -50 -50 0 -100 50 -50
200 16
100 0 85 35 70 70 35 85 0 100 -35 85 -70 70 -85 35 -100 0 -35 -35 -70 -70 -35 -85 0 -100 35 -85 70 -70 85 -35
400 1
0 0
600 16
 85 -35 100 0 85 35 70 70 35 85 0 100 -35 85 -70 70 -85 35 -100 0 -35 -35 -70 -70 -35 -85 0 -100 35 -85 70 -70
600 8
100 0 50 50 0 100 -50 50 -100 0 -50 -50 0 -100 50 -50
600 8
500 0 350 350 0 500 -350 350 -500 0 -350 -350 0 -500 350 -350
610 1
0 0
as mountainmodel.txt

WARNING: IT NEEDS TO HAVE EXACTLY 2 NUMBERS PER VALUE OF THE SECOND VALUE GIVEN, AS DOTS ARE DETERMINED BY 2 COORDINATES IN THE PLANE DETERMINED BY THE HEIGHT Y_POSITION_OF_CONTOUR_LINE.

and I made a model.txt just to make it not break for not existing...
Code:
0 0 0 0 0 0 0 0 0
which means "also include into the project the triangle with dots in 3 dimensions (0,0,0), (0,0,0), (0,0,0)
Adding more numbers (IN NEW LINES) will just include more triangles to the model, in any position you want. WARNING: NEEDS TO BE MULTIPLE OF 9, BECAUSE A TRIANGLE IS DETERMINED BY 9 COORDINATES IN A SPACE.

each 2 lines representing a contour line.

Note that having a single dot creates a contour line of 1 dot, this is why some positions are locally around a single dot.



Older versions of the git project provide alternatives to how you can create models, from the very beginning, when I was just messing around with rotating triangles. Feel free to explore, stable commits are marked in the title with "stable" .

WARNING: DO NOT rotate the model above 360º or under -360º. I just made a fix that forces the range [-180:180], you should use it. I do not know exactly what messes things up at higher angles.
WARNING: DO NOT use "show_debug_message" in the Draw event or in the sort algorithm, which is performed in the Draw event. I mean, you can to debug, but it might mess up with some stuff visually. No idea why, but works when the delayed output is not in it.

You can do whatever you want with whatever you find in the project. EXCEPT the sprites of the little character. Also, if you improve fps or sorting somehow, please feel free to ask for a PR on Github.
 
Last edited:
Top