Exemplo n.º 1
0
//--------------------------------------------------------------
// initialize application
void DontHitMe::appInit()
{
  // get the important directories
  mgString shaderDir;
  m_options.getFileName("shaderDir", m_options.m_sourceFileName, "docs/shaders", shaderDir);
  mgString uiDir;
  m_options.getFileName("uiDir", m_options.m_sourceFileName, "docs/ui", uiDir);
  mgString fontDir;
  m_options.getFileName("fontDir", m_options.m_sourceFileName, "docs/fonts", fontDir);

  mgInitDisplayServices(shaderDir, fontDir);

  mgDisplay->setFOV(m_options.getDouble("FOV", 60.0));
  mgDisplay->setDPI(m_options.getInteger("DPI", 0));

  // load cursor pattern
  loadCursor();
  setDeskMode(true);

  initMovement();

  // load the shaders we might use
  mgVertex::loadShader("litTexture");
  mgVertex::loadShader("unlitTexture");
  mgVertex::loadShader("litTextureCube");
  mgVertex::loadShader("unlitTextureCube");
  mgVertexTA::loadShader("litTextureArray");
  mgVertexTA::loadShader("unlitTextureArray");

  m_sky = new StarrySky(m_options);
  m_sky->enableSkyBox(true);
  m_sky->enableStars(true);
  m_sky->enableSun(true);

  mgPoint3 lightDir(0, 1, 1);
  lightDir.normalize();
  m_sky->setSunDir(lightDir);

  mgDisplay->setLightDir(lightDir);

  m_saucer = new Saucer(m_options);
  m_planet = new Planet(m_options);

  m_wreck = new Wreck(m_options);
  m_tower1 = new Tower(m_options, false);
  m_tower2 = new Tower(m_options, false);

  mgString fileName;
  m_options.getFileName("tube", m_options.m_sourceFileName, "tube.jpg", fileName);
  m_tubeTexture = mgDisplay->loadTexture(fileName);

  initTrack();
  initBall();
  updateBallPt();

  m_intro = new Intro(m_options, m_ballOrigin);
  m_showingIntro = false;

  m_lastAnimate = mgOSGetTime();  // now!
}
Exemplo n.º 2
0
//--------------------------------------------------------------------
// initialize application
void GuiTestAll::appInit()
{
  // get the important directories
  mgString shaderDir;
  m_options.getFileName("shaderDir", m_options.m_sourceFileName, "docs/shaders", shaderDir);
  mgString uiDir;
  m_options.getFileName("uiDir", m_options.m_sourceFileName, "docs/ui", uiDir);
  mgString fontDir;
  m_options.getFileName("fontDir", m_options.m_sourceFileName, "docs/fonts", fontDir);

  mgInitDisplayServices(shaderDir, fontDir);

  mgDisplay->setDPI(m_options.getInteger("dpi", 0));
  mgDisplay->setFOV(m_options.getDouble("FOV", 60.0));

  mgString title;
  title.format("%s, %s", mgProgramName, mgProgramVersion);
  mgPlatform->setWindowTitle(title);

  // load the shaders we use
  mgVertex::loadShader("litTexture");
  mgVertexTA::loadShader("litTextureArray");

  // load cursor pattern
  loadCursor();
  setDeskMode(true);

  initMovement();
  m_lastAnimate = mgOSGetTime();  // now!

  // rotation angle for cube
  m_angle = 0.0;

  // load texture patterns
  loadTextures();

  // create vertex and index buffers
  m_cubeIndexes = NULL;
  m_cubeVertexes = NULL;
  m_floorVertexes = NULL;

  m_surface = mgDisplay->createOverlaySurface();

  mgString fileName;
  m_options.getFileName("helpFile", m_options.m_sourceFileName, "help.xml", fileName);
  m_ui = new SampleUI(m_surface, fileName);
}
Exemplo n.º 3
0
//--------------------------------------------------------------
// initialize application
void SeaOfMemes::appInit()
{
  // get the important directories
  mgString shaderDir;
  m_options.getFileName("shaderDir", m_options.m_sourceFileName, "docs/shaders", shaderDir);
  mgString uiDir;
  m_options.getFileName("uiDir", m_options.m_sourceFileName, "docs/ui", uiDir);
  mgString fontDir;
  m_options.getFileName("fontDir", m_options.m_sourceFileName, "docs/fonts", fontDir);

  mgInitDisplayServices(shaderDir, fontDir);

  mgDisplay->setDPI(m_options.getInteger("dpi", 0));
  mgDisplay->setFOV(m_options.getDouble("FOV", 60.0));

  // load cursors
  loadCursor();

  setDeskMode(true);

  // take units from option
  m_unitsMetric = m_options.getBoolean("metricUnits", true);

  // create the sky
  m_matColor = mgPoint3(1, 1, 1);
  m_lightDir = mgPoint3(1.0, 0.25, 0.0);
  m_lightDir.normalize();

  m_sky = new NebulaSky(m_options);
  m_sky->setSunDir(m_lightDir);

  m_world = new SolarSystem(m_options);

  m_helpUI = new HelpUI(m_options);
  m_helpUI->setDebugApp(this);

  m_speedUI = new SpeedUI(m_options);
  m_speedUI->setUnits(m_unitsMetric ? UNITS_KM : UNITS_MILES);

  appCreateBuffers();

  // initialize movement
  initMovement();
  m_lastAnimate = 0.0;
}
Exemplo n.º 4
0
//--------------------------------------------------------------
// initialize application
void MovementApp::appInit()
{
  // get the important directories
  mgString shaderDir;
  m_options.getFileName("shaderDir", m_options.m_sourceFileName, "docs/shaders", shaderDir);
  mgString uiDir;
  m_options.getFileName("uiDir", m_options.m_sourceFileName, "docs/ui", uiDir);
  mgString fontDir;
  m_options.getFileName("fontDir", m_options.m_sourceFileName, "docs/fonts", fontDir);

  mgInitDisplayServices(shaderDir, fontDir);

  mgDisplay->setDPI(m_options.getInteger("dpi", 0));
  mgDisplay->setFOV(m_options.getDouble("FOV", 60.0));

  // load cursor pattern
  loadCursor();
  setDeskMode(true);

  initMovement();
  m_lastAnimate = mgOSGetTime();  // now!
}
Exemplo n.º 5
0
void TrajectoryController::addPoint(unsigned long now, 				/* current time of caller */
									TimedPosition& pEye 			/* included time is used */,
									unsigned long startApproachingTime /* = 0 */) {
	if ((startApproachingTime  == 0) || (startApproachingTime  > pEye.atTime))
		startApproachingTime = pEye.atTime;

	TimedPosition eye(pEye);
	if (debugTrajectory) {
		eye.println("addPoint");
		/*
		bool saveDebugKinematic = debugKinematic;
		debugKinematic = true;
		Kinematics::getInstance().moveServosTo(pEye.pos);
		debugKinematic = saveDebugKinematic;
		*/
	}

	// check for boundaries first
	Kinematics::getInstance().limitPosition(eye.pos);

	// compute the point where we are at starting point.
	// Returns null point if current trajectory ends before startApproachingTime
	Position startPoint = getPointByTime(startApproachingTime);

	// is new point within the first interval that is currently running?
	bool pointIsInRunningCurve = (trajectory.size() >= 2) && (getPointByIndex(1).laterThan(startApproachingTime));

	// is new point within the next interval that is currently running?
	bool pointIsRightAfterRunningCurve = ((trajectory.size() >= 3) &&
			getPointByIndex(1).earlierThan(startApproachingTime) &&
			getPointByIndex(2).laterThan(startApproachingTime)) ||
		((trajectory.size() == 2) && getPointByIndex(1).earlierThan(startApproachingTime));

	// if movement start before last point, we have to change the current trajectory
	if (startApproachingTime < getLastTrajectoryEntry().atTime) {

		// remove all trajectory points happening after the starting time
		trajectory.removeLaterThan(startApproachingTime);

		// if the starting point happens earlier than the target position
		// add the predicted position at the starting time
		// (the new point is added anyhow later on)
		// then add an intermediate point the movement starts from
		if (startApproachingTime < eye.atTime) {
			// add starting point of new movement
			TimedPosition intermediatePoint(startApproachingTime,startPoint);
			trajectory.add(intermediatePoint);
			intermediatePoint.println("intermediate point");
		}
	}

	// add new position
	trajectory.add(eye);

	// we need at least two positions to move
	if (trajectory.size() >= 2) {
		if (!bezierCurve.isActive())
			initMovement(now,eye.atTime); // we start to move
		else {
			if (pointIsInRunningCurve || pointIsRightAfterRunningCurve) {
				adaptCurrentTrajectoryPiece(now); // we adapt current curve
			}
		}
	}
}