#include #include #include class dMeteor : public dStageActor_c { int onCreate(); int onDelete(); int onExecute(); int onDraw(); static dMeteor *build(); mHeapAllocator_c allocator; m3d::mdl_c bodyModel; nw4r::g3d::ResFile resFile; int timer; int spinSpeed; char spinDir; Physics MakeItRound; void updateModelMatrices(); }; dMeteor *dMeteor::build() { void *buffer = AllocFromGameHeap1(sizeof(dMeteor)); return new(buffer) dMeteor; } // extern "C" dStageActor_c *GetSpecificPlayerActor(int num); // extern "C" void *modifyPlayerPropertiesWithRollingObject(dStageActor_c *Player, float _52C); extern "C" void *spinningPhysicsCallback(); int dMeteor::onCreate() { // Setup Model allocator.link(-1, GameHeaps[0], 0, 0x20); this->resFile.data = getResource("kazan_rock", "g3d/kazan_rock.brres"); nw4r::g3d::ResMdl mdl = this->resFile.GetResMdl("kazan_rock"); bodyModel.setup(mdl, &allocator, 0x224, 1, 0); SetupTextures_Enemy(&bodyModel, 0); allocator.unlink(); // Retrieve Scale and set it up float sca = (float)((this->settings >> 8) & 0xFF); sca = (sca/5.0) + 0.2; this->scale = (Vec){sca,sca,sca}; // Other settings this->spinDir = this->settings & 0x1; this->spinSpeed = ((this->settings >> 16) & 0xFF) * 80; // Setup Physics MakeItRound.baseSetup(this, &spinningPhysicsCallback, 0, 0, 1, 0); MakeItRound.x = 0.0; MakeItRound.y = 0.0; MakeItRound.diameter = 16.0 * sca; MakeItRound.isRound = 1; MakeItRound.update(); MakeItRound.addToList(); this->pos.z = -3458.0; this->onExecute(); return true; } int dMeteor::onDelete() { return true; } int dMeteor::onExecute() { if (spinDir == 0) { rot.z -= spinSpeed; } else { rot.z += spinSpeed; } MakeItRound.update(); updateModelMatrices(); // 518 == opposite of direction // for (i=0; i<4; i++) { // dStageActor_c *player = GetSpecificPlayerActor(i); // modifyPlayerPropertiesWithRollingObject(player, ); // } return true; } int dMeteor::onDraw() { bodyModel.scheduleForDrawing(); bodyModel._vf1C(); return true; } void dMeteor::updateModelMatrices() { // This won't work with wrap because I'm lazy. matrix.translation(pos.x, pos.y, pos.z); matrix.applyRotationYXZ(&rot.x, &rot.y, &rot.z); bodyModel.setDrawMatrix(matrix); bodyModel.setScale(&scale); bodyModel.calcWorld(false); }