void TankTop::Initialize(float x, float y, float z){ //RegisterForAutomated(); DeregisterForUpdate(); Matrix temp = Matrix(); tankTopScale.set( SCALE, 10.0f, 10.0f, 10.0f); //tankShellRot.set( ROT_XYZ, rotation[x],rotation[y] , rotation[z]); tankTopPos = Vect(x,y,z); temp = tankTopScale * tankTopRot * Matrix( TRANS, tankTopPos ); // SetGameObjectWorld(temp); tankTopScale.set( SCALE, 5000.0f, 5000.0f, 5000.0f); temp = tankTopScale * tankTopRot * Matrix( TRANS, tankTopPos ); RegisterCollision(this); }
TankTop::TankTop(Vect& position,Vect& scale,Vect& rotation,Tank* owner){ hit =false; //SoundSystem::SetMainVolume(1.0f); //DeregisterFromAutomated(); DeregisterToDraw(); myOwner = owner; Matrix temp = Matrix(); tankTopScale.set( SCALE, scale[x], scale[y], scale[z]); tankTopRot.set( ROT_XYZ, rotation[x],rotation[y] , rotation[z]); tankTopPos = position; temp = tankTopScale * tankTopRot * Matrix( TRANS, tankTopPos ); // SetGameObjectWorld(temp); SetGraphicAndCollisionModel(GraphicsObjectMaker::CreateGraphicsObjectFlatTexture(AssetManager::GetModel("TankTopModel"),AssetManager::GetTexture("TankTopTexture")), OOBBVolume); RegisterCollision(this); }
/*========================================================= Streaming::LoadArchive Arguments: archive - pointer to the IMG archive entry (probably just filename) imgID - index of the loading IMG archive Purpose: Loads an IMG archive into the streaming management memory. This allocates entries for COL libraries and IPL sectors. Paintjobs are allocated and models validated. Binary offsets: (1.0 US and 1.0 EU): 0x005B6170 =========================================================*/ static void __cdecl LoadArchive( IMGFile& archive, unsigned int imgID ) { CFile *file = OpenGlobalStream( archive.name, "rb" ); // We should always find the IMG container. Do a security check anyway. // NOTE: Rockstar did this too. if ( !file ) return; modelId_t lastID = 0xFFFFFFFF; union { char version[8]; // has to be "VER2" unsigned int checksum; }; memset( version, 0, 5 ); file->Read( version, 1, 4 ); assert( checksum == '2REV' ); int numFiles; bool successful = file->ReadInt( numFiles ); // Bugfix: make sure we read the file entry count properly. if ( successful ) { // Load all files one by one while ( numFiles ) { numFiles--; resourceFileHeader header; file->Read( &header, 1, sizeof(header) ); if ( header.primaryBlockOffset > biggestResourceBlockCount ) biggestResourceBlockCount = header.primaryBlockOffset; // Zero terminated for safety header.name[ sizeof(header.name) - 1 ] = '\0'; char *dot = strchr( header.name, '.' ); if ( !dot || (size_t)( dot - header.name ) > 20 ) { header.name[ sizeof(header.name) - 1 ] = '\0'; goto failureAdd; } const char *ext = dot + 1; *dot = '\0'; modelId_t id; if ( strnicmp( ext, "DFF", 3 ) == 0 ) { if ( !GetModelByName( header.name, &id ) ) { // We found a structure that has no representation in the game configuration files. // Native GTA:SA supports about 550 of such models. // We can still load such data through .SCM there (RequestSpecialModel). // That is done by storing the resourceFileHeader in a special stack. header.offset = Streaming::GetFileHandle( imgID, header.offset ); // Some sort of debug container (*VAR_MissingModelInfo)->Add( header ); goto failureAdd; } } else if ( strnicmp( ext, "TXD", 3 ) == 0 ) { int txdId = pGame->GetTextureManager()->FindTxdEntry( header.name ); if ( txdId == -1 ) { txdId = pGame->GetTextureManager()->CreateTxdEntry( header.name ); // Assign the txd to a vehicle if found a valid one TxdAssignVehiclePaintjob( header.name, txdId ); } id = (modelId_t)( txdId + DATA_TEXTURE_BLOCK ); } else if ( strnicmp( ext, "COL", 3 ) == 0 ) { id = DATA_COLL_BLOCK + RegisterCollision( header.name ); } else if ( strnicmp( ext, "IPL", 3 ) == 0 ) { unsigned int iplIndex = FindIPLFile( header.name ); if ( iplIndex == 0xFFFFFFFF ) { iplIndex = GetIPLEnvironment().RegisterInstance( header.name ); } id = iplIndex + DATA_IPL_BLOCK; } else if ( strnicmp( ext, "DAT", 3 ) == 0 ) { sscanf( header.name + 5, "%d", &id ); id += DATA_PATHFIND_BLOCK; } else if ( strnicmp( ext, "IFP", 3 ) == 0 ) { id = DATA_ANIM_BLOCK + pGame->GetAnimManager()->RegisterAnimBlock( header.name ); } else if ( strnicmp( ext, "RRR", 3 ) == 0 ) { id = DATA_RECORD_BLOCK + pGame->GetRecordings()->Register( header.name ); } else if ( strnicmp( ext, "SCM", 3 ) == 0 ) { // For now we do not need these script files. // If we ever need them, contact midnightStar/Martin. #ifdef _DEBUG OutputDebugString( "found unsupported SCM file: " ); OutputDebugString( header.name ); OutputDebugString( "\n" ); #endif //_DEBUG goto failureAdd; } else { *dot = '.'; goto failureAdd; } // Prepare the loading of this resource by storing its offset and IMG archive index unsigned int offset, count; // If this ID slot is already occupied, skip preparing this resource. CModelLoadInfoSA& info = Streaming::GetModelLoadInfo( id ); if ( info.GetOffset( offset, count ) ) goto failureAdd; info.m_imgID = imgID; if ( header.secondaryBlockOffset != 0 ) header.primaryBlockOffset = header.secondaryBlockOffset; info.SetOffset( header.offset, header.primaryBlockOffset ); info.m_flags = 0; // This id is used to optimize loading from disk. // The streaming system knows which data is next to each other. // It can be loaded in a swipe. if ( lastID != 0xFFFFFFFF ) Streaming::GetModelLoadInfo( lastID ).m_lastID = id; lastID = id; continue; failureAdd: lastID = 0xFFFFFFFF; } } delete file; }