//---------------------------------------------------------------------------
//	Ninja Sample
//	COPYRIGHT (C) SEGA ENTERPRISES, LTD.
//	
//	CameraEx:	UFOMan Demo
//---------------------------------------------------------------------------
#include	<shinobi.h>
#include	"nj.h"
#include	"Common.h"

static float		frame_no;

static NJS_POINT3		CameraPos;


void UFOManDemo2( int State )
{
	if ( State == STATE_ATTACH ) {
		nuLoadTexture( UFOMAN_TEXLIST );
		
		njPushMatrix( &_nj_unit_matrix_ );
		
		frame_no	= 0.0f;
	}
	else if ( State == STATE_DETACH ) {
		njPopMatrix( 1 );
		
		njReleaseTexture( UFOMAN_TEXLIST );
		
		//	画角を初期状態に戻す
		njSetPerspective( NJM_DEG_ANG( 60.0f ) );
		
	}
	else {
		//	ライトの設定
		njCnkSetEasyLight( 0.0f, -0.7f, -0.7f );
		njCnkSetEasyLightIntensity( 1.0f, 0.2f );
		njCnkSetEasyLightColor( 1.0f, 1.0f, 1.0f );
		
		njCnkSetSimpleLight( 0.0f, -0.7f, -0.7f );
		njCnkSetSimpleLightIntensity( 1.0f, 0.2f );
		njCnkSetSimpleLightColor( 1.0f, 1.0f, 1.0f );
		
		njPushMatrix( &_nj_unit_matrix_ );
		njCameraMotion( UFOMAN_CAMERA, UFOMAN_CAMOTION, frame_no );
		
		
		//	描画
		njPushMatrix( NULL );
		//njTranslate( NULL, 0.0f, 0.0f, -2000.0f );
		njSetTexture( UFOMAN_TEXLIST );
		njCnkSimpleDrawShapeMotion( UFOMAN_OBJECT, UFOMAN_MOTION, UFOMAN_SHAPE, frame_no );
		njPopMatrix( 1 );
		
		
		njPopMatrix( 1 );
		
		frame_no	+= 0.5f;
		
		if( frame_no >= UFOMAN_MOTION->nbFrame - 1.0f ) {
			frame_no	= 0.0f;
		}
	}
}
