OSDN Git Service

swig generated java files
[mikumikustudio/libgdx-mikumikustudio.git] / extensions / gdx-bullet / jni / swig-src / com / badlogic / gdx / physics / bullet / btIndexedMesh.java
1 /* ----------------------------------------------------------------------------\r
2  * This file was automatically generated by SWIG (http://www.swig.org).\r
3  * Version 2.0.10\r
4  *\r
5  * Do not make changes to this file unless you know what you are doing--modify\r
6  * the SWIG interface file instead.\r
7  * ----------------------------------------------------------------------------- */\r
8 \r
9 package com.badlogic.gdx.physics.bullet;\r
10 \r
11 import com.badlogic.gdx.graphics.Mesh;\r
12 import com.badlogic.gdx.graphics.VertexAttribute;\r
13 import com.badlogic.gdx.graphics.VertexAttributes.Usage;\r
14 import com.badlogic.gdx.graphics.g3d.model.MeshPart;\r
15 import com.badlogic.gdx.utils.Array;\r
16 import com.badlogic.gdx.utils.GdxRuntimeException;\r
17 \r
18 public class btIndexedMesh extends BulletBase {\r
19         private long swigCPtr;\r
20         \r
21         protected btIndexedMesh(final String className, long cPtr, boolean cMemoryOwn) {\r
22                 super(className, cPtr, cMemoryOwn);\r
23                 swigCPtr = cPtr;\r
24         }\r
25         \r
26         protected btIndexedMesh(long cPtr, boolean cMemoryOwn) {\r
27                 this("btIndexedMesh", cPtr, cMemoryOwn);\r
28                 construct();\r
29         }\r
30         \r
31         @Override\r
32         protected void reset(long cPtr, boolean cMemoryOwn) {\r
33                 if (!destroyed)\r
34                         destroy();\r
35                 super.reset(swigCPtr = cPtr, cMemoryOwn);\r
36         }\r
37         \r
38         public static long getCPtr(btIndexedMesh obj) {\r
39                 return (obj == null) ? 0 : obj.swigCPtr;\r
40         }\r
41 \r
42         @Override\r
43         protected void finalize() throws Throwable {\r
44                 if (!destroyed)\r
45                         destroy();\r
46                 super.finalize();\r
47         }\r
48 \r
49   @Override protected synchronized void delete() {\r
50                 if (swigCPtr != 0) {\r
51                         if (swigCMemOwn) {\r
52                                 swigCMemOwn = false;\r
53                                 gdxBulletJNI.delete_btIndexedMesh(swigCPtr);\r
54                         }\r
55                         swigCPtr = 0;\r
56                 }\r
57                 super.delete();\r
58         }\r
59 \r
60         protected final static Array<btIndexedMesh> instances = new Array<btIndexedMesh>();\r
61         protected static btIndexedMesh getInstance(final MeshPart meshPart) {\r
62                 final int n = instances.size;\r
63                 for (int i = 0; i < n; i++) {\r
64                         final btIndexedMesh mesh = instances.get(i);\r
65                         if (meshPart.equals(mesh.meshPart))\r
66                                 return mesh;\r
67                 }\r
68                 return null;\r
69         }\r
70         \r
71         /** Create or reuse a btIndexedMesh instance based on the specified {@link MeshPart}.\r
72          * Use {@link #release()} to release the mesh when it's no longer needed. */\r
73         public static btIndexedMesh obtain(final MeshPart meshPart) {\r
74                 if (meshPart == null)\r
75                         throw new GdxRuntimeException("meshPart cannot be null");\r
76                 \r
77                 btIndexedMesh result = getInstance(meshPart);\r
78                 if (result == null) {\r
79                         result = new btIndexedMesh(meshPart);\r
80                         instances.add(result);\r
81                 }\r
82                 result.obtain();\r
83                 return result;\r
84         }\r
85         \r
86         protected MeshPart meshPart;\r
87         \r
88         /** Construct a new btIndexedMesh based on the supplied {@link Mesh}\r
89          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
90          * The buffers for the vertices and indices are shared amonst both. */\r
91         public btIndexedMesh(final Mesh mesh) {\r
92                 this();\r
93                 set(mesh);\r
94         }\r
95         \r
96         /** Construct a new btIndexedMesh based on the supplied {@link MeshPart}\r
97          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
98          * The buffers for the vertices and indices are shared amonst both. */\r
99         public btIndexedMesh(final MeshPart meshPart) {\r
100                 this();\r
101                 set(meshPart);\r
102         }\r
103         \r
104         /** Construct a new btIndexedMesh based on the supplied {@link Mesh}\r
105          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
106          * The buffers for the vertices and indices are shared amonst both. */\r
107         public btIndexedMesh(final Mesh mesh, int offset, int count) {\r
108                 this();\r
109                 set(mesh, offset, count);\r
110         }\r
111         \r
112         /** @return The {@link MeshPart} used to create or set this btIndexedMesh, may be null. */\r
113         public MeshPart getMeshPart() {\r
114                 return meshPart;\r
115         }\r
116         \r
117         /** Convenience method to set this btIndexedMesh to the specified {@link Mesh} \r
118          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
119          * The buffers for the vertices and indices are shared amonst both. */\r
120         public void set(final Mesh mesh) {\r
121                 set(mesh, 0, mesh.getNumIndices());\r
122         }\r
123 \r
124         /** Convenience method to set this btIndexedMesh to the specified {@link MeshPart} \r
125          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
126          * The buffers for the vertices and indices are shared amonst both. */\r
127         public void set(final MeshPart meshPart) {\r
128                 if (meshPart.primitiveType != com.badlogic.gdx.graphics.GL10.GL_TRIANGLES)\r
129                         throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh must be indexed and triangulated");\r
130                 set(meshPart.mesh, meshPart.indexOffset, meshPart.numVertices);\r
131                 this.meshPart = meshPart;\r
132         }\r
133 \r
134         /** Convenience method to set this btIndexedMesh to the specified {@link Mesh} \r
135          * The specified mesh must be indexed and triangulated and must outlive this btIndexedMesh.\r
136          * The buffers for the vertices and indices are shared amonst both. */\r
137         public void set(final Mesh mesh, int offset, int count) {\r
138                 if ((count <= 0) || ((count % 3) != 0))\r
139                         throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh must be indexed and triangulated");\r
140 \r
141                 VertexAttribute posAttr = mesh.getVertexAttribute(Usage.Position);\r
142                 \r
143                 if (posAttr == null)\r
144                         throw new com.badlogic.gdx.utils.GdxRuntimeException("Mesh doesn't have a position attribute");\r
145                 \r
146                 setVertices(mesh.getVerticesBuffer(), mesh.getVertexSize(), mesh.getNumVertices(), posAttr.offset);\r
147                 setIndices(mesh.getIndicesBuffer(), offset, count);\r
148                 \r
149                 meshPart = null;\r
150         }\r
151 \r
152   public void setNumTriangles(int value) {\r
153     gdxBulletJNI.btIndexedMesh_numTriangles_set(swigCPtr, this, value);\r
154   }\r
155 \r
156   public int getNumTriangles() {\r
157     return gdxBulletJNI.btIndexedMesh_numTriangles_get(swigCPtr, this);\r
158   }\r
159 \r
160   public void setTriangleIndexBase(java.nio.ByteBuffer value) {\r
161     assert value.isDirect() : "Buffer must be allocated direct.";\r
162     {\r
163       gdxBulletJNI.btIndexedMesh_triangleIndexBase_set(swigCPtr, this, value);\r
164     }\r
165   }\r
166 \r
167   public java.nio.ByteBuffer getTriangleIndexBase() {\r
168     return gdxBulletJNI.btIndexedMesh_triangleIndexBase_get(swigCPtr, this);\r
169 }\r
170 \r
171   public void setTriangleIndexStride(int value) {\r
172     gdxBulletJNI.btIndexedMesh_triangleIndexStride_set(swigCPtr, this, value);\r
173   }\r
174 \r
175   public int getTriangleIndexStride() {\r
176     return gdxBulletJNI.btIndexedMesh_triangleIndexStride_get(swigCPtr, this);\r
177   }\r
178 \r
179   public void setNumVertices(int value) {\r
180     gdxBulletJNI.btIndexedMesh_numVertices_set(swigCPtr, this, value);\r
181   }\r
182 \r
183   public int getNumVertices() {\r
184     return gdxBulletJNI.btIndexedMesh_numVertices_get(swigCPtr, this);\r
185   }\r
186 \r
187   public void setVertexBase(java.nio.ByteBuffer value) {\r
188     assert value.isDirect() : "Buffer must be allocated direct.";\r
189     {\r
190       gdxBulletJNI.btIndexedMesh_vertexBase_set(swigCPtr, this, value);\r
191     }\r
192   }\r
193 \r
194   public java.nio.ByteBuffer getVertexBase() {\r
195     return gdxBulletJNI.btIndexedMesh_vertexBase_get(swigCPtr, this);\r
196 }\r
197 \r
198   public void setVertexStride(int value) {\r
199     gdxBulletJNI.btIndexedMesh_vertexStride_set(swigCPtr, this, value);\r
200   }\r
201 \r
202   public int getVertexStride() {\r
203     return gdxBulletJNI.btIndexedMesh_vertexStride_get(swigCPtr, this);\r
204   }\r
205 \r
206   public void setIndexType(int value) {\r
207     gdxBulletJNI.btIndexedMesh_indexType_set(swigCPtr, this, value);\r
208   }\r
209 \r
210   public int getIndexType() {\r
211     return gdxBulletJNI.btIndexedMesh_indexType_get(swigCPtr, this);\r
212   }\r
213 \r
214   public void setVertexType(int value) {\r
215     gdxBulletJNI.btIndexedMesh_vertexType_set(swigCPtr, this, value);\r
216   }\r
217 \r
218   public int getVertexType() {\r
219     return gdxBulletJNI.btIndexedMesh_vertexType_get(swigCPtr, this);\r
220   }\r
221 \r
222   public btIndexedMesh() {\r
223     this(gdxBulletJNI.new_btIndexedMesh(), true);\r
224   }\r
225 \r
226   public void setTriangleIndexBase(java.nio.ShortBuffer data) {\r
227     assert data.isDirect() : "Buffer must be allocated direct.";\r
228     {\r
229       gdxBulletJNI.btIndexedMesh_setTriangleIndexBase(swigCPtr, this, data);\r
230     }\r
231   }\r
232 \r
233   public void setVertexBase(java.nio.FloatBuffer data) {\r
234     assert data.isDirect() : "Buffer must be allocated direct.";\r
235     {\r
236       gdxBulletJNI.btIndexedMesh_setVertexBase(swigCPtr, this, data);\r
237     }\r
238   }\r
239 \r
240   public void setVertices(java.nio.FloatBuffer vertices, int sizeInBytesOfEachVertex, int vertexCount, int positionOffsetInBytes) {\r
241     assert vertices.isDirect() : "Buffer must be allocated direct.";\r
242     {\r
243       gdxBulletJNI.btIndexedMesh_setVertices(swigCPtr, this, vertices, sizeInBytesOfEachVertex, vertexCount, positionOffsetInBytes);\r
244     }\r
245   }\r
246 \r
247   public void setIndices(java.nio.ShortBuffer indices, int indexOffset, int indexCount) {\r
248     assert indices.isDirect() : "Buffer must be allocated direct.";\r
249     {\r
250       gdxBulletJNI.btIndexedMesh_setIndices(swigCPtr, this, indices, indexOffset, indexCount);\r
251     }\r
252   }\r
253 \r
254 }\r