当前位置: 首页>>代码示例>>C++>>正文


C++ CameraController类代码示例

本文整理汇总了C++中CameraController的典型用法代码示例。如果您正苦于以下问题:C++ CameraController类的具体用法?C++ CameraController怎么用?C++ CameraController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CameraController类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: l_dev_set_camera_offset

/*
 * Set current camera offset to vector,
 * (the offset will reset when switching cameras)
 *
 * Dev.SetCameraOffset(x, y, z)
 */
static int l_dev_set_camera_offset(lua_State *l)
{
	if (!Pi::game || !Pi::game->GetWorldView())
		return luaL_error(l, "Dev.SetCameraOffset only works when there is a game running");
	CameraController *cam = Pi::game->GetWorldView()->GetCameraController();
	const float x = luaL_checknumber(l, 1);
	const float y = luaL_checknumber(l, 2);
	const float z = luaL_checknumber(l, 3);
	cam->SetPosition(vector3d(x, y, z));
	return 0;
}
开发者ID:Ikesters,项目名称:pioneer,代码行数:17,代码来源:LuaDev.cpp

示例2: main

int main(int argc, char** argv) {
	int nflats = 3;
	std::stringstream ss1;
	srand(time(NULL));
	ss1 << "flat" << rand()%1000 << "_";
	std::string flatTestName = ss1.str() + "test";
	std::string flatName = ss1.str();
	
	double exptime = 0.5;
	std::string iso = "200";
	double satVal = 16384;
	//	double satVal=3000;
	double thresVal = satVal/3;
	int ret;

	CameraController c;
	//take a flat with minimal exposure time, double exposure until threshold exceeded
	while(1) {
		ret = c.capture_to_file(flatTestName, exptime, iso);
		if (ret != GP_OK) {
			std::cout << "Error while capturing image" << std::endl;
			return ret;
		}
		double rval = get_average(flatTestName+"R.fits");
		double gval = get_average(flatTestName+"G.fits");
		double bval = get_average(flatTestName+"B.fits");
		std::cout << rval << " " << gval << " " << bval << std::endl;
		if (rval > thresVal && gval > thresVal && bval > thresVal) break;
		exptime *= 2;
	}
	//we've found a good value, so take flats
	for (int i=0; i < nflats; i++) {
		std::stringstream ss;
		ss << flatName << i;
		ret = c.capture_to_file(ss.str(), exptime, iso);
		if (ret != GP_OK) {
			std::cout << "Error while capturing image" << std::endl;
			return ret;
		}
	}
	return 0;
}
开发者ID:Bengoo,项目名称:dslrphoto,代码行数:42,代码来源:takeflats.cpp

示例3: _prof

void ModelViewer::Update( float deltaT )
{
	ScopedTimer _prof(L"Update State");

	m_pCameraController->Update(deltaT);
	m_ViewProjMatrix = m_Camera.GetViewProjMatrix();

	float costheta = cosf(m_SunOrientation);
	float sintheta = sinf(m_SunOrientation);
	float cosphi = cosf(m_SunInclination * 3.14159f * 0.5f);
	float sinphi = sinf(m_SunInclination * 3.14159f * 0.5f);
	m_SunDirection = Normalize(Vector3( costheta * cosphi, sinphi, sintheta * cosphi ));

	if (MotionBlur::TemporalAA)
	{
		// 2x super sampling with no feedback
		float SampleOffsets[2][2] =
		{
			{ -0.25f, -0.25f },
			{  0.25f,  0.25f },
		};
		const float* Offset = SampleOffsets[Graphics::GetFrameCount() % 2];

		m_MainViewport.TopLeftX = Offset[0];
		m_MainViewport.TopLeftY = Offset[1];
	}
	else
	{
		m_MainViewport.TopLeftX = 0.0f;
		m_MainViewport.TopLeftY = 0.0f;
	}

	m_MainViewport.Width = (float)g_SceneColorBuffer.GetWidth();
	m_MainViewport.Height = (float)g_SceneColorBuffer.GetHeight();
	m_MainViewport.MinDepth = 0.0f;
	m_MainViewport.MaxDepth = 1.0f;

	m_MainScissor.left = 0;
	m_MainScissor.top = 0;
	m_MainScissor.right = (LONG)g_SceneColorBuffer.GetWidth();
	m_MainScissor.bottom = (LONG)g_SceneColorBuffer.GetHeight();
}
开发者ID:GeorgeKps,项目名称:nBodyD3D12,代码行数:42,代码来源:ModelViewer.cpp

示例4: mouseEvent

void mouseEvent(int button, int state, int x, int y) {
    CameraController::MouseState mouseState;
    if (state == GLUT_DOWN) {
        switch (button) {
            case GLUT_LEFT_BUTTON : {
                                        mouseState = CameraController::LEFT_BTN;
                                        break;
                                    }
            case GLUT_RIGHT_BUTTON : {
                                         mouseState = CameraController::RIGHT_BTN;
                                         break;
                                     }
            default : break;
        }
    } else {
        mouseState = CameraController::NO_BTN;
    }
    camera.updateMouseBtn(mouseState, x, y);
    glutPostRedisplay();
}
开发者ID:CompN3rd,项目名称:cg2,代码行数:20,代码来源:Ex10.cpp

示例5: keyboardEvent

void keyboardEvent(unsigned char key, int x, int y) {
    switch (key) {
        case 'x':
        case 27 : {
                      exit(0);
                      break;
                  }
        case 'w': {
                      // move forward //
                      camera.move(CameraController::MOVE_FORWARD);
                      break;
                  }
        case 's': {
                      // move backward //
                      camera.move(CameraController::MOVE_BACKWARD);
                      break;
                  }
        case 'a': {
                      // move left //
                      camera.move(CameraController::MOVE_LEFT);
                      break;
                  }
        case 'd': {
                      // move right //
                      camera.move(CameraController::MOVE_RIGHT);
                      break;
                  }
        case 'z': {
                      camera.setOpeningAngle(camera.getOpeningAngle() + 0.1f);
                      break;
                  }
        case 'h': {
                      camera.setOpeningAngle(std::min(std::max(camera.getOpeningAngle() - 0.1f, 1.0f), 180.0f));
                      break;
                  }
        case 'r': {
                      camera.setNear(std::min(camera.getNear() + 0.1f, camera.getFar() - 0.01f));
                      break;
                  }
        case 'f': {
                      camera.setNear(std::max(camera.getNear() - 0.1f, 0.1f));
                      break;
                  }
        case 't': {
                      camera.setFar(camera.getFar() + 0.1f);
                      break;
                  }
        case 'g': {
                      camera.setFar(std::max(camera.getFar() - 0.1f, camera.getNear() + 0.01f));
                      break;
                  }
        case 'm': {
                      materialIndex++;
                      if (materialIndex >= materialCount) materialIndex = 0;
                      break;
                  }
        case '5': {
                      // reset light pos //
                      light.position = initialLightPos;
                      lightSourcePosUpdate = true;
                      break;
                  }
        case '4': {
                      // move light source left //
                      light.position.x -= 0.05f;
                      lightSourcePosUpdate = true;
                      break;
                  }
        case '6': {
                      // move light source right //
                      light.position.x += 0.05f;
                      lightSourcePosUpdate = true;
                      break;
                  }
        case '2': {
                      // move light source backward //
                      light.position.z += 0.05f;
                      lightSourcePosUpdate = true;
                      break;
                  }
        case '8': {
                      // move light source forward //
                      light.position.z -= 0.05f;
                      lightSourcePosUpdate = true;
                      break;
                  }
        case '+': {
                      // move light source up //
                      light.position.y += 0.05f;
                      lightSourcePosUpdate = true;
                      break;
                  }
        case '-': {
                      // move light source down //
                      light.position.y -= 0.05f;
                      lightSourcePosUpdate = true;
                      break;
                  }
    }
    glutPostRedisplay();
//.........这里部分代码省略.........
开发者ID:CompN3rd,项目名称:cg2,代码行数:101,代码来源:Ex10.cpp

示例6: unproject

static tuple unproject( CameraController &c, Imath::V2f &p )
{
    Imath::V3f near, far;
    c.unproject( p, near, far );
    return make_tuple( near, far );
}
开发者ID:mor-vfx,项目名称:cortex,代码行数:6,代码来源:CameraControllerBinding.cpp

示例7: _prof

void ModelViewer::Update( float deltaT )
{
	ScopedTimer _prof(L"Update State");

	if (GameInput::IsFirstPressed(GameInput::kLShoulder))
		DebugZoom.Decrement();
	else if (GameInput::IsFirstPressed(GameInput::kRShoulder))
		DebugZoom.Increment();

	m_pCameraController->Update(deltaT);
	m_ViewProjMatrix = m_Camera.GetViewProjMatrix();

	float costheta = cosf(m_SunOrientation);
	float sintheta = sinf(m_SunOrientation);
	float cosphi = cosf(m_SunInclination * 3.14159f * 0.5f);
	float sinphi = sinf(m_SunInclination * 3.14159f * 0.5f);
	m_SunDirection = Normalize(Vector3( costheta * cosphi, sinphi, sintheta * cosphi ));

	// We use viewport offsets to jitter our color samples from frame to frame (with TAA.)
	// D3D has a design quirk with fractional offsets such that the implicit scissor
	// region of a viewport is floor(TopLeftXY) and floor(TopLeftXY + WidthHeight), so
	// having a negative fractional top left, e.g. (-0.25, -0.25) would also shift the
	// BottomRight corner up by a whole integer.  One solution is to pad your viewport
	// dimensions with an extra pixel.  My solution is to only use positive fractional offsets,
	// but that means that the average sample position is +0.5, which I use when I disable
	// temporal AA.
	if (TemporalAA::Enable)
	{
		uint64_t FrameIndex = Graphics::GetFrameCount();
#if 1
		// 2x super sampling with no feedback
		float SampleOffsets[2][2] =
		{
			{ 0.25f, 0.25f },
			{ 0.75f, 0.75f },
		};
		const float* Offset = SampleOffsets[FrameIndex & 1];
#else
		// 4x super sampling via controlled feedback
		float SampleOffsets[4][2] =
		{
			{ 0.125f, 0.625f },
			{ 0.375f, 0.125f },
			{ 0.875f, 0.375f },
			{ 0.625f, 0.875f }
		};
		const float* Offset = SampleOffsets[FrameIndex & 3];
#endif
		m_MainViewport.TopLeftX = Offset[0];
		m_MainViewport.TopLeftY = Offset[1];
	}
	else
	{
		m_MainViewport.TopLeftX = 0.5f;
		m_MainViewport.TopLeftY = 0.5f;
	}

	m_MainViewport.Width = (float)g_SceneColorBuffer.GetWidth();
	m_MainViewport.Height = (float)g_SceneColorBuffer.GetHeight();
	m_MainViewport.MinDepth = 0.0f;
	m_MainViewport.MaxDepth = 1.0f;

	m_MainScissor.left = 0;
	m_MainScissor.top = 0;
	m_MainScissor.right = (LONG)g_SceneColorBuffer.GetWidth();
	m_MainScissor.bottom = (LONG)g_SceneColorBuffer.GetHeight();
}
开发者ID:Cynica1,项目名称:DirectX-Graphics-Samples,代码行数:67,代码来源:ModelViewer.cpp

示例8: keyboardEvent

void keyboardEvent(unsigned char key, int x, int y) {
	switch (key) {
		case 'x':
		case 27 : {
				  exit(0);
				  break;
			  }
		case 'w': {
				  // move forward //
				  camera.move(CameraController::MOVE_FORWARD);
				  break;
			  }
		case 's': {
				  // move backward //
				  camera.move(CameraController::MOVE_BACKWARD);
				  break;
			  }
		case 'a': {
				  // move left //
				  camera.move(CameraController::MOVE_LEFT);
				  break;
			  }
		case 'd': {
				  // move right //
				  camera.move(CameraController::MOVE_RIGHT);
				  break;
			  }
		case 'z': {
				  camera.setOpeningAngle(camera.getOpeningAngle() + 0.1f);
				  break;
			  }
		case 'h': {
				  camera.setOpeningAngle(std::min(std::max(camera.getOpeningAngle() - 0.1f, 1.0f), 180.0f));
				  break;
			  }
		case 'r': {
				  camera.setNear(std::min(camera.getNear() + 0.1f, camera.getFar() - 0.01f));
				  break;
			  }
		case 'f': {
				  camera.setNear(std::max(camera.getNear() - 0.1f, 0.1f));
				  break;
			  }
		case 't': {
				  camera.setFar(camera.getFar() + 0.1f);
				  break;
			  }
		case 'g': {
				  camera.setFar(std::max(camera.getFar() - 0.1f, camera.getNear() + 0.01f));
				  break;
			  }
		case 'm': {
				  materialIndex++;
				  if (materialIndex >= materialCount) materialIndex = 0;
				  break;
			  }
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9': {
				  int lightIdx;
				  std::stringstream keyStr;
				  keyStr << key;
				  keyStr >> lightIdx;
				  if (lightIdx == 0) lightIdx = 10;
				  if (lightIdx > 0) toggleLightSource(lightIdx - 1);
				  break;
			  }
	}
	glutPostRedisplay();
}
开发者ID:Aegyr,项目名称:cg2,代码行数:77,代码来源:Ex07.cpp

示例9: Cull

void Scene::Cull (const CameraController& cam)
{
	Cull(cam.GetPosition(), cam.GetRotation(), cam.GetRange(), cam.GetActiveCamera());
}
开发者ID:saggita,项目名称:r5ge,代码行数:4,代码来源:Scene.cpp

示例10: keyboardEvent

void keyboardEvent(unsigned char key, int x, int y) {
  switch (key) {
    case 'x':
    case 27 : {
      exit(0);
      break;
    }
    case 'w': {
      // move forward //
      camera.move(CameraController::MOVE_FORWARD);
      break;
    }
    case 's': {
      // move backward //
      camera.move(CameraController::MOVE_BACKWARD);
      break;
    }
    case 'a': {
      // move left //
      camera.move(CameraController::MOVE_LEFT);
      break;
    }
    case 'd': {
      // move right //
      camera.move(CameraController::MOVE_RIGHT);
      break;
    }
    case 'z': {
      camera.setOpeningAngle(camera.getOpeningAngle() + 0.1f);
      break;
    }
    case 'h': {
      camera.setOpeningAngle(std::min(std::max(camera.getOpeningAngle() - 0.1f, 1.0f), 180.0f));
      break;
    }
    case 'r': {
      camera.setNear(std::min(camera.getNear() + 0.1f, camera.getFar() - 0.01f));
      break;
    }
    case 'f': {
      camera.setNear(std::max(camera.getNear() - 0.1f, 0.1f));
      break;
    }
    case 't': {
      camera.setFar(camera.getFar() + 0.1f);
      break;
    }
    case 'g': {
      camera.setFar(std::max(camera.getFar() - 0.1f, camera.getNear() + 0.01f));
      break;
    }
    case 'm': {
      materialIndex++;
      if (materialIndex >= materialCount) materialIndex = 0;
      break;
    }
    case 'l': {
      lightIndex++;
      if (lightIndex >= lightCount) lightIndex = 0;
      break;
    }
  }
  glutPostRedisplay();
}
开发者ID:blinrybot,项目名称:cg2,代码行数:64,代码来源:Ex05.cpp

示例11: updateGL

void updateGL() {
    //Done TODO: also clear the stencil buffer before rendering again //
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    // set viewport dimensions //
    glViewport(0, 0, windowWidth, windowHeight);

    // get projection mat from camera controller //
    glm_ProjectionMatrix.top() = camera.getProjectionMat();
    // upload projection matrix //
    glUniformMatrix4fv(uniformLocations["projection"], 1, false, glm::value_ptr(glm_ProjectionMatrix.top()));

    // init scene graph by cloning the top entry, which can now be manipulated //
    // get modelview mat from camera controller //
    glm_ModelViewMatrix.top() = camera.getModelViewMat();

    // #INFO# render scene //
    renderScene();

    // #INFO# render shadow volume //
    renderShadow();

    // swap renderbuffers for smooth rendering //
    glutSwapBuffers();
}
开发者ID:CompN3rd,项目名称:cg2,代码行数:25,代码来源:Ex10.cpp

示例12: initScene

void initScene() {
    camera.setFar(1000.0f);

    // load scene.obj from disk and create renderable MeshObj //
    objLoader.loadObjFile("../meshes/testbox.obj", "sceneObject");

    // init materials //
    Material mat;
    mat.ambient_color = glm::vec3(1.0, 1.0, 1.0);
    mat.diffuse_color = glm::vec3(0.8, 1.0, 0.5);
    mat.specular_color = glm::vec3(1.0, 1.0, 1.0);
    mat.specular_shininess = 5.0;
    materials.push_back(mat);

    // save material count for later and select first material //
    materialCount = materials.size();
    materialIndex = 0;

    // init light //
    light.ambient_color = glm::vec3(0.05, 0.05, 0.05);
    light.diffuse_color = glm::vec3(1.0, 1.0, 1.0);
    light.specular_color = glm::vec3(1.0, 1.0, 1.0);
    light.position = initialLightPos;
}
开发者ID:CompN3rd,项目名称:cg2,代码行数:24,代码来源:Ex10.cpp

示例13: mouseMoveEvent

void mouseMoveEvent(int x, int y) {
    camera.updateMousePos(x, y);
    glutPostRedisplay();
}
开发者ID:CompN3rd,项目名称:cg2,代码行数:4,代码来源:Ex10.cpp


注:本文中的CameraController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。