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

Asset - Scripts Voxel Import

S_Kleer

Member
png1.png
Hello all! Just I want to show my asset that allow to load models from Magica Voxel to GMS 2!
All code writen on GML. It fast and optimased (i hope).

This asset is a paid, but you can try free compiled demo.

Features:
  • Import Magica Voxel (.vox) models
  • Models can be stored in one vertex buffer for better perfomance
  • Support frame based animation (you must use Magica Voxel 0.98.2)
  • Simple texture support
  • Support to set scale, when model is loading
  • Support to set origin, when model is loading (nine points of origin)
  • Easy to use
limitations:
  • If you load many models through a loop, it can take a lot of memory (make small loops)
  • Large levels can take a long time to load
  • Maximal size of model is 256x256x256 voxels
  • Models is not optimazed when is loaded. Each voxel have external sides. (2 triangle for each side) But inner sides not be generated.

List of functions:
Code:
VI_init()
VI_data_load(fname)
VI_data_unload(data)
VI_data_get_frames(data)
VI_data_get_palette(data)
VI_model_create(data, x, y, z, scale, origin)
VI_model_complex_start(frames)
VI_model_complex_add(complex, data, x, y, z, scale, origin)
VI_model_complex_end(complex)
VI_model_draw(model, frame, texture, x, y, z)
VI_model_draw_ext(model, frame, texture, x, y, z, xrotation, yrotation, zrotation, xscale, yscale, zscale)
VI_model_destroy(model)
  • All functions are rewritten for version 2.3.0!
  • Models are now loaded into memory using the new VI_data_load function. Previously, to create a model, game had to constantly open and read a file.
  • Due to the addition of the VI_data_load function, a lot of work has been done to rewrite the old code.
  • Added VI_data_unload function to unload information about models from memory if they are no longer needed.
  • Renamed the VI_model_get_frames and VI_model_get_palette functions to VI_data_get_frames and VI_data_get_palette.
  • Changed the origin system of models. Now the argument takes an array of 3 values, which is much clearer and more convenient. By default, the center [0, 0, 0] is in the upper left corner at the bottom of the model.
  • Slightly changed the code for drawing models. Now you need to call matrix_set(matrix_world, matrix_build_identity()) after the VI_model_draw and VI_model_draw_ext functions. This change made it possible to slightly speed up the draw of models.
  • Fixed a bug with model normals (I hope), which led to incorrect display of light.
  • Added a new demo. The already familiar landscape, but without using the VI_model_complex_start function to clearly show the difference in fps.


Marketplace link.
Demo link.
 
Last edited:

dadio

Potato Overlord
GMC Elder
Interesting! Big fan of Magica Voxel here.
This import is very nice and clean.
Nice job!

Some suggestions:

1. "Baked" lighting based on current Magica Voxel render settings - possible? (Would be *awesome*)

2. Opacities/glows etc. from Magica Voxels material settings - possible? (Would also rock.)
 

S_Kleer

Member
Thank you!

1) I think, that it impossible, because *.vox not have any baked light information.
2) It is poooossible, but! I am a noob in shaders. Sorry =(
 
S

Shazard Bansraj

Guest
Hey thanks for this. I think voxels would be a nice step for Game Maker. I've recently been exposed to some Magicavoxel art and would like to use this art style in a future game, if possible.
 
Last edited by a moderator:

S_Kleer

Member
So, I decided to update my asset, but I ran into an error:

Error creating package
Package signing error

Honestly, I don't even know what to do...

It happens when I choose Marketplace -> Update existing package -> ok
I also tried Create Package but it just open my profile in marketplace.

My IDE version 2.3.0
 

S_Kleer

Member
I finally updated my asset! Please, use it only for GMS 2.3 (Because I don't know how to delete versions for GMS 2.2...)

List of functions:
Code:
VI_init()
VI_data_load(fname)
VI_data_unload(data)
VI_data_get_frames(data)
VI_data_get_palette(data)
VI_model_create(data, x, y, z, scale, origin)
VI_model_complex_start(frames)
VI_model_complex_add(complex, data, x, y, z, scale, origin)
VI_model_complex_end(complex)
VI_model_draw(model, frame, texture, x, y, z)
VI_model_draw_ext(model, frame, texture, x, y, z, xrotation, yrotation, zrotation, xscale, yscale, zscale)
VI_model_destroy(model)
Changes (1.1.2):
  • All functions are rewritten for version 2.3.0!
  • Models are now loaded into memory using the new VI_data_load function. Previously, to create a model, game had to constantly open and read a file.
  • Due to the addition of the VI_data_load function, a lot of work has been done to rewrite the old code.
  • Added VI_data_unload function to unload information about models from memory if they are no longer needed.
  • Renamed the VI_model_get_frames and VI_model_get_palette functions to VI_data_get_frames and VI_data_get_palette.
  • Changed the origin system of models. Now the argument takes an array of 3 values, which is much clearer and more convenient. By default, the center [0, 0, 0] is in the upper left corner at the bottom of the model.
  • Slightly changed the code for drawing models. Now you need to call matrix_set(matrix_world, matrix_build_identity()) after the VI_model_draw and VI_model_draw_ext functions. This change made it possible to slightly speed up the draw of models.
  • Fixed a bug with model normals (I hope), which led to incorrect display of light.
  • Added a new demo. The already familiar landscape, but without using the VI_model_complex_start function to clearly show the difference in fps.
 
Top