Ejemplo n.º 1
0
void
GUISettingsHandler::applyViewport(GUISUMOAbstractView* view) const {
    if (myLookFrom.z() > 0) {
        // z value stores zoom so we must convert first
        Position lookFrom(myLookFrom.x(), myLookFrom.y(), view->getChanger().zoom2ZPos(myLookFrom.z()));
        view->setViewportFromToRot(lookFrom, myLookAt, myRotation);
    }
}
Ejemplo n.º 2
0
Archivo: 3d.c Proyecto: hrldcpr/iso
void display() {
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  glViewport(0, VIEW_HEIGHT, VIEW_WIDTH, VIEW_HEIGHT);
  lookFrom(1, 1, 1, 0, 0, 1); // isometric
  draw();

  glViewport(VIEW_WIDTH, VIEW_HEIGHT, VIEW_WIDTH, VIEW_HEIGHT);
  lookFrom(1, 0, 0, 0, 0, 1); // YZ
  draw();

  glViewport(0, 0, VIEW_WIDTH, VIEW_HEIGHT);
  lookFrom(0, 1, 0, 0, 0, 1); // XZ
  draw();

  glViewport(VIEW_WIDTH, 0, VIEW_WIDTH, VIEW_HEIGHT);
  lookFrom(0, 0, 1, 0, 1, 0); // YZ
  draw();

  glutSwapBuffers();
}
void ChunkPhotographer::setStates( Chunk& chunk )
{
	//first, setup some rendering options.
	//we need to draw as cheaply as possible, and
	//not clobber the main pipeline.

	Waters::simulationEnabled(false);
	Waters::drawReflection(false);

	ChunkFlare::ignore( true );
    EditorChunkLink::enableDraw( false );
    EditorChunkStationNode::enableDraw( false );
	PySplodge::s_ignoreSplodge_ = true;
	Rain::disable( true );
	g_disableSkyLightMap = true;    

	//save some states we are about to change
	oldFOV_ = Moo::rc().camera().fov();
	savedLighting_ = Moo::rc().lightContainer();
	savedChunkLighting_ = &ChunkManager::instance().cameraSpace()->enviro().timeOfDay()->lighting();
	oldInvView_ = Moo::rc().invView();

	//create some lighting
	if ( !lighting_ )
	{
		Vector4 ambientColour( 0.08f,0.02f,0.1f,1.f );

		//outside lighting for chunks
		chunkLighting_.sunTransform.setRotateX( DEG_TO_RAD(90.f) );
		chunkLighting_.sunTransform.postRotateZ( DEG_TO_RAD(20.f) );
		chunkLighting_.sunColour.set( 1.f, 1.f, 1.f, 1.f );		
		chunkLighting_.ambientColour = ambientColour;

		//light container for terrain
		Moo::DirectionalLightPtr spDirectional = new Moo::DirectionalLight(
			Moo::Colour(1,1,1,1), Vector3(0,0,-1.f) );
		spDirectional->worldTransform( chunkLighting_.sunTransform );

		lighting_ = new Moo::LightContainer;
		lighting_->ambientColour( Moo::Colour( ambientColour ) );
		lighting_->addDirectional( spDirectional );
	}

	Moo::rc().lightContainer( lighting_ );

	//setup the correct transform for the given chunk.
	//adds of .25 is for the near clipping plane.
	std::vector<ChunkItemPtr> items;
	EditorChunkCache::instance(chunk).allItems( items );
	BoundingBox bb( Vector3::zero(), Vector3::zero() );
	for( std::vector<ChunkItemPtr>::iterator iter = items.begin(); iter != items.end(); ++iter )
		(*iter)->addYBounds( bb );
	Matrix view;
	Vector3 lookFrom( chunk.transform().applyToOrigin() );	
	lookFrom.x += GRID_RESOLUTION / 2.f;
	lookFrom.z += GRID_RESOLUTION / 2.f;
	lookFrom.y = bb.maxBounds().y + 0.25f + 300.f;

	float chunkHeight = bb.maxBounds().y - bb.minBounds().y + 320.f;
	view.lookAt( lookFrom, Vector3(0,-1,0), Vector3(0,0,1) );
	Moo::rc().push();
	Moo::rc().world( Matrix::identity );
	Matrix proj;
	proj.orthogonalProjection( GRID_RESOLUTION, GRID_RESOLUTION, 0.25f, chunkHeight + 0.25f );
	Moo::rc().view( view );
	Moo::rc().projection( proj );
	Moo::rc().updateViewTransforms();
	Terrain::BaseTerrainRenderer::instance()->enableSpecular( false );

	//make sure there are no states set into the main part of bigbang
	//that could upset the rendering
	Moo::rc().setRenderState( D3DRS_FILLMODE, D3DFILL_SOLID );
	Moo::rc().fogEnabled( false );
	FogController::instance().enable( false );	
}
Ejemplo n.º 4
0
Archivo: core.cpp Proyecto: bo0ts/mango
 /**
  * Position and orient the camera so that it is looking from one
  * point at another point.
  *
  * @see lookAt
  */
 void CoreCamera::lookFrom(Vector from_point, Vector at_point){
   focus_frame->position = at_point;
   lookFrom(from_point);
 }
Ejemplo n.º 5
0
bool HexMapTest::UpdateKey() {
	CIwMat   rotation;
    CIwVec3  lookFrom(0,0,0);

	if (KeyPressed(s3eKeyPageUp)) {
		if (KeyAltDown()) {
			rotation.SetAxisAngle(
				s_viewMatrix.RotateVec(s_left),
				IW_ANGLE_FROM_DEGREES(0));
			lookFrom = (s_viewMatrix * rotation).RotateVec(
				s_cameraPos);
			updateLookAt(lookFrom);
		} else {
			s_viewMatrix.t[2] -= 0x010;
			if (s_cameraPos.z<-0x40)
				s_cameraPos.z += 0x40;
		}
	}

	if (KeyPressed(s3eKeyPageDown))
	{
		if (KeyAltDown()) {
			s_cameraPos.z -= 0x40;
			rotation.SetAxisAngle(
				s_viewMatrix.RotateVec(s_left),
				IW_ANGLE_FROM_DEGREES(0));
			lookFrom = (s_viewMatrix * rotation).RotateVec(
				s_cameraPos);
			updateLookAt(lookFrom);
		} else {
			s_viewMatrix.t[2] += 0x010;
		}
	}

    // Up, Down, Left, Right keys
    //

    if (KeyPressed(s3eKeyUp))
    {
		if (KeyAltDown()) {
			rotation.SetAxisAngle(
				s_viewMatrix.RotateVec(s_left),
				IW_ANGLE_FROM_DEGREES(-5));
			lookFrom = (s_viewMatrix * rotation).RotateVec(
				s_cameraPos);
			updateLookAt(lookFrom);
		} else {
			s_viewMatrix.t[1] -= 0x010;
		}
    }

    if (KeyPressed(s3eKeyDown))
    {
		if (KeyAltDown()) {
			rotation.SetAxisAngle(
				s_viewMatrix.RotateVec(s_left),
				IW_ANGLE_FROM_DEGREES(5));
			lookFrom = (s_viewMatrix * rotation).RotateVec(
				s_cameraPos);
			updateLookAt(lookFrom);
		} else {
			s_viewMatrix.t[1] += 0x010;
		}
    }

    if (KeyPressed(s3eKeyRight))
    {
		if (KeyAltDown()) {
			rotation.SetAxisAngle(
				s_viewMatrix.TransformVec(s_up),
				IW_ANGLE_FROM_DEGREES(5));
			lookFrom = (s_viewMatrix * rotation).RotateVec(
				s_cameraPos);
			updateLookAt(lookFrom);
		} else {
			s_viewMatrix.t[0] += 0x010;
		}
    }

	if (KeyPressed(s3eKeyLeft))
    {
		if (KeyAltDown()) {
			rotation.SetAxisAngle(
				s_viewMatrix.TransformVec(s_up),
				IW_ANGLE_FROM_DEGREES(-5));
			lookFrom = (s_viewMatrix * rotation).RotateVec(
				s_cameraPos);
			updateLookAt(lookFrom);
		} else {
			s_viewMatrix.t[0] -= 0x010;
		}
    }
	return true;
}
Ejemplo n.º 6
0
Archivo: 3d.c Proyecto: hrldcpr/iso
void mouse(int button, int state, int u, int v) {
  if (button == GLUT_LEFT_BUTTON) {
    if (state == GLUT_DOWN) {
      mouse_x = u;
      mouse_y = v;
    }
    else if (state == GLUT_UP) {
      if (!dragging) {
        double model[16], projection[16], x, y, z, near[3], far[3];
        int viewport[4];
        float depth;

        glViewport(0, VIEW_HEIGHT, VIEW_WIDTH, VIEW_HEIGHT);
        lookFrom(1, 1, 1, 0, 0, 1); // isometric

        glGetDoublev(GL_MODELVIEW_MATRIX, model);
        glGetDoublev(GL_PROJECTION_MATRIX, projection);
        glGetIntegerv(GL_VIEWPORT, viewport);

        v = 2 * VIEW_HEIGHT - v;

        glReadPixels(u, v, 1, 1, // the 1x1 rect at (u,v)
                     GL_DEPTH_COMPONENT, GL_FLOAT, &depth);

        if (depth > 0 && depth < 1) { // not clipped
          gluUnProject(u, v, depth,
                       model, projection, viewport,
                       &x, &y, &z);
        }
        else { // clipped or empty
          gluUnProject(u, v, 0,
                       model, projection, viewport,
                       near + 0, near + 1, near + 2);
          gluUnProject(u, v, 1,
                       model, projection, viewport,
                       far + 0, far + 1, far + 2);
          intercept(near, far, &x, &y);
          z = 0;
        }

        x = round(x);
        y = round(y);
        z = round(z);
        Cube **prev = &cubes, *next = *prev;
        while (next) {
          if (next->x == x && next->y == y && next->z == z)
            break;
          prev = &next->next;
          next = *prev;
        }
        if (next) {// hit
          *prev = next->next; // remove from list
          Ball *ball = balls;
          while(ball) {
            if (ball->cube == next)
              ball->cube = NULL;
            ball = ball->next;
          }
        }
        else
          add_cube(x, y, z);
      }

      dragging = 0;
    }

    glutPostRedisplay();
  }
}