-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyamc.gml
96 lines (92 loc) · 2.79 KB
/
yamc.gml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/// @macro {Id.VertexFormat} A vertex format with 3D position, normal, texcoord
/// and color, in this exact order. Do not delete!
///
/// @example
/// Following code loads a model from a file "model.bin", using the default
/// vertex format.
/// ```gml
/// model = vertex_buffer_load("model.bin", vertex_format_pnuc);
/// ```
///
/// @see vertex_buffer_load
#macro vertex_format_pnuc __vertex_format_pnuc()
/// @ignore
function __vertex_format_pnuc()
{
static _vformat = undefined;
if (_vformat == undefined)
{
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_normal();
vertex_format_add_texcoord();
vertex_format_add_color();
_vformat = vertex_format_end();
}
return _vformat;
}
/// @macro {Id.VertexFormat} Vertex format with 3D position, normal, texcoord,
/// color and tangent vector with bitangent sign (float4), in this exact order.
/// Do not delete!
///
/// @example
/// Following code loads a model from a file "model.bin", using the TBN
/// vertex format.
/// ```gml
/// model = vertex_buffer_load("model.bin", vertex_format_pnuct);
/// ```
///
/// @see vertex_buffer_load
#macro vertex_format_pnuct __vertex_format_pnuct()
/// @ignore
function __vertex_format_pnuct()
{
static _vformat = undefined;
if (_vformat == undefined)
{
vertex_format_begin();
vertex_format_add_position_3d();
vertex_format_add_normal();
vertex_format_add_texcoord();
vertex_format_add_color();
vertex_format_add_custom(vertex_type_float4, vertex_usage_texcoord);
_vformat = vertex_format_end();
}
return _vformat;
}
/// @func vertex_buffer_load(_filename, _vformat)
///
/// @desc Loads a vertex buffer from a file.
///
/// @param {String} _filename The file to load the buffer from.
/// @param {Id.VertexFormat} _vformat The vertex format of the buffer.
///
/// @return {Id.VertexBuffer} The loaded vertex buffer.
///
/// @example
/// Following code loads a model from file "model.bin" in the Create event
/// using the default vertex format, then draws it at the Draw event at the
/// instances x, y, z position and rotated around the Z axis by its direction
/// and finally frees the model from memory in the Clean Up event.
/// ```gml
/// /// @desc Create event
/// model = vertex_buffer_load("model.bin", vertex_format_pnuc);
///
/// /// @desc Draw event
/// matrix_set(matrix_world, matrix_build(x, y, z, 0, 0, direction, 1, 1, 1));
/// vertex_submit(model, pr_trianglelist, sprite_get_texture(SprModel, 0));
/// matrix_set(matrix_world, matrix_build_identity());
///
/// /// @desc Clean Up event
/// vertex_delete_buffer(model);
/// ```
///
/// @see vertex_format_pnuc
function vertex_buffer_load(_filename, _vformat)
{
gml_pragma("forceinline");
var _buffer = buffer_load(_filename);
var _vbuffer = vertex_create_buffer_from_buffer(_buffer, _vformat);
buffer_delete(_buffer);
return _vbuffer;
}