void PlanetariumEngine::addCamera() { mCamera = new BasicCamera(mSceneManager); mSceneManager->setActiveCamera(mCamera->getIrrlichtCamera()); emit newCamera(); }
void GamePlay_01::init() { mat_manager = MaterialManager::getInstance(); mat_manager->enableDefaultMaterial(); cube_01 = new (EAllocationType::GAMEOBJECTS) CubeObjectTest("node_1"); light1 = SceneManager::getInstance()->createLight("light01",Light::LightTypes::LT_SPOTLIGHT); light1->setPosition(Vector3(0.0,0.0,8.0)); light1->setDirection(Vector3(0.0,0.0,-1.0)); light1->setType(Light::LightTypes::LT_SPOTLIGHT); //light1->setDiffuseColour(0.8,0.8,0.8); //light2 = SceneManager::getInstance()->createLight("light02",Light::LightTypes::LT_SPOTLIGHT); //light2->setPosition(Vector3(0.0,0.0,8.0)); //light2->setDirection(Vector3(0.0,0.0,-1.0)); //light2->setDiffuseColour(0.8,0.0,0.0); mat_01 = new Material ("mat_01"); tex2d = ResourceManager::getInstance()->loadTexture("texture.raw",256,256); //newAgeCube = new CubeObjectTest("d", Vector3 (0.0,0.0,0.0), Quaternion.IDENTITY); //SceneManager * sc_mn = SceneManager::getInstance(); cam = newCamera("camera1");//SceneManager::getInstance()->createCamera("camera1"); x_vel = 0; y_vel = 0; speed = 1; xrot = 1; yrot = 1; xrot_zero = 0; currentFramePositionx = 0; lastFramePositionx = 0; yrot_zero = 0; currentFramePositiony = 0; lastFramePositiony = 0; Root * mRoot = Root::getInstance(); cube_01->init(1); //cube_02->init(3); cam->setPosition(Vector3(0.0f,0.0f,-15.0f)); cube_01->mMesh->setMaterial(mat_01); mat_01->setDiffiuseColour(0.7,0.0,0.0); mat_01->setShineValue(110); //mat_01->setTexture2D(tex2d); }
AS3_Val initializeCamera( void* self, AS3_Val args ) { Camera * camera; Entity * eye; double fov, nearClip, farClip; AS3_ArrayValue( args, "PtrType, DoubleType, DoubleType, DoubleType", & eye, & fov, & nearClip, & farClip ); nearClip = nearClip < 5.0f ? 5.0f : nearClip; camera = newCamera( (float)fov, (float)nearClip, (float)farClip, eye ); return AS3_Array( "PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType", camera, camera->target, & camera->fov, & camera->near, & camera->far, & camera->fnfDirty, & camera->isUVN, &camera->rotationDirty, &camera->rotateX, &camera->rotateY, &camera->rotateZ, &camera->distance, &camera->factor, &camera->step, &camera->hoverType); }
Scene * newScene(GLboolean vsync) { Scene * scene = (Scene *) malloc(sizeof(Scene)); scene->context = (ContextSize *) malloc(sizeof(ContextSize)); scene->context->w = CONTEXT_WIDTH_INITIAL; scene->context->h = CONTEXT_HEIGHT_INITIAL; setupOpenGLContext(scene->context); checkOpenGLVersion(); setupOpenGLState(scene->context, vsync); scene->camera = newCamera(scene->context->w, scene->context->h); scene->world = getWorld("world.txt"); scene->water = getWater(); setupWater(scene->water->drawSP, scene->world); setupWorldUniforms(scene->world->sp, scene->water); return scene; }
MainWindow::MainWindow(MainController& ctrl, QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) , mController(ctrl) , mCurrentBodyWidget(0) , mIsTerminated(false) { irr::IrrlichtDevice* device = 0; ui->setupUi(this); /* Configure Irrlicht */ mIrrlichtWidget = new IrrlichtWidget(mController.getConfiguration().getGraphicsConfiguration(), ui->irrlichtContainer); ui->irrlichtLayout->addWidget(mIrrlichtWidget); device = mIrrlichtWidget->getIrrlichtDevice(); Engine::PlanetariumEngine* engine = mController.createEngine(device); mIrrlichtWidget->setEngine(engine); onNewCamera(); /* Add label to the status bar */ mStatusLabel = new QLabel(ui->statusBar); ui->statusBar->addWidget(mStatusLabel); /* Set status bar message */ mStatusLabel->setText(tr("Uninitialized")); /* Set initial values */ ui->speedSpin->setValue(ctrl.getSpeed()); ui->stepSpin->setValue(ctrl.getStep()); ui->scaleSpinBox->setValue(ctrl.getEngine()->getScale()); /* Connect GUI to controller */ // menu actions connect(ui->quitAction, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actionPreferences, SIGNAL(triggered()), this, SLOT(onPreferences())); connect(ui->openAction, SIGNAL(triggered()), this, SLOT(onOpen())); connect(ui->actionStart, SIGNAL(triggered()), this, SLOT(onPlayTriggered())); connect(ui->actionStop, SIGNAL(triggered()), this, SLOT(onStopTriggered())); // spin buttons connect(ui->speedSpin, SIGNAL(valueChanged(double)), &ctrl, SLOT(setSpeed(double))); connect(ui->stepSpin, SIGNAL(valueChanged(double)), &ctrl, SLOT(setStep(double))); connect(ui->scaleSpinBox, SIGNAL(valueChanged(double)), ctrl.getEngine(), SLOT(setScale(double))); connect(ui->xCamPos, SIGNAL(valueChanged(double)), this, SLOT(onCameraPositionChanged(double))); connect(ui->yCamPos, SIGNAL(valueChanged(double)), this, SLOT(onCameraPositionChanged(double))); connect(ui->zCamPos, SIGNAL(valueChanged(double)), this, SLOT(onCameraPositionChanged(double))); // control buttons connect(ui->playButton, SIGNAL(clicked()), this, SLOT(onPlayTriggered())); connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(onStopTriggered())); // List connect(ui->objectList, SIGNAL(currentRowChanged(int)), this, SLOT(onListSelectionChanged(int))); /* Connect controller event */ connect(&ctrl, SIGNAL(simulationStateChanged()), this, SLOT(simulationStateChanged())); connect(&ctrl, SIGNAL(model_updated()), this, SLOT(onSimulationUpdate())); connect(engine, SIGNAL(newCamera()), this, SLOT(onNewCamera())); }