📄 m3gtransformable.c
字号:
/*****************************************************************************
*
* Filename:
* ---------
* Transformable.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!
*------------------------------------------------------------------------------
* 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_VOID
Java_javax_microedition_m3g_Transformable_getCompositeTransformImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
st_m3g_transform* transform = (st_m3g_transform*)KNI_GetParameterAsInt(2);
if(transform == NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null handle");
} else {
M3G_Transformable_getCompositeTransform(handle, transform);
}
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_getOrientationImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
KNI_StartHandles(1);
KNI_DeclareHandle(orient_handle);
KNI_GetParameterAsObject(2, orient_handle);
if(*orient_handle == NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null handle");
} else {
#if FAST_KNI && defined(CLDCHI)
jfloat_array* orient = (jfloat_array*)*orient_handle;
if(orient->length < 4) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid orient");
} else {
//orient->elements[0] = _GL_X_2_FLOAT(handle->_orient_angle);
//_GL_X_2_FLOAT_NV(&orient->elements[1], handle->_orient_axis, 3);
M3G_Transformable_getOrientation(handle,orient->elements);
}
#else
ASSERT(0);
#endif /* FAST_KNI */
}
KNI_EndHandles();
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_getScaleImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
KNI_StartHandles(1);
KNI_DeclareHandle(scale_handle);
KNI_GetParameterAsObject(2, scale_handle);
if(*scale_handle == NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null handle");
} else {
#if FAST_KNI && defined(CLDCHI)
jfloat_array* scale = (jfloat_array*)*scale_handle;
if(scale->length < 3) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid scale");
} else {
//memcpy(scale->elements, handle->_scale, 3*sizeof(float));
M3G_Transformable_getScale(handle,scale->elements);
}
#else
ASSERT(0);
#endif /* FAST_KNI */
}
KNI_EndHandles();
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_getTransformImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
st_m3g_transform* transform = (st_m3g_transform*)KNI_GetParameterAsInt(2);
if(transform == NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null handle");
} else {
//memcpy(transform->matrix, handle->_transform, 16*sizeof(GLnative));
M3G_Transformable_getTransform(handle,transform);
}
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_getTranslationImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
KNI_StartHandles(1);
KNI_DeclareHandle(translation_handle);
KNI_GetParameterAsObject(2, translation_handle);
if(*translation_handle == NULL) {
KNI_ThrowNew("java/lang/NullPointerException", "null handle");
} else {
#if FAST_KNI && defined(CLDCHI)
jfloat_array* translation = (jfloat_array*)*translation_handle;
if(translation->length < 3) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid translation");
} else {
//memcpy(translation->elements, handle->_translation, 3*sizeof(float));
M3G_Transformable_getTranslation(handle,translation->elements);
}
#else
ASSERT(0);
#endif /* FAST_KNI */
}
KNI_EndHandles();
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_postRotateImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
jfloat angle = KNI_GetParameterAsFloat(2);
jfloat ax = KNI_GetParameterAsFloat(3);
jfloat ay = KNI_GetParameterAsFloat(4);
jfloat az = KNI_GetParameterAsFloat(5);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_POSTROTATE, handle, angle, (int)ax, (int)ay, (int)az);
if(ax==0.0f&&ay==0.0f&&az==0.0f&&angle!=0.0f) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid rotate");
} else {
M3G_Transformable_postRotate(handle, angle, ax, ay, az);
}
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_preRotateImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
jfloat angle = KNI_GetParameterAsFloat(2);
jfloat ax = KNI_GetParameterAsFloat(3);
jfloat ay = KNI_GetParameterAsFloat(4);
jfloat az = KNI_GetParameterAsFloat(5);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_PREROTATE, handle, (int)angle, (int)ax, (int)ay, (int)az);
if(ax==0.0f&&ay==0.0f&&az==0.0f&&angle!=0.0f) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid rotate");
} else {
M3G_Transformable_preRotate(handle, angle, ax, ay, az);
}
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_scaleImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
jfloat sx = KNI_GetParameterAsFloat(2);
jfloat sy = KNI_GetParameterAsFloat(3);
jfloat sz = KNI_GetParameterAsFloat(4);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_SCALE, handle, (int)sx, (int)sy, (int)sz);
M3G_Transformable_scale(handle, sx, sy, sz);
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_setOrientationImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
jfloat angle = KNI_GetParameterAsFloat(2);
jfloat ax = KNI_GetParameterAsFloat(3);
jfloat ay = KNI_GetParameterAsFloat(4);
jfloat az = KNI_GetParameterAsFloat(5);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_SETORIENTATION, handle, (int)angle, (int)ax, (int)ay, (int)az);
if(ax==0.0f&&ay==0.0f&&az==0.0f&&angle!=0.0f) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid orient");
} else {
M3G_Transformable_setOrientation(handle, angle, ax, ay, az);
}
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_setScaleImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
jfloat sx = KNI_GetParameterAsFloat(2);
jfloat sy = KNI_GetParameterAsFloat(3);
jfloat sz = KNI_GetParameterAsFloat(4);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_SETSCALE, handle, (int)sx, (int)sy, (int)sz);
M3G_Transformable_setScale(handle, sx, sy, sz);
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_setTransformImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
st_m3g_transform* transform = (st_m3g_transform*)KNI_GetParameterAsInt(2);
if(transform == NULL) {
_m3g_set_identity_matrix_4x4x(handle->_transform);
handle->transform_flags |= M3G_TRANSFORMABLE_MODEL_MATRIX;
} else if(IsInstanceOfNode((st_m3g_object3d*)handle) &&
(transform->matrix[3] != _GL_ZERO || transform->matrix[7] != _GL_ZERO ||
transform->matrix[11] != _GL_ZERO || transform->matrix[15] != _GL_ONE)) {
KNI_ThrowNew("java/lang/IllegalArgumentException", "invalid transform");
} else {
M3G_Transformable_setTransform(handle, transform);
}
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_setTranslationImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
jfloat tx = KNI_GetParameterAsFloat(2);
jfloat ty = KNI_GetParameterAsFloat(3);
jfloat tz = KNI_GetParameterAsFloat(4);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_SETTRANSLATION, handle, (int)tx, (int)ty, (int)tz);
M3G_Transformable_setTranslation(handle, tx, ty, tz);
KNI_ReturnVoid();
}
KNIEXPORT KNI_RETURNTYPE_VOID
Java_javax_microedition_m3g_Transformable_translateImpl()
{
st_m3g_transformable* handle = (st_m3g_transformable*)KNI_GetParameterAsInt(1);
jfloat tx = KNI_GetParameterAsFloat(2);
jfloat ty = KNI_GetParameterAsFloat(3);
jfloat tz = KNI_GetParameterAsFloat(4);
kal_trace(TRACE_GROUP_6, FUNC_J2ME_M3G_TRANSLATE, handle, (int)tx, (int)ty, (int)tz);
M3G_Transformable_translate(handle, tx, ty, tz);
KNI_ReturnVoid();
}
#endif /* #ifdef SUPPORT_JSR_184 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -