1 /** 2 Node that instances meshes into a scenario. 3 4 Copyright: 5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. 6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) 7 Copyright (c) 2017-2018 Godot-D contributors 8 9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License) 10 11 12 */ 13 module godot.meshinstance; 14 import std.meta : AliasSeq, staticIndexOf; 15 import std.traits : Unqual; 16 import godot.d.meta; 17 import godot.core; 18 import godot.c; 19 import godot.d.bind; 20 import godot.d.reference; 21 import godot.object; 22 import godot.classdb; 23 import godot.geometryinstance; 24 import godot.mesh; 25 import godot.material; 26 import godot.visualinstance; 27 import godot.spatial; 28 import godot.node; 29 /** 30 Node that instances meshes into a scenario. 31 32 MeshInstance is a node that takes a $(D Mesh) resource and adds it to the current scenario by creating an instance of it. This is the class most often used to get 3D geometry rendered and can be used to instance a single $(D Mesh) in many places. This allows to reuse geometry and save on resources. When a $(D Mesh) has to be instanced more than thousands of times at close proximity, consider using a $(D MultiMesh) in a $(D MultiMeshInstance) instead. 33 */ 34 @GodotBaseClass struct MeshInstance 35 { 36 enum string _GODOT_internal_name = "MeshInstance"; 37 public: 38 @nogc nothrow: 39 union { godot_object _godot_object; GeometryInstance _GODOT_base; } 40 alias _GODOT_base this; 41 alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses); 42 package(godot) __gshared bool _classBindingInitialized = false; 43 package(godot) static struct _classBinding 44 { 45 __gshared: 46 @GodotName("set_mesh") GodotMethod!(void, Mesh) setMesh; 47 @GodotName("get_mesh") GodotMethod!(Mesh) getMesh; 48 @GodotName("set_skeleton_path") GodotMethod!(void, NodePath) setSkeletonPath; 49 @GodotName("get_skeleton_path") GodotMethod!(NodePath) getSkeletonPath; 50 @GodotName("get_surface_material_count") GodotMethod!(long) getSurfaceMaterialCount; 51 @GodotName("set_surface_material") GodotMethod!(void, long, Material) setSurfaceMaterial; 52 @GodotName("get_surface_material") GodotMethod!(Material, long) getSurfaceMaterial; 53 @GodotName("create_trimesh_collision") GodotMethod!(void) createTrimeshCollision; 54 @GodotName("create_convex_collision") GodotMethod!(void) createConvexCollision; 55 @GodotName("_mesh_changed") GodotMethod!(void) _meshChanged; 56 @GodotName("create_debug_tangents") GodotMethod!(void) createDebugTangents; 57 } 58 bool opEquals(in MeshInstance other) const { return _godot_object.ptr is other._godot_object.ptr; } 59 MeshInstance opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; } 60 bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; } 61 mixin baseCasts; 62 static MeshInstance _new() 63 { 64 static godot_class_constructor constructor; 65 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("MeshInstance"); 66 if(constructor is null) return typeof(this).init; 67 return cast(MeshInstance)(constructor()); 68 } 69 @disable new(size_t s); 70 /** 71 72 */ 73 void setMesh(Mesh mesh) 74 { 75 checkClassBinding!(typeof(this))(); 76 ptrcall!(void)(_classBinding.setMesh, _godot_object, mesh); 77 } 78 /** 79 80 */ 81 Ref!Mesh getMesh() const 82 { 83 checkClassBinding!(typeof(this))(); 84 return ptrcall!(Mesh)(_classBinding.getMesh, _godot_object); 85 } 86 /** 87 88 */ 89 void setSkeletonPath(NodePathArg0)(in NodePathArg0 skeleton_path) 90 { 91 checkClassBinding!(typeof(this))(); 92 ptrcall!(void)(_classBinding.setSkeletonPath, _godot_object, skeleton_path); 93 } 94 /** 95 96 */ 97 NodePath getSkeletonPath() 98 { 99 checkClassBinding!(typeof(this))(); 100 return ptrcall!(NodePath)(_classBinding.getSkeletonPath, _godot_object); 101 } 102 /** 103 104 */ 105 long getSurfaceMaterialCount() const 106 { 107 checkClassBinding!(typeof(this))(); 108 return ptrcall!(long)(_classBinding.getSurfaceMaterialCount, _godot_object); 109 } 110 /** 111 Sets the $(D Material) for a surface of the $(D Mesh) resource. 112 */ 113 void setSurfaceMaterial(in long surface, Material material) 114 { 115 checkClassBinding!(typeof(this))(); 116 ptrcall!(void)(_classBinding.setSurfaceMaterial, _godot_object, surface, material); 117 } 118 /** 119 Returns the $(D Material) for a surface of the $(D Mesh) resource. 120 */ 121 Ref!Material getSurfaceMaterial(in long surface) const 122 { 123 checkClassBinding!(typeof(this))(); 124 return ptrcall!(Material)(_classBinding.getSurfaceMaterial, _godot_object, surface); 125 } 126 /** 127 This helper creates a $(D StaticBody) child node with a $(D ConcavePolygonShape) collision shape calculated from the mesh geometry. It's mainly used for testing. 128 */ 129 void createTrimeshCollision() 130 { 131 checkClassBinding!(typeof(this))(); 132 ptrcall!(void)(_classBinding.createTrimeshCollision, _godot_object); 133 } 134 /** 135 This helper creates a $(D StaticBody) child node with a $(D ConvexPolygonShape) collision shape calculated from the mesh geometry. It's mainly used for testing. 136 */ 137 void createConvexCollision() 138 { 139 checkClassBinding!(typeof(this))(); 140 ptrcall!(void)(_classBinding.createConvexCollision, _godot_object); 141 } 142 /** 143 144 */ 145 void _meshChanged() 146 { 147 Array _GODOT_args = Array.empty_array; 148 String _GODOT_method_name = String("_mesh_changed"); 149 this.callv(_GODOT_method_name, _GODOT_args); 150 } 151 /** 152 This helper creates a $(D MeshInstance) child node with gizmos at every vertex calculated from the mesh geometry. It's mainly used for testing. 153 */ 154 void createDebugTangents() 155 { 156 checkClassBinding!(typeof(this))(); 157 ptrcall!(void)(_classBinding.createDebugTangents, _godot_object); 158 } 159 /** 160 The $(D Mesh) resource for the instance. 161 */ 162 @property Mesh mesh() 163 { 164 return getMesh(); 165 } 166 /// ditto 167 @property void mesh(Mesh v) 168 { 169 setMesh(v); 170 } 171 /** 172 $(D NodePath) to the $(D Skeleton) associated with the instance. 173 */ 174 @property NodePath skeleton() 175 { 176 return getSkeletonPath(); 177 } 178 /// ditto 179 @property void skeleton(NodePath v) 180 { 181 setSkeletonPath(v); 182 } 183 }