void CPhysicsObject::InitFromTemplate( CPhysicsEnvironment *pEnvironment, void *pGameData, const vphysics_save_cphysicsobject_t &objectTemplate ) { m_collideType = objectTemplate.collideType; IVP_Template_Real_Object ivpObjectTemplate; IVP_U_Quat rotation; IVP_U_Point pos; ConvertRotationToIVP( objectTemplate.angles, rotation ); ConvertPositionToIVP( objectTemplate.origin, pos ); ivpObjectTemplate.mass = objectTemplate.mass; if ( objectTemplate.materialIndex >= 0 ) { ivpObjectTemplate.material = physprops->GetIVPMaterial( objectTemplate.materialIndex ); } else { ivpObjectTemplate.material = physprops->GetIVPMaterial( physprops->GetSurfaceIndex( "default" ) ); } Assert( ivpObjectTemplate.material ); // HACKHACK: Pass this name in for debug ivpObjectTemplate.set_name(objectTemplate.pName); ivpObjectTemplate.set_nocoll_group_ident( NULL ); ivpObjectTemplate.physical_unmoveable = objectTemplate.isStatic ? IVP_TRUE : IVP_FALSE; ivpObjectTemplate.rot_inertia_is_factor = IVP_TRUE; ivpObjectTemplate.rot_inertia.set( 1,1,1 ); ivpObjectTemplate.rot_speed_damp_factor.set( objectTemplate.rotSpeedDamping, objectTemplate.rotSpeedDamping, objectTemplate.rotSpeedDamping ); ivpObjectTemplate.speed_damp_factor = objectTemplate.speedDamping; IVP_U_Matrix massCenterMatrix; massCenterMatrix.init(); const Vector *massOverride = 0; if ( objectTemplate.massCenterOverride != vec3_origin ) { IVP_U_Point center; ConvertPositionToIVP( objectTemplate.massCenterOverride, center ); massCenterMatrix.shift_os( ¢er ); ivpObjectTemplate.mass_center_override = &massCenterMatrix; massOverride = &objectTemplate.massCenterOverride; } IVP_Real_Object *realObject = NULL; if ( m_collideType == COLLIDE_BALL ) { IVP_Template_Ball ballTemplate; ballTemplate.radius = ConvertDistanceToIVP( objectTemplate.sphereRadius ); realObject = pEnvironment->GetIVPEnvironment()->create_ball( &ballTemplate, &ivpObjectTemplate, &rotation, &pos ); } else { const IVP_Compact_Surface *pSurface = (const IVP_Compact_Surface *)objectTemplate.pCollide; IVP_SurfaceManager_Polygon *surman = new IVP_SurfaceManager_Polygon( pSurface ); realObject = pEnvironment->GetIVPEnvironment()->create_polygon(surman, &ivpObjectTemplate, &rotation, &pos); } Init( realObject, objectTemplate.materialIndex, objectTemplate.volume, objectTemplate.dragCoefficient, objectTemplate.dragCoefficient, massOverride ); SetInertia( objectTemplate.rotInertia ); // will wake up the object if ( objectTemplate.velocity.LengthSqr() != 0 || objectTemplate.angVelocity.LengthSqr() != 0 ) { Assert( !objectTemplate.isAsleep ); SetVelocity( &objectTemplate.velocity, &objectTemplate.angVelocity ); } SetCallbackFlags( (unsigned short) objectTemplate.callbacks ); SetGameFlags( (unsigned short) objectTemplate.gameFlags ); SetGameData( pGameData ); SetContents( objectTemplate.contentsMask ); if ( objectTemplate.dragEnabled ) { Assert( !objectTemplate.isStatic ); EnableDrag( true ); } if ( !objectTemplate.motionEnabled ) { Assert( !objectTemplate.isStatic ); EnableMotion( false ); } if ( objectTemplate.isTrigger ) { BecomeTrigger(); } if ( !objectTemplate.gravityEnabled ) { EnableGravity( false ); } if ( objectTemplate.collisionEnabled ) { EnableCollisions( true ); } if ( !objectTemplate.isAsleep ) { Assert( !objectTemplate.isStatic ); Wake(); } m_pShadow = NULL; }
/*メイン関数*/ void TextClass::Main(UserClass &User){ //メニューパラメータセット static struct MenuArg_rec MenuRightParam; SetMenuParam_GameRight(MenuRightParam); static MenuClass GameRightMenu(MenuRightParam); //定数 const int OtherSelect = 6; //ゲームカウントの初期化 InitGameCount(User); //テキストチェック CheckText(User); //制御コードチェック if( WriteMode != EYECATCH ) CheckCotrolCode(User); //背景描画 Graph.DrawBack(User); //キャラクタ描画 Graph.DrawChar(User); //テキストボックス描画 if( WriteMode != NOTWINDOW ) Graph.DrawWindow(); //描画モード取得 //WriteMode = GetWriteMode(); //コンフィグで未読スキップ許可設定 ReadUpdate(User); //既読チェック CheckRead(); //デバッグ用既読操作 ControlRead(); //メニュー設置・処理 if( WriteMode == NORMAL ){ GameRightMenu.Create(); Select = GameRightMenu.GetSelectNo(); } //テキスト描画 if( WriteMode == NORMAL ) NormalWrite(User); //通常テキスト描画 if( WriteMode == EYECATCH ) EyeCatching(User); //アイキャッチ if( WriteMode == BACKLOG ) BackLogMain(User); //バックログ if( WriteMode == NOTWINDOW ) NotWindow(); //ウィンドウ非表示 if( WriteMode == END ) GameEnd(User); //ゲーム終了 //メニューを選択していなければ、テキストを進める・スキップ・オート if( Select == OtherSelect && WriteMode == NORMAL){ PutNextLine(User); //SkipFunction(User); AutoFunction(User); } //現在のカウントをセット SetGameData(User); }