1/**************************************************************************/
2/* mesh_storage.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#ifndef MESH_STORAGE_H
32#define MESH_STORAGE_H
33
34#include "servers/rendering_server.h"
35#include "utilities.h"
36
37class RendererMeshStorage {
38public:
39 virtual ~RendererMeshStorage() {}
40
41 /* MESH API */
42
43 virtual RID mesh_allocate() = 0;
44 virtual void mesh_initialize(RID p_rid) = 0;
45 virtual void mesh_free(RID p_rid) = 0;
46
47 virtual void mesh_set_blend_shape_count(RID p_mesh, int p_blend_shape_count) = 0;
48
49 /// Returns stride
50 virtual void mesh_add_surface(RID p_mesh, const RS::SurfaceData &p_surface) = 0;
51
52 virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0;
53
54 virtual void mesh_set_blend_shape_mode(RID p_mesh, RS::BlendShapeMode p_mode) = 0;
55 virtual RS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0;
56
57 virtual void mesh_surface_update_vertex_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0;
58 virtual void mesh_surface_update_attribute_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0;
59 virtual void mesh_surface_update_skin_region(RID p_mesh, int p_surface, int p_offset, const Vector<uint8_t> &p_data) = 0;
60
61 virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0;
62 virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0;
63
64 virtual RS::SurfaceData mesh_get_surface(RID p_mesh, int p_surface) const = 0;
65
66 virtual int mesh_get_surface_count(RID p_mesh) const = 0;
67
68 virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0;
69 virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
70
71 virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton = RID()) = 0;
72
73 virtual void mesh_set_shadow_mesh(RID p_mesh, RID p_shadow_mesh) = 0;
74
75 virtual void mesh_clear(RID p_mesh) = 0;
76
77 virtual bool mesh_needs_instance(RID p_mesh, bool p_has_skeleton) = 0;
78
79 /* MESH INSTANCE */
80
81 virtual RID mesh_instance_create(RID p_base) = 0;
82 virtual void mesh_instance_free(RID p_rid) = 0;
83 virtual void mesh_instance_set_skeleton(RID p_mesh_instance, RID p_skeleton) = 0;
84 virtual void mesh_instance_set_blend_shape_weight(RID p_mesh_instance, int p_shape, float p_weight) = 0;
85 virtual void mesh_instance_check_for_update(RID p_mesh_instance) = 0;
86 virtual void mesh_instance_set_canvas_item_transform(RID p_mesh_instance, const Transform2D &p_transform) = 0;
87 virtual void update_mesh_instances() = 0;
88
89 /* MULTIMESH API */
90
91 virtual RID multimesh_allocate() = 0;
92 virtual void multimesh_initialize(RID p_rid) = 0;
93 virtual void multimesh_free(RID p_rid) = 0;
94
95 virtual void multimesh_allocate_data(RID p_multimesh, int p_instances, RS::MultimeshTransformFormat p_transform_format, bool p_use_colors = false, bool p_use_custom_data = false) = 0;
96
97 virtual int multimesh_get_instance_count(RID p_multimesh) const = 0;
98
99 virtual void multimesh_set_mesh(RID p_multimesh, RID p_mesh) = 0;
100 virtual void multimesh_instance_set_transform(RID p_multimesh, int p_index, const Transform3D &p_transform) = 0;
101 virtual void multimesh_instance_set_transform_2d(RID p_multimesh, int p_index, const Transform2D &p_transform) = 0;
102 virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0;
103 virtual void multimesh_instance_set_custom_data(RID p_multimesh, int p_index, const Color &p_color) = 0;
104
105 virtual RID multimesh_get_mesh(RID p_multimesh) const = 0;
106
107 virtual Transform3D multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0;
108 virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0;
109 virtual Color multimesh_instance_get_color(RID p_multimesh, int p_index) const = 0;
110 virtual Color multimesh_instance_get_custom_data(RID p_multimesh, int p_index) const = 0;
111
112 virtual void multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_buffer) = 0;
113 virtual Vector<float> multimesh_get_buffer(RID p_multimesh) const = 0;
114
115 virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
116 virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0;
117
118 virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0;
119
120 /* SKELETON API */
121
122 virtual RID skeleton_allocate() = 0;
123 virtual void skeleton_initialize(RID p_rid) = 0;
124 virtual void skeleton_free(RID p_rid) = 0;
125
126 virtual void skeleton_allocate_data(RID p_skeleton, int p_bones, bool p_2d_skeleton = false) = 0;
127 virtual int skeleton_get_bone_count(RID p_skeleton) const = 0;
128 virtual void skeleton_bone_set_transform(RID p_skeleton, int p_bone, const Transform3D &p_transform) = 0;
129 virtual Transform3D skeleton_bone_get_transform(RID p_skeleton, int p_bone) const = 0;
130 virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) = 0;
131 virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const = 0;
132 virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) = 0;
133
134 virtual void skeleton_update_dependency(RID p_base, DependencyTracker *p_instance) = 0;
135};
136
137#endif // MESH_STORAGE_H
138