#include "newtonbody.bmx.release.win32.x86.h"
static BBString _s0={
	&bbStringClass,
	1,
	{9}
};
static BBString _s1={
	&bbStringClass,
	4,
	{66,51,68,58}
};
struct BBDebugScope_10{int kind; const char *name; BBDebugDecl decls[11]; };
void __m_newtonbody_TNewtonBody_New(struct _m_newtonbody_TNewtonBody_obj* o) {
	_newton_dynamics_TNBody_New(o);
	o->clas = (BBClass*)&_m_newtonbody_TNewtonBody;
	o->__m_newtonbody_tnewtonbody_mesh = &bbNullObject;
	o->__m_newtonbody_tnewtonbody_mass = .0f;
	o->__m_newtonbody_tnewtonbody_shadow = &bbNullObject;
}
void __m_newtonbody_TNewtonBody_OnTransform_pfi(struct _m_newtonbody_TNewtonBody_obj* o,BBFLOAT* bbt_matrix,BBINT bbt_threadIndex){
	((struct _m_newtonbody_TNewtonBody_obj*)o)->clas->m_AlignEntity_pf(o,bbt_matrix);
}
void __m_newtonbody_TNewtonBody_OnForceAndTorque_fi(struct _m_newtonbody_TNewtonBody_obj* o,BBFLOAT bbt_timestamp,BBINT bbt_threadIndex){
	BBFLOAT bbt__mass=.0f;
	BBFLOAT bbt_Ixx=.0f;
	BBFLOAT bbt_Iyy=.0f;
	BBFLOAT bbt_Izz=.0f;
	((struct newton_dynamics_TNBody_obj*)o)->clas->m_GetMassMatrix_vfvfvfvf(o,(&bbt__mass),(&bbt_Ixx),(&bbt_Iyy),(&bbt_Izz));
	((struct newton_dynamics_TNBody_obj*)o)->clas->m_SetForce_ffff(o,(0.0f*bbt__mass),(-0.987f*bbt__mass),(0.0f*bbt__mass),1.0f);
}
void __m_newtonbody_TNewtonBody_ToggleShadow_i(struct _m_newtonbody_TNewtonBody_obj* o,BBINT bbt_toggle){
	if(bbt_toggle!=0){
		o->__m_newtonbody_tnewtonbody_shadow =openb3d_openb3dex_CreateShadow(o->__m_newtonbody_tnewtonbody_mesh ,0);
	}else{
		if(o->__m_newtonbody_tnewtonbody_shadow != &bbNullObject){
			openb3d_openb3dex_FreeShadow(o->__m_newtonbody_tnewtonbody_shadow );
			o->__m_newtonbody_tnewtonbody_shadow =&bbNullObject;
		}
	}
}
void __m_newtonbody_TNewtonBody_Remove(struct _m_newtonbody_TNewtonBody_obj* o){
	((struct _m_newtonbody_TNewtonBody_obj*)o)->clas->m_ToggleShadow_i(o,0);
	if(o->__m_newtonbody_tnewtonbody_mesh != &bbNullObject){
		openb3d_openb3dex_FreeEntity((struct openb3d_openb3dex_TEntity_obj*)bbObjectDowncast(o->__m_newtonbody_tnewtonbody_mesh ,&openb3d_openb3dex_TEntity));
		o->__m_newtonbody_tnewtonbody_mesh =&bbNullObject;
	}
	((struct newton_dynamics_TNBody_obj*)o)->clas->m_Destroy(o);
}
BBINT __m_newtonbody_TNewtonBody_AlignNewtonMatrix_TTNMatrix(struct _m_newtonbody_TNewtonBody_obj* o,struct newton_dynamics_TNMatrix_obj* bbt_newton_matrix){
	bbMemCopy((void*)(((BBBYTE*)bbt_newton_matrix)+(sizeof(void*))),(const void*)((BBBYTE*)o->__m_newtonbody_tnewtonbody_mesh ->_openb3d_openb3dex_tentity_mat ->_openb3d_openb3dex_tmatrix_grid ),(size_t)64LL);
	return 0;
}
BBINT __m_newtonbody_TNewtonBody_AlignEntity_pf(struct _m_newtonbody_TNewtonBody_obj* o,BBFLOAT* bbt_newton_matrix){
	(o->__m_newtonbody_tnewtonbody_mesh )->clas->m_MQ_ApplyNewtonTransform_pf(o->__m_newtonbody_tnewtonbody_mesh ,bbt_newton_matrix);
	return 0;
}
struct BBDebugScope_10 _m_newtonbody_TNewtonBody_scope ={
	BBDEBUGSCOPE_USERTYPE,
	"TNewtonBody",
	{
		{
			BBDEBUGDECL_FIELD,
			"mesh",
			":TMesh",
			.field_offset=offsetof(struct _m_newtonbody_TNewtonBody_obj,__m_newtonbody_tnewtonbody_mesh)
		},
		{
			BBDEBUGDECL_FIELD,
			"mass",
			"f",
			.field_offset=offsetof(struct _m_newtonbody_TNewtonBody_obj,__m_newtonbody_tnewtonbody_mass)
		},
		{
			BBDEBUGDECL_FIELD,
			"shadow",
			":TShadowObject",
			.field_offset=offsetof(struct _m_newtonbody_TNewtonBody_obj,__m_newtonbody_tnewtonbody_shadow)
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"New",
			"()",
			&__m_newtonbody_TNewtonBody_New
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"OnTransform",
			"(*f,i)",
			&__m_newtonbody_TNewtonBody_OnTransform_pfi
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"OnForceAndTorque",
			"(f,i)",
			&__m_newtonbody_TNewtonBody_OnForceAndTorque_fi
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"ToggleShadow",
			"(i)",
			&__m_newtonbody_TNewtonBody_ToggleShadow_i
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"Remove",
			"()",
			&__m_newtonbody_TNewtonBody_Remove
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"AlignNewtonMatrix",
			"(:TNMatrix)i",
			&__m_newtonbody_TNewtonBody_AlignNewtonMatrix_TTNMatrix
		},
		{
			BBDEBUGDECL_TYPEMETHOD,
			"AlignEntity",
			"(*f)i",
			&__m_newtonbody_TNewtonBody_AlignEntity_pf
		},
		BBDEBUGDECL_END
	}
};
struct BBClass__m_newtonbody_TNewtonBody _m_newtonbody_TNewtonBody={
	&newton_dynamics_TNBody,
	bbObjectFree,
	&_m_newtonbody_TNewtonBody_scope,
	sizeof(struct _m_newtonbody_TNewtonBody_obj),
	__m_newtonbody_TNewtonBody_New,
	bbObjectDtor,
	bbObjectToString,
	bbObjectCompare,
	bbObjectSendMessage,
	0,
	0,
	offsetof(struct _m_newtonbody_TNewtonBody_obj,__m_newtonbody_tnewtonbody_shadow) - sizeof(void*) + sizeof(struct openb3d_openb3dex_TShadowObject_obj*)
	,__m_newtonbody_TNewtonBody_OnForceAndTorque_fi
	,__m_newtonbody_TNewtonBody_OnTransform_pfi
	,_newton_dynamics_TNBody_SetMatrix_TTNMatrix
	,_newton_dynamics_TNBody_GetMatrix_TTNMatrix
	,_newton_dynamics_TNBody_GetMassMatrix_vfvfvfvf
	,_newton_dynamics_TNBody_GetRotation_vfvfvfvf
	,_newton_dynamics_TNBody_GetInvMass_vfvfvfvf
	,_newton_dynamics_TNBody_GetInertiaMatrix_TTNMatrix
	,_newton_dynamics_TNBody_GetInvInertiaMatrix_TTNMatrix
	,_newton_dynamics_TNBody_GetOmega_vfvfvf
	,_newton_dynamics_TNBody_GetVelocity_vfvfvf
	,_newton_dynamics_TNBody_GetForce_vfvfvf
	,_newton_dynamics_TNBody_GetTorque_vfvfvf
	,_newton_dynamics_TNBody_GetForceAcc_vfvfvf
	,_newton_dynamics_TNBody_GetTorqueAcc_vfvfvf
	,_newton_dynamics_TNBody_GetCentreOfMass_vfvfvf
	,_newton_dynamics_TNBody_GetAngularDamping_vfvfvf
	,_newton_dynamics_TNBody_NewtonBodyGetAABB_vfvfvfvfvfvf
	,_newton_dynamics_TNBody_SetAngularDamping_fff
	,_newton_dynamics_TNBody_SetForceAndTorqueCallback_F_TTNBodyfi_v_
	,_newton_dynamics_TNBody_SetTransformCallback_F_TTNBodypfi_v_
	,_newton_dynamics_TNBody_SetOmega_ffff
	,_newton_dynamics_TNBody_SetForce_ffff
	,_newton_dynamics_TNBody_SetVelocity_ffff
	,_newton_dynamics_TNBody_SetTorque_ffff
	,_newton_dynamics_TNBody_SetMassProperties_fTTNCollision
	,_newton_dynamics_TNBody_SetLinearDamping_f
	,_newton_dynamics_TNBody_GetType
	,_newton_dynamics_TNBody_GetCollidable
	,_newton_dynamics_TNBody_SetCollidable_i
	,_newton_dynamics_TNBody_AddForce_fff
	,_newton_dynamics_TNBody_AddTorque_fff
	,_newton_dynamics_TNBody_CalculateInverseDynamicsForce_ffffvfvfvf
	,newton_dynamics_TNBody__forceAndTorqueCallback_v_pbfi
	,newton_dynamics_TNBody__defaultForceAndTorqueCallback_v_pbfi
	,newton_dynamics_TNBody__transformCallback_v_pbpfi
	,newton_dynamics_TNBody__defaultTransformCallback_v_pbpfi
	,_newton_dynamics_TNBody_Destroy
	,__m_newtonbody_TNewtonBody_ToggleShadow_i
	,__m_newtonbody_TNewtonBody_Remove
	,__m_newtonbody_TNewtonBody_AlignNewtonMatrix_TTNMatrix
	,__m_newtonbody_TNewtonBody_AlignEntity_pf
};

BBINT _m_newtonbody_PrintMatrix(struct openb3d_openb3dex_TMatrix_obj* bbt_matrix,BBINT bbt_indent){
	BBSTRING bbt_id=&bbEmptyString;
	{
		BBINT bbt_loop=0;
		BBINT bbt_=bbt_indent;
		for(bbt_loop;(bbt_loop<bbt_);bbt_loop=(bbt_loop+1)){
			bbt_id=bbStringConcat(bbt_id,&_s0);
		}
	}
	brl_standardio_Print(bbStringConcat(bbt_id,&_s1));
	brl_standardio_Print(&bbEmptyString);
	{
		BBFLOAT bbt_y=0.000000000f;
		for(bbt_y;(bbt_y<=3.00000000f);bbt_y=(bbt_y+1.00000000f)){
			brl_standardio_Print(bbStringConcat(bbStringConcat(bbStringConcat(bbStringConcat(bbStringConcat(bbStringConcat(bbStringConcat(bbStringConcat(bbt_id,bbStringFromFloat(bbt_matrix->_openb3d_openb3dex_tmatrix_grid [((BBUINT)(bbt_y*4.00000000f))])),&_s0),bbStringFromFloat(bbt_matrix->_openb3d_openb3dex_tmatrix_grid [((BBUINT)((bbt_y*4.00000000f)+1.00000000f))])),&_s0),bbStringFromFloat(bbt_matrix->_openb3d_openb3dex_tmatrix_grid [((BBUINT)((bbt_y*4.00000000f)+2.00000000f))])),&_s0),bbStringFromFloat(bbt_matrix->_openb3d_openb3dex_tmatrix_grid [((BBUINT)((bbt_y*4.00000000f)+3.00000000f))])),&_s0));
		}
	}
	brl_standardio_Print(&bbEmptyString);
	return 0;
}
static int _bb_newtonb3d_newtonbody_inited = 0;
int _bb_newtonb3d_newtonbody(){
	if (!_bb_newtonb3d_newtonbody_inited) {
		_bb_newtonb3d_newtonbody_inited = 1;
		__bb_brl_blitz_blitz();
		__bb_brl_appstub_appstub();
		__bb_brl_audio_audio();
		__bb_brl_bank_bank();
		__bb_brl_bankstream_bankstream();
		__bb_brl_basic_basic();
		__bb_brl_bmploader_bmploader();
		__bb_brl_d3d7max2d_d3d7max2d();
		__bb_brl_d3d9max2d_d3d9max2d();
		__bb_brl_data_data();
		__bb_brl_directsoundaudio_directsoundaudio();
		__bb_brl_eventqueue_eventqueue();
		__bb_brl_freeaudioaudio_freeaudioaudio();
		__bb_brl_freetypefont_freetypefont();
		__bb_brl_glgraphics_glgraphics();
		__bb_brl_glmax2d_glmax2d();
		__bb_brl_gnet_gnet();
		__bb_brl_jpgloader_jpgloader();
		__bb_brl_map_map();
		__bb_brl_maxlua_maxlua();
		__bb_brl_maxutil_maxutil();
		__bb_brl_oggloader_oggloader();
		__bb_brl_openalaudio_openalaudio();
		__bb_brl_pngloader_pngloader();
		__bb_brl_retro_retro();
		__bb_brl_tgaloader_tgaloader();
		__bb_brl_threads_threads();
		__bb_brl_timer_timer();
		__bb_brl_timerdefault_timerdefault();
		__bb_brl_wavloader_wavloader();
		__bb_pub_freejoy_freejoy();
		__bb_pub_freeprocess_freeprocess();
		__bb_pub_macos_macos();
		__bb_pub_opengles_opengles();
		__bb_pub_vulkan_vulkan();
		__bb_pub_xmmintrin_xmmintrin();
		__bb_newton_dynamics_dynamics();
		__bb_openb3d_b3dglgraphics_b3dglgraphics();
		bbObjectRegisterType(&_m_newtonbody_TNewtonBody);
		return 0;
	}
	return 0;
}