コード例 #1
0
ファイル: GIIHelper.cpp プロジェクト: pixpil/gii
int GIIHelper::_renderFrameBuffer( lua_State *L ){
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "U" )) return 0;
	MOAIFrameBufferRenderCommand* command = state.GetLuaObject < MOAIFrameBufferRenderCommand >( -1, false );
	if ( command ) {
		if ( command->IsEnabled() && command->GetFrameBuffer() ) {
			zglBegin();
			command->Render();
			zglEnd();
		}
	} else {
		MOAIFrameBuffer* frameBuffer = state.GetLuaObject < MOAIFrameBuffer >( -1, false );
		if ( frameBuffer ) {
			zglBegin();
			frameBuffer->Render ( NULL );
			zglEnd();
		}
	}
	// MOAIFrameBuffer* frameBuffer = state.GetLuaObject < MOAIFrameBuffer >( 1, false );
	// MOAIGfxDevice& device = MOAIGfxDevice::Get ();
	// if (frameBuffer) {
	// 	zglBegin();
	// 	frameBuffer->Render( NULL );
	// 	zglEnd();
	// }
	return 0;
}
コード例 #2
0
ファイル: GIIHelper.cpp プロジェクト: pixpil/gii
int GIIHelper::_stepSim( lua_State *L ){
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "N" )) return 0;
	double step = state.GetValue< double >( 1, 0.0f );
	GIIHelper::Get().stepSim( step );
	return 0;
}
コード例 #3
0
ファイル: GIIHelper.cpp プロジェクト: pixpil/gii
int GIIHelper::_setBufferSize( lua_State *L){
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "NN" )) return 0;
	u32 width=state.GetValue<u32>(1, 0);
	u32 height=state.GetValue<u32>(2, 0);
	MOAIGfxDevice::Get ().SetBufferSize ( width, height );
	return 0;
}
コード例 #4
0
ファイル: GIIHelper.cpp プロジェクト: pixpil/gii
int GIIHelper::_setVertexTransform( lua_State *L){
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "U" )) return 0;
	MOAITransformBase* trans = state.GetLuaObject< MOAITransformBase >(1, true);
	if ( trans ) {
		MOAIGfxDevice::Get().SetVertexTransform( MOAIGfxDevice::VTX_WORLD_TRANSFORM, trans->GetLocalToWorldMtx() );
	}
	return 0;
}
コード例 #5
0
ファイル: MOAILogMgr.cpp プロジェクト: Heyzap/moai-dev
/**	@name	openFile
	@text	Opens a new file to receive log messages.
	
	@in		string filename
	@out	nil
*/
int MOAILogMgr::_openFile ( lua_State* L ) {

	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "S" )) return 0;
	
	cc8* filename = state.GetValue < cc8* >( 1, "" );
	MOAILogMgr::Get ().OpenFile ( filename );
	
	return 0;
}
コード例 #6
0
ファイル: MOAILogMgr.cpp プロジェクト: Heyzap/moai-dev
/**	@name	log
	@text	Alias for print.
	
	@in		string message
	@out	nil
*/
int MOAILogMgr::_log ( lua_State* L ) {

	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "S" )) return 0;

	cc8* msg = state.GetValue < cc8* >( 1, "" );
	ZLLog::Print( msg );
	
	return 0;
}
コード例 #7
0
ファイル: MOAICpShape.cpp プロジェクト: AzureRodrigo/moai-dev
/**	@name	areaForRect
	@text	Returns the area for the specified rectangle.

	@in		number x1
	@in		number y1
	@in		number x2
	@in		number y2
	@out	number area			The calculated area.
*/
int MOAICpShape::_areaForRect ( lua_State* L ) {
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "NNNN" )) return 0;

	ZLMetaRect < cpFloat > rect = state.GetRect < cpFloat >( 1 );
	rect.Bless ();
	
	lua_pushnumber ( L, rect.Area ());
	return 1;
}
コード例 #8
0
/**	@name	timeToFrames
	@text	Converts the number of time passed in seconds to frames.

	@in		number time			The number of seconds.
	@out	number frames		The equivilant number of frames for the specified number of seconds.
*/
int MOAISim::_timeToFrames ( lua_State* L ) {

	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;
	
	float time = state.GetValue < float >( 1, 0.0f );
	
	MOAISim& device = MOAISim::Get ();
	lua_pushnumber ( state, time / device.mStep );
	
	return 1;
}
コード例 #9
0
/**	@name	showStyle
	@text	Enables of disables drawing of a given debug line style.
	
	@in		number styleID		See MOAIDebugLines class documentation for a list of styles.
	@opt	boolean show		Default value is 'true'
	@out	nil
*/
int MOAIDebugLines::_showStyle ( lua_State* L ) {

	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;
	
	u32 styleID		= state.GetValue < u32 >( 1, 0 );
	bool show		= state.GetValue < bool >( 2, true );
	
	MOAIDebugLines::Get ().ShowStyle ( styleID, show );
	
	return 0;
}
コード例 #10
0
/**	@name	framesToTime
	@text	Converts the number of frames to time passed in seconds.

	@in		number frames		The number of frames.
	@out	number time			The equivilant number of seconds for the specified number of frames.
*/
int MOAISim::_framesToTime ( lua_State* L ) {

	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;
	
	float frames = state.GetValue < float >( 1, 0.0f );
	
	MOAISim& device = MOAISim::Get ();
	lua_pushnumber ( state, frames * device.mStep );
	
	return 1;
}
コード例 #11
0
/**	@name	parseString
	@text	Parses the contents of the specified string as XML.

	@in		MOAIXmlParser self
	@in		string filename			The XML data stored in a string.
	@out	table data				A tree of tables representing the XML.
*/
int MOAIXmlParser::_parseString ( lua_State* L ) {

    MOAILuaState state ( L );
    if ( !state.CheckParams ( 1, "S" )) return 0;

    cc8* xml = lua_tostring ( state, 1 );

    TiXmlDocument doc;
    doc.Parse ( xml );
    MOAIXmlParser::Parse ( state, doc.RootElement ());

    return 1;
}
コード例 #12
0
/**	@name	removeRenderPass
	@text	Removes the specified prim from the render stack.

	@in		MOAIProp2D prop		The viewport of the render prim.
	@out	nil
*/
int MOAISim::_removeRenderPass ( lua_State* L ) {

	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "U" )) return 0;
	
	MOAIProp* prop = state.GetLuaObject < MOAIProp >( 1 );
	if ( !prop ) return 0;
	
	MOAISim& device = MOAISim::Get ();
	device.RemoveRenderPass ( prop );

	return 0;
}
コード例 #13
0
/**	@name	blockOnAction
	@text	Skip updating current thread until the specified action is
			no longer busy. A little more efficient than spinlocking from
			Lua.

	@in		MOAIAction blocker
	@out	nil
*/
int MOAICoroutine::_blockOnAction ( lua_State* L ) {
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "U" )) return 0;

	MOAIAction* current = MOAIActionMgr::Get ().GetCurrentAction ();
	if ( !current ) return 0;
	
	MOAIAction* blocker = state.GetLuaObject < MOAIAction >( 1, true );
	if ( !blocker || !blocker->IsBusy ()) return 0;
	
	current->SetBlocker ( blocker );
	
	return lua_yield ( state, 0 );
}
コード例 #14
0
ファイル: MOAILogMgr.cpp プロジェクト: Heyzap/moai-dev
/**	@name	registerLogMessage
	@text	Register a format string to handle a log message. Register
			an empty string to hide messages.
	
	@in		number messageID
	@opt	string formatString		Default value is an empty string.
	@opt	number level			One of MOAILogMgr.LOG_ERROR, MOAILogMgr.LOG_WARNING, MOAILogMgr.LOG_STATUS.
									Default value is MOAILogMgr.LOG_STATUS.
	@out	nil
*/
int MOAILogMgr::_registerLogMessage ( lua_State* L ) {
	UNUSED ( L );

	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;

	u32 messageID		= state.GetValue < u32 >( 1, 0 );
	cc8* formatString	= state.GetValue < cc8* >( 2, "" );
	u32 level			= state.GetValue < u32 >( 3, LOG_STATUS );

	MOAILogMgr::Get ().RegisterLogMessage ( messageID, level, formatString );

	return 0;
}
コード例 #15
0
/**	@name	parseFile
	@text	Parses the contents of the specified file as XML.

	@in		MOAIXmlParser self
	@in		string filename			The path of the file to read the XML data from.
	@out	table data				A tree of tables representing the XML.
*/
int MOAIXmlParser::_parseFile ( lua_State* L ) {

    MOAILuaState state ( L );
    if ( !state.CheckParams ( 1, "S" )) return 0;

    cc8* filename = lua_tostring ( state, 1 );

    if ( MOAILogMessages::CheckFileExists ( filename, L )) {
        TiXmlDocument doc;
        doc.LoadFile ( filename );
        MOAIXmlParser::Parse ( state, doc.RootElement ());
        return 1;
    }
    return 0;
}
コード例 #16
0
ファイル: MOAICpShape.cpp プロジェクト: AzureRodrigo/moai-dev
/**	@name	areaForCircle
	@text	Returns the area for a polygon.
	
	@in		table vertices Array containg vertex coordinate components ( t[1] = x0, t[2] = y0, t[3] = x1, t[4] = y1... )
	@out	number area
*/ 
int MOAICpShape::_areaForPolygon ( lua_State* L ) {
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "T" )) return 0;

	cpVect verts [ MAX_POLY_VERTS ];
	int numVerts = MOAICpShape::LoadVerts ( state, 1, verts, MAX_POLY_VERTS );
			
	if ( numVerts && cpPolyValidate ( verts, numVerts )) {
		cpFloat area = cpAreaForPoly ( numVerts, verts );
		area = area < 0 ? -area : area;
		lua_pushnumber ( L, area );
		return 1;
	}
	return 0;
}
コード例 #17
0
/**	@name	openWindow
	@text	Opens a new window for the application to render on.  This must be called before any rendering can be done, and it must only be called once.

	@in		string title		The title of the window.
	@in		number width		The width of the window in pixels.
	@in		number height		The height of the window in pixels.
	@out	nil
*/
int MOAISim::_openWindow ( lua_State* L ) {
	
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "SNN" )) return 0;
	
	cc8* title = lua_tostring ( state, 1 );
	u32 width = state.GetValue < u32 >( 2, 320 );
	u32 height = state.GetValue < u32 >( 3, 480 );

	OpenWindowFunc openWindow = MOAISim::Get ().GetOpenWindowFunc ();
	if ( openWindow ) {
		MOAIGfxDevice::Get ().SetBufferSize ( width, height );
		openWindow ( title, width, height );
	}

	return 0;
}
コード例 #18
0
ファイル: MOAICpShape.cpp プロジェクト: AzureRodrigo/moai-dev
/**	@name	areaForSegment
	@text	Returns the area for the specified segment.

	@in		number x1
	@in		number y1
	@in		number x2
	@in		number y2
	@in		number r
	@out	number area			The calculated area.
*/
int MOAICpShape::_areaForSegment ( lua_State* L ) {
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "UUNNNN" )) return 0;
	
	cpVect a;
	a.x = state.GetValue < cpFloat >( 1, 0 );
	a.y = state.GetValue < cpFloat >( 2, 0 );
	
	cpVect b;
	b.x = state.GetValue < cpFloat >( 3, 0 );
	b.y = state.GetValue < cpFloat >( 4, 0 );

	cpFloat r = state.GetValue < cpFloat >( 5, 0 );

	lua_pushnumber ( L, cpAreaForSegment ( a, b, r ));
	return 1;
}
コード例 #19
0
/**	@name	setStyle
	@text	Sets the particulars of a given debug line style.
	
	@in		number styleID		See MOAIDebugLines class documentation for a list of styles.
	@opt	number size			Pen size (in pixels) for the style. Default value is 1.
	@opt	number r			Red component of line color. Default value is 1.
	@opt	number g			Green component of line color. Default value is 1.
	@opt	number b			Blue component of line color. Default value is 1.
	@opt	number a			Alpha component of line color. Default value is 1.
	@out	nil
*/
int MOAIDebugLines::_setStyle ( lua_State* L ) {
	
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;
	
	u32 styleID		= state.GetValue < u32 >( 1, 0 );
	float size		= state.GetValue < float >( 2, 1.0f );
	float r			= state.GetValue < float >( 3, 1.0f );
	float g			= state.GetValue < float >( 4, 1.0f );
	float b			= state.GetValue < float >( 5, 1.0f );
	float a			= state.GetValue < float >( 6, 1.0f );
	
	u32 color = ZLColor::PackRGBA ( r, g, b, a );
	
	MOAIDebugLines::Get ().SetStyle ( styleID, size, color );
	
	return 0;
}
コード例 #20
0
ファイル: MOAILuaRuntime.cpp プロジェクト: flimshaw/moai-dev
//----------------------------------------------------------------//
int MOAILuaRuntime::_dump ( lua_State* L ) {
	UNUSED ( L );

	#if ( LUA_VERSION_NUM < 502 ) && ( !MOAI_WITH_LUAJIT )

		MOAILuaState state ( L );

		if ( !state.CheckParams ( 1, "S." )) return 0;

		cc8* name = state.GetValue < cc8* >( 1, "" );
		bool verbose = state.GetValue < bool >( 3, true );

		TableSet foundTables;
		_dumpType ( state, 2, name, verbose, foundTables );

	#endif

	return 0;
}
コード例 #21
0
ファイル: GIIHelper.cpp プロジェクト: pixpil/gii
int GIIHelper::_setWorldLoc( lua_State *L ){
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "UN" )) return 0;
	MOAITransform* dst = state.GetLuaObject< MOAITransform >(1, true);
	float x = state.GetValue< float >( 2, 0.0f );
	float y = state.GetValue< float >( 3, 0.0f );
	float z = state.GetValue< float >( 4, 0.0f );
	ZLVec3D loc;
	loc.Init( x, y, z );		
	const ZLAffine3D* inherit = dst->GetLinkedValue < ZLAffine3D* >( PACK_ATTR ( MOAITransformBase, MOAITransformBase::INHERIT_TRANSFORM ), 0 );	
	if( inherit ) {
		ZLAffine3D inverse;
		inverse.Inverse( *inherit ); 
		inverse.Transform( loc );
	}
	dst->SetLoc( loc );	
	dst->ScheduleUpdate();
	return 0;
}
コード例 #22
0
ファイル: MOAICpShape.cpp プロジェクト: AzureRodrigo/moai-dev
/**	@name	areaForCircle
	@text	Returns the area for a ring or circle.
	
	@overload
	
		@in		number radius
		@out	number area

	@overload
	
		@in		number innerRadius
		@in		number outerRadius
		@out	number area
*/ 
int MOAICpShape::_areaForCircle ( lua_State* L ) {
	MOAILuaState state ( L );
	if ( !state.CheckParams ( 1, "N" )) return 0;

	cpFloat r1;
	cpFloat r2;

	if ( state.GetTop () >= 2 ) {
		r1 = state.GetValue < cpFloat >( 1, 0 );
		r2 = state.GetValue < cpFloat >( 2, 0 );
		
	}
	else {
		r1 = 0;
		r2 = state.GetValue < cpFloat >( 1, 0 );
	}

	lua_pushnumber ( L, cpAreaForCircle ( r1, r2 ));
	return 1;
}
コード例 #23
0
ファイル: GIIHelper.cpp プロジェクト: pixpil/gii
int GIIHelper::_copyWorldTransform( lua_State *L ){
	ZLAffine3D tmp;
	ZLAffine3D tmp1;
	float rx,ry,rz;
	MOAILuaState state (L);
	if ( !state.CheckParams ( 1, "UU" )) return 0;
	MOAITransform* src = state.GetLuaObject< MOAITransform >(1, true);
	MOAITransform* dst = state.GetLuaObject< MOAITransform >(2, true);
	const ZLAffine3D& srcMtx = src->GetLocalToWorldMtx ();
	const ZLAffine3D* inherit = dst->GetLinkedValue < ZLAffine3D* >( PACK_ATTR ( MOAITransformBase, MOAITransformBase::INHERIT_TRANSFORM ), 0 );	
	tmp.Init( src->GetLocalToWorldMtx() );
	if( inherit ) {
		tmp1.Inverse( *inherit ); 
		tmp.Append( tmp1 );
	}
	ZLVec3D loc   = tmp.GetTranslation();
	ZLVec3D scale = tmp.GetStretch();
	dst->SetLoc( loc );
	dst->SetScl( scale );
	rz = tmp.GetRot();
	dst->SetRot( 0, 0, rz );
	dst->ScheduleUpdate();
	return 0;
}