示例#1
0
void CBoxProxyView::OnSize(UINT nType, int cx, int cy)
{
	CView::OnSize(nType, cx, cy);

	height=cy;
	width=cx;

	if (gettingDepth)
		return;

	resize(width,height);
	updateCam();
	/*float ratio = 1.0* cx/ cy;

	// Reset the coordinate system before modifying
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	// Set the viewport to be the entire window
	glViewport(0, 0, cx, cy);

	// Set the correct perspective.
	gluPerspective(45,ratio,1,1000);
	glMatrixMode(GL_MODELVIEW);*/
	// 设置视口
	
	/*glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0, (GLfloat)cx/(GLfloat)cy, 0.001, 5000.0);

	// 设置模型视图矩阵
	updateCam();*/
	// TODO: 在此处添加消息处理程序代码
}
示例#2
0
文件: main.cpp 项目: g0mb4/glutFPScam
void renderScene(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    	glLoadIdentity();

    	camControl(0.05, 0.02, key, mx, my);
    	updateCam();

	glBegin(GL_QUADS);
		glVertex3f(-100.0f, 0.0f, -100.0f);
		glVertex3f(-100.0f, 0.0f,  100.0f);
		glVertex3f( 100.0f, 0.0f,  100.0f);
		glVertex3f( 100.0f, 0.0f, -100.0f);
	glEnd();

	for(int i = -3; i < 3; i++)
		for(int j=-3; j < 3; j++) {
			glPushMatrix();
                		glTranslatef(i * 10.0, 0, j * 10.0);
                		drawSnowMan();
			glPopMatrix();
		}

	glutSwapBuffers();

	key = 0;
}
示例#3
0
void CBoxProxyView::OnMouseMove(UINT nFlags, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	if(MouseDown){
		if (lastPoint!=CPoint(0,0))
		{
			angle1+=(point.x-lastPoint.x)*up;
			angle2+=(point.y-lastPoint.y)*up;
			if (angle2>90)
			{
				angle1+=180;
				angle2=180-angle2;
				up=-up;
			}
			if(angle2<-90)
			{
				angle1+=180;
				angle2=-180-angle2;
				up=-up;
			}
			updateCam();
			CPaintDC dc(this);
			OnDraw(&dc);
		} 
		if(lastPoint!=point)
			lastPoint=point;		
	}

	CView::OnMouseMove(nFlags, point);
}
示例#4
0
void CBoxProxyView::OpenXmlFile(CString fileName)
{
	if (myDepthMap!=NULL)
		reset();
	defaultFileName=fileName;

	BoxCreator BoxCreator;

	Para para;
	BoxCreator.loadBoxFromFile(fileName,boxes,para);
	downDir=boxes.at(0).GetWmBox().Axis[para.downDirIndex];
	type=para.type;


	myDepthMap=new MyDepthMap(para.depthFileName,para.imgFileName);

	myDepthMap->LoadDepthFromFile();
	Vector3d offset=myDepthMap->GetUnProjectedPoints(points,pColors);
	cX=offset(0);
	cY=offset(1);
	cZ=offset(2);

	updateCam();
	CPaintDC dc(this);
	OnDraw(&dc);
}
示例#5
0
文件: Camera.cpp 项目: FRC830/Stone
	void CAMERAFEEDS::run() {
		/*
		if (contrlr->GetRawButton(CAMERAFEEDS::kBtCamFront)) {
			changeCam(camFront);
		}
		if (contrlr->GetRawButton(CAMERAFEEDS::kBtCamBack)) {
			changeCam(camBack);
		}*/
		updateCam();
	}
示例#6
0
void Engine::Graphics::update() {
  rt.clear();
  updateCam();
  rt.setView(camera);

  auto& entities = getEntities();
  for (auto e : entities) {
    Common::Point point;
    if (e.hasComponent<GamePosition>()) {
      auto& pos = e.getComponent<GamePosition>();
      point = pos.point;
    }

    if (e.hasComponent<Movable>()) {
      auto& pos = e.getComponent<Movable>();
      point = pos.position;
    }

    auto& drawable = e.getComponent<Drawable>();
    drawable.sprite.setPosition(sf::Vector2f{ point.x * TILESIZE, point.y * TILESIZE });
    rt.draw(drawable.sprite);
  }

  rt.display();

  auto tmngr = Game::Game::getGameInstance()->timeManager;

  if (tmngr->isOutatime()) {
    auto color = sf::Color::Black;
    if (tmngr->getTimeMultiplier() > 0) {
      color = sf::Color(0x0000FF00);
    }

    if (tmngr->getTimeMultiplier() < 0) {
      color = sf::Color(0x00FF0000);
    }

    float intensity = std::abs(tmngr->getTimeMultiplier()) * 0.35f;

    ppShader.setParameter("glowColor", color);
    ppShader.setParameter("intensity", intensity);
    window.draw(ppSprite, &ppShader);
  } else {

    window.draw(ppSprite);
  }

  for (auto& t : texts) {
    window.draw(t);
  }

  texts.clear();

  window.display();
}
示例#7
0
BOOL CBoxProxyView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	dist-=zDelta/1000.0;
	if (dist<0.1)
		dist=0.1;

	updateCam();
	CPaintDC dc(this);
	OnDraw(&dc);
	return CView::OnMouseWheel(nFlags, zDelta, pt);
}
示例#8
0
void onIdle()
{
  //meassure time
  time_passed=glutGet(GLUT_ELAPSED_TIME)-time_abs;
  time_abs=glutGet(GLUT_ELAPSED_TIME);

  //update camera
  updateCam();
  glm::mat4 view = glm::lookAt(cam_pos, cam_pos + cam_dir, cam_up);
  glm::mat4 projection = glm::perspective(45.0f, 1.0f*screen_width/screen_height, 0.1f, 100000.0f);
  glm::mat4 mvp = projection * view;
  simpleProgram->use();
  glUniformMatrix4fv(uniform_proj, 1, GL_FALSE, glm::value_ptr(mvp));

  //redisplay
  glutPostRedisplay();
}
void CAMERAFEEDS::run() {
    kBtPrev = kBtCurr;
    kBtCurr = contrlr->GetRawButton(CAMERAFEEDS::kBtCamToggle);

    if(kBtCurr == true && kBtPrev == false)
    {
        if (currCamNum == 1) {
            changeCam(camFront);
            currCamNum = 0;
        }
        else if (currCamNum == 0) {
            changeCam(camBack);
            currCamNum = 1;
        }
    }
    updateCam();
}
示例#10
0
void renderScene() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  // limpar o depth buffer

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    updateCam();
    renderFloor();

    modelPOR.Draw();

    //Testing the map car draw
    if(foundCars)
    {
        porTest1.Translate(redCar_x,0.33,redCar_z);
        porTest1.Draw();
        porTest2.Translate(blueCar_x,0.33,blueCar_z);
        porTest2.Draw();
    }
}
示例#11
0
void CBoxProxyView::GetDepthAfter()
{
	z=new float[640*480];
	glReadPixels(0,
		0,//y坐标
		640,480,//读取一个像素
		GL_RED,//获得深度信息
		GL_FLOAT,//数据类型为浮点型
		z);//获得的深度值保存在winZ中

	for (int y=0;y<240;y++)
	{
		for (int x=0;x<640;x++)
		{
			float tmp;
			int index1=y*640+x;
			int index2=(479-y)*640+x;
			tmp=z[index1];
			z[index1]=z[index2]*10;
			z[index2]=tmp*10;			
		}
	}
	if (testMode)
	{
		testDepthMap=new MyDepthMap(z,480,640);
		free(z);
		sd.removeShader();
		resize(width,height);
		updateCam();
		testRes=0;
		for (int x=0;x<640;x++)
		{
			for (int y=0;y<480;y++)
			{
				float tmp=fabs(testDepthMap->getDepth(x,y)-viewDepthMap->getDepth(x,y));	
				if (tmp>0)
				{
					testRes+=1;
				}
			}
		}
		delete testDepthMap;
		CString c;
		c.Format("%f",testRes);
		//MessageBox(c);
	}
	else
	{
		viewDepthMap=new MyDepthMap(z,480,640);
		float z1=viewDepthMap->getDepth(289,50);
		free(z);
		sd.removeShader();
		gettingDepth=false;
		resize(width,height);
		updateCam();
		float dz=0;
		for (int x=0;x<640;x++)
		{
			for (int y=0;y<480;y++)
			{
				float tmp=fabs(myDepthMap->getDepth(x,y)-viewDepthMap->getDepth(x,y));	
				if (tmp>0)
				{
					dz+=tmp;
				}
				if (tmp>0.08)
				{
					float tz=viewDepthMap->getDepth(x,y);
					Vector3d p1(x*tz,y*tz,tz);
					Vector3d p2;
					Vector4d tmpP=cam.unproject(p1);

					for (int i=0;i<3;i++)
					{
						p2(i)=tmpP(i)/tmpP(3);
					}
					Dpoints.push_back(p2);
					Vector3d p3=cam.project_homo(p2);
					float tz1=p3(2);
					tz1=tz1;
				}

			}
		}
		dz/=480*640;
		dz=dz;
		CString c;
		c.Format("%f",dz);
		//MessageBox(c);
		CPaintDC dc(this);
		OnDraw(&dc);
	}


}