void Enemy::init(Transform* player, glm::vec3 pos, EnemyType type) { this->player = player; Transform* model = registerModel(); transform->parentAll(model); glm::vec3 scale = glm::vec3(1.0f, 2.0f, 1.0f); glm::vec3 variance = Mth::randInsideUnitCube(); variance.x = variance.z = abs(variance.x); scale += variance * .25f; glm::vec3 color; switch (type) { case EnemyType::ELITE: { scale *= Mth::rand01() + 2.0f; color = glm::vec3(0.8f, 1.0f, 0.6f); speed = Mth::rand01() * 5.0f + 10.0f; jumpVel = Mth::rand01() * 10.0f + 30.0f; health = 100.0f; Transform* larm = registerModel(); Transform* rarm = registerModel(); larm->setPos(-scale.x * 0.75f, scale.y * 0.75f, 0.0f); rarm->setPos(scale.x * 0.75f, scale.y * 0.75f, 0.0f); larm->setScale(scale*0.75f); rarm->setScale(scale*0.75f); transform->parentAllWithColor(larm, rarm); break; } case EnemyType::BASIC: { color = glm::vec3(1.0f, Mth::rand01() * 0.3f, Mth::rand01() * 0.3f); speed = Mth::rand01() * 5.0f + 5.0f; jumpVel = Mth::rand01() * 10.0f + 20.0f; health = 20.0f; //scale = glm::vec3(0.75f, 2.0f, 0.75f); Transform* head = registerModel(); head->setPos(0.0f, scale.y * 0.75f, 0.0f); head->setScale(1.3f, 0.7f, 1.3f); head->color = glm::vec3(1.0f, 0.0f, 0.0f); transform->parentAll(head); break; } default: break; } transform->setPos(pos); model->setPos(0.0f, scale.y / 2.0f, 0.0f); model->setScale(scale); model->color = color; glm::vec3 min = glm::vec3(-0.5f, 0.0f, -0.5f)*scale; glm::vec3 max = glm::vec3(0.5f, 1.0f, 0.5f)*scale; collider->setExtents(min, max); }
void Subscribe::registerModels() { auto subscriptionModel = newModel("subscription", 0, QDate(2015, 9, 18)); subscriptionModel->addField("gid", ModelField::Integer).notNull(); subscriptionModel->addField("uid", ModelField::Integer).notNull(); subscriptionModel->addField("subscribed_on", ModelField::Timestamp); subscriptionModel->addUniqueIndex("gid", "uid"); subscriptionModel->addIndex("gid"); subscriptionModel->registerModel(); }
void CoreModel::registerModels() { auto installedModelModel = mBotInterface->newModel("core", "installed_model", 0, QDate(2015, 9, 17)); installedModelModel->addField("section", ModelField::String).notNull(); installedModelModel->addField("name", ModelField::String).notNull(); installedModelModel->addField("installed_version", ModelField::Integer).notNull(); installedModelModel->addField("version_date", ModelField::Timestamp); installedModelModel->addField("installed_date", ModelField::Timestamp); installedModelModel->addUniqueIndex("section", "name"); installedModelModel->registerModel(); }
CSMFModel *CModelManager::registerSMFModel(const std::string fname){ CModel *found = findModel(fname); if(found)return static_cast<CSMFModel*>(found); gcon.printString("Loading SMF model " + fname + "\n"); CSMFModelPtr model = new CSMFModel(this); model->load(fname, CEngine::getSingleton()->vfs); registerModel(model); return model; }
CSkelModel *CModelManager::registerSkelModel(const std::string fname){ CModel *found = findModel(fname); if(found)return static_cast<CSkelModel *>(found); gcon.printString("Loading skeletal model " + fname + "\n"); CSkelModelPtr model = new CSkelModel(this); try { model->load(fname, CEngine::getSingleton()->vfs); } catch (CException e) { CEngine::getSingleton()->con.printString("Failed to load : " + fname + "\n "); CEngine::getSingleton()->con.printString(e.getExplanation() + "\n"); return 0; } registerModel(model); return model; }