📄 m3grayintersection.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:
* ---------
* RayIntersection.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!
*------------------------------------------------------------------------------
* 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_RayIntersection_create()
{
st_m3g_rayintersection* handle;
ENTER_M3D_CS;
handle = M3G_RayIntersection_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_RayIntersection_finalize()
{
KNI_StartHandles(1);
KNI_DeclareHandle(object_handle);
KNI_GetParameterAsObject(0, object_handle);
if(*object_handle) {
#if FAST_KNI && defined(CLDCHI)
rayintr_class* object = (rayintr_class*)*object_handle;
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)object->rayintersection_handle;
if(handle && --handle->reference_count == 0) {
ENTER_M3D_CS;
M3G_RayIntersection_finalize(handle);
LEAVE_M3D_CS;
}
#else
ASSERT(0);
#endif /* KNI */
}
KNI_EndHandles();
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_FLOAT
Java_javax_microedition_m3g_RayIntersection_getDistanceImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
//KNI_ReturnFloat(handle->distance);
KNI_ReturnFloat(M3G_RayIntersection_getDistance(handle));
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_RayIntersection_getIntersectedImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
//KNI_ReturnInt((jint)handle->intersected_node);
KNI_ReturnInt((jint)M3G_RayIntersection_getIntersected(handle));
}
KNIEXPORT KNI_RETURNTYPE_FLOAT
Java_javax_microedition_m3g_RayIntersection_getNormalXImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
//KNI_ReturnFloat(handle->normal[0]);
KNI_ReturnFloat(M3G_RayIntersection_getNormalX(handle));
}
KNIEXPORT KNI_RETURNTYPE_FLOAT
Java_javax_microedition_m3g_RayIntersection_getNormalYImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
//KNI_ReturnFloat(handle->normal[1]);
KNI_ReturnFloat(M3G_RayIntersection_getNormalY(handle));
}
KNIEXPORT KNI_RETURNTYPE_FLOAT
Java_javax_microedition_m3g_RayIntersection_getNormalZImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
//KNI_ReturnFloat(handle->normal[2]);
KNI_ReturnFloat(M3G_RayIntersection_getNormalZ(handle));
}
KNIEXPORT KNI_RETURNTYPE_INT
Java_javax_microedition_m3g_RayIntersection_getSubmeshIndexImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
//KNI_ReturnInt(handle->intersected_submesh_indx);
KNI_ReturnInt(M3G_RayIntersection_getSubmeshIndex(handle));
}
KNIEXPORT KNI_RETURNTYPE_FLOAT
Java_javax_microedition_m3g_RayIntersection_getTextureSImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
jint index = KNI_GetParameterAsInt(2);
jfloat result = 0.0f;
if (index < 0 || index > m3g_graphics3d.max_texunits) {
KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid index");
} else {
st_m3g_node *node = handle->intersected_node;
if(node) {
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
result = M3G_RayIntersection_getTextureS(handle, index);
}
}
KNI_ReturnFloat(result);
}
KNIEXPORT KNI_RETURNTYPE_FLOAT
Java_javax_microedition_m3g_RayIntersection_getTextureTImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
jint index = KNI_GetParameterAsInt(2);
jfloat result = 0.0f;
if (index < 0 || index > m3g_graphics3d.max_texunits) {
KNI_ThrowNew("java/lang/IndexOutOfBoundsException", "invalid index");
} else {
st_m3g_node *node = handle->intersected_node;
if(node) {
#if 0
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
/* under construction !*/
#endif
result = M3G_RayIntersection_getTextureT(handle, index);
}
}
KNI_ReturnFloat(result);
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_RayIntersection_getRayImpl()
{
st_m3g_rayintersection* handle = (st_m3g_rayintersection*)KNI_GetParameterAsInt(1);
int len = 0;
KNI_StartHandles(1);
KNI_DeclareHandle(object_handle);
KNI_GetParameterAsObject(2, object_handle);
if (*object_handle == NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null array");
} else {
len = KNI_GetArrayLength(object_handle);
if (len < 6) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid array");
} else {
#if FAST_KNI && defined(CLDCHI)
float *ray = ((jfloat_array*)*object_handle)->elements;
#else
ASSERT(0);
#endif /* FAST_KNI */
M3G_RayIntersection_getRay(handle, ray);
}
}
KNI_EndHandles();
KNI_ReturnVoid();
}
#endif /* #ifdef SUPPORT_JSR_184 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -