📄 m3ggroup.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:
* ---------
* Group.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!
*
* 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 Definiton
****************************************************************************/
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Group_create()
{
st_m3g_group* handle;
ENTER_M3D_CS;
handle = M3G_Group_new();
LEAVE_M3D_CS;
if(handle==NULL) KNI_ThrowNew("java/lang/NullPointerException", "null handle");
KNI_ReturnInt((jint)handle);
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Group_addChildImpl()
{
st_m3g_group* handle = (st_m3g_group*)KNI_GetParameterAsInt(1);
st_m3g_node* child = (st_m3g_node*)KNI_GetParameterAsInt(2);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_ADDCHILD, handle, child);
if(child == NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null child");
} else if (child->parent != NULL) {
/* 1.1 API modify throw exception condition */
if (child->parent != (st_m3g_node*)handle) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid child");
}
/* else do nothing */
} else if(((st_m3g_object3d*)child)->object_type==M3G_WORLD ||
(st_m3g_node*)handle==child ||
(_m3g_Group_is_decendant((st_m3g_node*)child, (st_m3g_node*)handle) == M3G_TRUE)) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid child");
} else {
ENTER_M3D_CS;
M3G_Group_addChild(handle, child);
LEAVE_M3D_CS;
}
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Group_getChildCountImpl()
{
st_m3g_group* handle = (st_m3g_group*)KNI_GetParameterAsInt(1);
//KNI_ReturnInt(handle->children_count);
KNI_ReturnInt(M3G_Group_getChildCount(handle));
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Group_getChildImpl()
{
st_m3g_node* child = NULL;
st_m3g_group* handle = (st_m3g_group*)KNI_GetParameterAsInt(1);
jint index = KNI_GetParameterAsInt(2);
if(index<0 || index>= handle->children_count) {
KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid childindex");
} else {
child = (st_m3g_node*)M3G_Group_getChild(handle,index);
//////
}
KNI_ReturnInt((jint)child);
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_Group_groupNewImpl()
{
st_m3g_group* handle;
ENTER_M3D_CS;
handle = M3G_Group_new();
LEAVE_M3D_CS;
KNI_ReturnInt((jint)handle);
}
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_javax_microedition_m3g_Group_pickCameraImpl()
{
st_m3g_group* handle = (st_m3g_group*)KNI_GetParameterAsInt(1);
jint scope = KNI_GetParameterAsInt(2);
jfloat x = KNI_GetParameterAsFloat(3);
jfloat y = KNI_GetParameterAsFloat(4);
st_m3g_camera* camera = (st_m3g_camera*)KNI_GetParameterAsInt(5);
st_m3g_rayintersection* ray = (st_m3g_rayintersection*)KNI_GetParameterAsInt(6);
st_m3g_rayintersection ray2;
kal_int32 result = M3G_SUCCESS;
st_m3g_node *root1, *root2;
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_PICKCAMERA, handle, scope, x, y, camera, ray);
if(camera==NULL || handle==NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null camera");
} else {
root1 = _m3g_Node_findRoot((st_m3g_node*)camera);
root2 = _m3g_Node_findRoot((st_m3g_node*)handle);
if(root1 != root2) {
KNI_ThrowNew("java/lang/IllegalStateException", "no common scene");
} else {
if(ray == NULL) ray = &ray2;
ENTER_M3D_CS;
result = M3G_Group_pick_I(handle, scope, x, y, camera, ray);
LEAVE_M3D_CS;
if(result == M3G_ERROR_ILLEGAL_STATE) {
KNI_ThrowNew("java/lang/IllegalStateException", "intersect error");
} else if(result == M3G_ERROR_ARITHMETIC_EXCEPTION) {
KNI_ThrowNew("java/lang/ArithmeticException", "transform error");
}
}
}
KNI_ReturnBoolean(result == M3G_TRUE);
}
KNIEXPORT KNI_RETURNTYPE_BOOLEAN
Java_javax_microedition_m3g_Group_pickNodeImpl()
{
st_m3g_group* handle = (st_m3g_group*)KNI_GetParameterAsInt(1);
jint scope = KNI_GetParameterAsInt(2);
jfloat ox = KNI_GetParameterAsFloat(3);
jfloat oy = KNI_GetParameterAsFloat(4);
jfloat oz = KNI_GetParameterAsFloat(5);
jfloat dx = KNI_GetParameterAsFloat(6);
jfloat dy = KNI_GetParameterAsFloat(7);
jfloat dz = KNI_GetParameterAsFloat(8);
st_m3g_rayintersection* ray = (st_m3g_rayintersection*)KNI_GetParameterAsInt(9);
st_m3g_rayintersection ray2;
kal_int32 result = M3G_SUCCESS;
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_PICKNODE, handle, scope, ox, oy, oz, dx, dy, dz);
if(handle==NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null camera");
} if(dx==0.0f && dy==0.0f && dz==0.0f) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "direction");
} else {
if(ray == NULL) ray = &ray2;
ENTER_M3D_CS;
result = M3G_Group_pick_II(handle, scope, ox, oy, oz, dx, dy, dz, ray);
LEAVE_M3D_CS;
if(result == M3G_ERROR_ILLEGAL_STATE) {
KNI_ThrowNew("java/lang/IllegalStateException", "intersect error");
} else if(result == M3G_ERROR_ARITHMETIC_EXCEPTION) {
KNI_ThrowNew("java/lang/ArithmeticException", "transform error");
}
}
KNI_ReturnBoolean(result == M3G_TRUE);
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Group_removeChildImpl()
{
st_m3g_group* handle = (st_m3g_group*)KNI_GetParameterAsInt(1);
st_m3g_node* child = (st_m3g_node*)KNI_GetParameterAsInt(2);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_REMOVECHILD, handle, child);
if (M3G_Group_removeChild(handle, child) != M3G_SUCCESS) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "break skinnedmesh connection");
}
KNI_ReturnVoid();
}
#endif /* #ifdef SUPPORT_JSR_184 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -