Advertisement
Badwrong

GameMaker - Vertex Buffer From .dat file

Oct 3rd, 2021 (edited)
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function LoadModelBuffer(_fileName, _format) {
  2.  
  3.     if(!file_exists(_fileName))
  4.     {
  5.         show_debug_message("File not Found: " + string(_fileName));
  6.         return noone;
  7.     }
  8.    
  9.     var _buff = buffer_load(_fileName);
  10.     var _vBuff = vertex_create_buffer_from_buffer(_buff, _format);
  11.     buffer_delete(_buff);
  12.     return _vBuff;
  13. }
  14.  
  15. function VertexFormatDefault()
  16. {
  17.     vertex_format_begin();
  18.     vertex_format_add_position_3d();
  19.     vertex_format_add_normal();
  20.     vertex_format_add_color();
  21.     vertex_format_add_texcoord();
  22.     return vertex_format_end();
  23. }
  24.  
  25. // When initializing game
  26. global.VFormat = VertexFormatDefault();
  27.  
  28. // In the actor object
  29. Mesh = LoadModelBuffer(file.dat, global.VFormat);
  30. Texture = sprite_get_texture(TextureSprite, 0);
  31.  
  32. // Actors drawing
  33. vertex_submit(Mesh, pr_trianglelist, Texture);   // After setting draw matrix etc.
  34.  
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement