📄 m3gmesh.c
字号:
/*******************************************************************************
* Modification Notice:
* --------------------------
* This software is modified by MediaTek Inc. and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2001
*
*******************************************************************************/
/*****************************************************************************
*
* Filename:
* ---------
* Mesh.c
*
* Project:
* --------
* Maui_Software
*
* Description:
* ------------
*
*
* Author:
* -------
* -------
*
*============================================================================
* HISTORY
* Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*------------------------------------------------------------------------------
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*
* removed!
* removed!
* removed!
*------------------------------------------------------------------------------
* Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
*============================================================================
****************************************************************************/
/****************************************************************************
Include Header Files
****************************************************************************/
#include "m3g.h"
#ifdef SUPPORT_JSR_184
/****************************************************************************
Function Definition
****************************************************************************/
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Mesh_createMultiSubmesh()
{
st_m3g_vertexbuffer* vb = (st_m3g_vertexbuffer*)KNI_GetParameterAsInt(1);
st_m3g_mesh* handle = NULL;
int submesh_count, i;
KNI_StartHandles(2);
KNI_DeclareHandle(ib_handle);
KNI_DeclareHandle(ap_handle);
KNI_GetParameterAsObject(2, ib_handle);
KNI_GetParameterAsObject(3, ap_handle);
#if FAST_KNI && defined(CLDCHI)
if(vb==NULL || *ib_handle==NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null handle");
} else {
jint_array* ibs = (jint_array*)*ib_handle;
jint_array* aps = (jint_array*)*ap_handle;
submesh_count = ibs->length;
if((aps && aps->length<submesh_count) || submesh_count==0) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "Invalid submeshs");
} else {
for(i=0; i<submesh_count; i++) {
if(ibs->elements[i] == 0) {
KNI_ThrowNew("java/lang/NullPointerException", "Invalid submeshs");
goto _return;
}
}
ENTER_M3D_CS;
if(aps == NULL) {
handle = M3G_Mesh_new(vb, submesh_count, (st_m3g_indexbuffer**)ibs->elements, NULL);
} else {
handle = M3G_Mesh_new(vb, submesh_count, (st_m3g_indexbuffer**)ibs->elements,
(st_m3g_appearance**)aps->elements);
}
LEAVE_M3D_CS;
if (handle == NULL) KNI_ThrowNew("java/lang/NullPointerException", "new mesh failed");
}
}
#else
ASSERT(0);
#endif /* FAST_KNI */
_return:
KNI_EndHandles();
KNI_ReturnInt((jint)handle);
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Mesh_createSingleSubmesh()
{
st_m3g_vertexbuffer* vb = (st_m3g_vertexbuffer*)KNI_GetParameterAsInt(1);
st_m3g_indexbuffer* ib = (st_m3g_indexbuffer*)KNI_GetParameterAsInt(2);
st_m3g_appearance* ap = (st_m3g_appearance*)KNI_GetParameterAsInt(3);
st_m3g_mesh* handle = NULL;
if(vb==NULL || ib==NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null handle");
} else {
ENTER_M3D_CS;
handle = M3G_Mesh_new(vb, 1, &ib, &ap);
LEAVE_M3D_CS;
if (handle == NULL) KNI_ThrowNew("java/lang/NullPointerException", "new mesh failed");
}
KNI_ReturnInt((jint)handle);
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Mesh_getAppearanceImpl()
{
st_m3g_mesh* handle = (st_m3g_mesh*)KNI_GetParameterAsInt(1);
jint index = KNI_GetParameterAsInt(2);
if(index<0 || index>=handle->submesh_count) {
KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid appearance index");
KNI_ReturnInt((jint)0);
} else {
KNI_ReturnInt((jint)M3G_Mesh_getAppearance(handle, index));
}
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Mesh_getIndexBufferImpl()
{
st_m3g_mesh* handle = (st_m3g_mesh*)KNI_GetParameterAsInt(1);
jint index = KNI_GetParameterAsInt(2);
if(index<0 || index>=handle->submesh_count) {
KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid appearance index");
KNI_ReturnInt((jint)0);
} else {
KNI_ReturnInt((jint)M3G_Mesh_getIndexBuffer(handle, index));
}
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Mesh_getSubmeshCountImpl()
{
st_m3g_mesh* handle = (st_m3g_mesh*)KNI_GetParameterAsInt(1);
//KNI_ReturnInt((jint)handle->submesh_count);
KNI_ReturnInt((jint)M3G_Mesh_getSubmeshCount(handle));
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Mesh_getVertexBufferImpl()
{
st_m3g_mesh* handle = (st_m3g_mesh*)KNI_GetParameterAsInt(1);
//KNI_ReturnInt((jint)handle->vertex_buffer);
KNI_ReturnInt((jint)M3G_Mesh_getgetVertexBuffer(handle));
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Mesh_setAppearanceImpl()
{
st_m3g_mesh* handle = (st_m3g_mesh*)KNI_GetParameterAsInt(1);
jint index = KNI_GetParameterAsInt(2);
st_m3g_appearance* appearance = (st_m3g_appearance*)KNI_GetParameterAsInt(3);
if(index<0 || index>=handle->submesh_count) {
KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid appearance index");
} else if (M3G_Mesh_setAppearance(handle, index, appearance) != M3G_SUCCESS) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "Invalid appearance");
}
KNI_ReturnVoid();
}
#endif /* #ifdef SUPPORT_JSR_184 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -