コード例 #1
0
int MOAIFmodEventMgr::_playVoiceLine ( lua_State* L ) {
    MOAILuaState state ( L );

    cc8* linename	= state.GetValue < cc8* >( 1, "" );
    if ( linename[0] != '\0' ) {

        FMODDesigner::LineCode lineCode = FMODDesigner::LineCode( linename );

        cc8* eventName = state.GetValue < cc8* > ( 2, "" );
        if ( eventName[0] != '\0' ) {

            const FMODDesigner::Event* pEvent = MOAIFmodEventMgr::Get().GetEvent( eventName );
            if ( !pEvent )
            {
                FMODDesigner::Event actualEvent = FMODDesigner::Event( STLString( eventName ) );
                MOAIFmodEventMgr::Get().AddEvent( eventName, actualEvent );
                pEvent = MOAIFmodEventMgr::Get().GetEvent( eventName );
            }

            if ( pEvent->IsValid() ) {
                const FMODDesigner::EventProperties* pProperties = FMODDesigner::tEventManager.GetEventProperties( *pEvent );
                if( pProperties )
                {
                    FMODDesigner::EventHandle hEventHandle;

                    if ( !pProperties->m_is3D ) {
                        // Play the line, which should be the same as the event, at full volume
                        hEventHandle = FMODDesigner::tEventManager.PlayEvent2D( *pEvent, false, &lineCode );
                    }
                    else if ( pProperties->m_headRelative ) {
                        // Head relative sounds are basically 2D, except played as 3D w/ a zero position.
                        hEventHandle = FMODDesigner::tEventManager.PlayEvent3D( *pEvent, ZLVec3D( 0.f, 0.f, 0.f ), false, ZLVec3D( 0.f, 0.f, 0.f ), &lineCode );
                    }
                    else {
                        float x = state.GetValue < float > ( 3, 0.f );
                        float y = state.GetValue < float > ( 4, 0.f );
                        float z = state.GetValue < float > ( 5, 0.f );

                        hEventHandle = FMODDesigner::tEventManager.PlayEvent3D( *pEvent, ZLVec3D( x, y, z ), false, ZLVec3D( 0.f, 0.f, 0.f ), &lineCode );
                    }

                    if ( *hEventHandle )
                    {
                        MOAIFmodEventInstance* pEventInstance = new MOAIFmodEventInstance();
                        pEventInstance->SetEventInstance( hEventHandle );
                        pEventInstance->PushLuaUserdata ( state );

                        return 1;
                    }
                }
            }
        }
    }

    return 0;
}
コード例 #2
0
// Copyright (c) 2010-2011 Zipline Games, Inc. All Rights Reserved.
// http://getmoai.com

#include "pch.h"
#include <moai-sim/MOAIVectorUtil.h>
#include <tesselator.h>
#include <signal.h>
#include <setjmp.h>
#include <zl-vfs/assert.h>

//================================================================//
// SafeTesselator
//================================================================//

const ZLVec3D SafeTesselator::sNormal = ZLVec3D ( 0.0f, 0.0f, 1.0f );

//----------------------------------------------------------------//
void SafeTesselator::GetTriangles ( MOAIVertexBuffer& vtxBuffer, MOAIIndexBuffer& idxBuffer ) {

	ZLMemStream idxStream;
	ZLMemStream vtxStream;

	const int* elems = tessGetElements ( this->mTess );
	const int nelems = tessGetElementCount ( this->mTess );
	
	for ( int i = 0; i < nelems; ++i ) {
		const int* tri = &elems [ i * 3 ];
		
		idxStream.Write < u32 >( tri [ 0 ]);
		idxStream.Write < u32 >( tri [ 1 ]);
		idxStream.Write < u32 >( tri [ 2 ]);
コード例 #3
0
int MOAIFmodEventMgr::_playEvent3D ( lua_State* L ) {
    MOAILuaState state ( L );

    cc8* eventName = state.GetValue < cc8* > ( 1, "" );
    if ( eventName[0] != '\0' ) {

        const FMODDesigner::Event* pEvent = MOAIFmodEventMgr::Get().GetEvent( eventName );
        if ( !pEvent )
        {
            FMODDesigner::Event actualEvent = FMODDesigner::Event( STLString( eventName ) );
            MOAIFmodEventMgr::Get().AddEvent( eventName, actualEvent );
            pEvent = MOAIFmodEventMgr::Get().GetEvent( eventName );
        }

        if ( pEvent->IsValid() ) {

            float x = state.GetValue < float > ( 2, 0.f );
            float y = state.GetValue < float > ( 3, 0.f );
            float z = state.GetValue < float > ( 4, 0.f );

            bool bLoop = state.GetValue( 5, false );

            // Try to play the sound
            FMODDesigner::EventHandle hEventHandle = FMODDesigner::tEventManager.PlayEvent3D( *pEvent, ZLVec3D( x, y, z ), bLoop );

            // Create a MOAI Event Instance and push it out
            MOAIFmodEventInstance* pEventInstance = new MOAIFmodEventInstance();
            pEventInstance->SetEventInstance( hEventHandle );
            pEventInstance->PushLuaUserdata ( state );

            return 1;
        }
    }

    return 0;
}