本文整理汇总了C++中CrtRender::SetNextCamera方法的典型用法代码示例。如果您正苦于以下问题:C++ CrtRender::SetNextCamera方法的具体用法?C++ CrtRender::SetNextCamera怎么用?C++ CrtRender::SetNextCamera使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CrtRender
的用法示例。
在下文中一共展示了CrtRender::SetNextCamera方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MouseCallback
void MouseCallback(int button, int state, int x, int y)
{
switch (button)
{
case GLUT_MIDDLE_BUTTON:
if (state == GLUT_UP) {
sLeftBtnDown = false;
}
else if (state == GLUT_DOWN) {
sLeftBtnDown = true;
_CrtRender.SetNextCamera();
}
break;
case GLUT_LEFT_BUTTON:
if (state == GLUT_UP)
sLeftBtnDown = false;
else if (state == GLUT_DOWN)
sLeftBtnDown = true;
break;
case GLUT_RIGHT_BUTTON:
if (state == GLUT_UP)
sRightBtnDown = false;
else if (state == GLUT_DOWN)
sRightBtnDown = true;
break;
default:
break;
}
}
示例2: onUpdate
bool COLLADA_Viewer::onUpdate()
{
float tolerrance = 0.15;
static float buttonTime = 0;
static float cameraTime = 0;
bool result = FWGLApplication::onUpdate();
if (mRunning==false)
return result;
FWTimeVal curTime = FWTime::getCurrentTime();
if ((float)curTime - buttonTime > 0.15) // execute these control base on time elapse, not frame rate
{
buttonTime = curTime;
if(mpPad->getRawBool(FWInput::Channel_Button_Select))
{
_CrtRender.SetNextCamera();
return result;
} else if(mpPad->getRawBool(FWInput::Channel_Button_L3))
{
if (Browser.IsVisible())
Browser.SetVisible(false);
else
Browser.SetVisible(true);
} else if(mpPad->getRawBool(FWInput::Channel_Button_R3))
{
if (togglewireframe) {
togglewireframe = false;
} else {
togglewireframe = true;
}
} else if(mpPad->getRawBool(FWInput::Channel_Button_Square))
{
if (togglelighting) {
togglelighting = false;
} else {
togglelighting = true;
}
} else if(mpPad->getRawBool(FWInput::Channel_Button_Cross))
{
mCurrentFile = Browser.GetThumbnail(Browser.GetSelection())->GetDocument();
load_ok = _CrtRender.Load(mCurrentFile, NULL);
return result;
} else if(mpPad->getRawBool(FWInput::Channel_Button_Up))
{
Browser.SelectPrev();
} else if(mpPad->getRawBool(FWInput::Channel_Button_Down))
{
Browser.SelectNext();
}
}
if ((float)curTime - cameraTime > 0.05) // execute these control base on time elapse, not frame rate
{
cameraTime = curTime;
// Get the values from the analog sticks
float conditioned_X_0 = mpPad->getRawFloat(FWInput::Channel_XAxis_0);
float conditioned_Y_0 = mpPad->getRawFloat(FWInput::Channel_YAxis_0);
float conditioned_X_1 = mpPad->getRawFloat(FWInput::Channel_XAxis_1);
float conditioned_Y_1 = mpPad->getRawFloat(FWInput::Channel_YAxis_1);
if (-tolerrance < conditioned_X_0 && conditioned_X_0 < tolerrance) conditioned_X_0 = 0.0f;
if (-tolerrance < conditioned_Y_0 && conditioned_Y_0 < tolerrance) conditioned_Y_0 = 0.0f;
if (-tolerrance < conditioned_X_1 && conditioned_X_1 < tolerrance) conditioned_X_1 = 0.0f;
if (-tolerrance < conditioned_Y_1 && conditioned_Y_1 < tolerrance) conditioned_Y_1 = 0.0f;
conditioned_X_0 = mpInputX0 ? -mpInputX0->getFloatValue() : 0.f;
conditioned_Y_0 = mpInputY0 ? -mpInputY0->getFloatValue() : 0.f;
conditioned_X_1 = mpInputX1 ? -mpInputX1->getFloatValue() : 0.f;
conditioned_Y_1 = mpInputY1 ? -mpInputY1->getFloatValue() : 0.f;
float multiplier = 10.0f;
if (conditioned_X_0 != 0.0f || conditioned_Y_0 != 0.0f)
{
_CrtRender.ActiveInstanceCamera->MoveOrbit(conditioned_X_0 * multiplier, conditioned_Y_0 * multiplier);
}
if (conditioned_X_1 != 0.0f || conditioned_Y_1 != 0.0f)
{
_CrtRender.ActiveInstanceCamera->SetPanAndTilt(conditioned_X_1 * multiplier, conditioned_Y_1 * multiplier);
}
}
if(mpPad->getRawBool(FWInput::Channel_Button_L2))
{ // zoom in
_CrtRender.ZoomIn(-0.005f);
} else if(mpPad->getRawBool(FWInput::Channel_Button_L1))
{ // zoom out
_CrtRender.ZoomIn(0.005f);
}
if (togglewireframe) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
} else {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
if (togglelighting) {
glEnable(GL_LIGHTING);
} else {
//.........这里部分代码省略.........
示例3: WndProc
LRESULT CALLBACK WndProc( HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_ACTIVATE:
{
if (!HIWORD(wParam))
{
active=TRUE;
}
else
{
active=FALSE;
}
return 0;
}
case WM_SYSCOMMAND:
{
switch (wParam)
{
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return 0;
}
break;
}
case WM_CLOSE:
{
PostQuitMessage(0);
return 0;
}
case WM_KEYDOWN:
{
// We only want to know which keys are down, so if this was an auto-repeat, ignore it
if(!(HIWORD(lParam) & KF_REPEAT))
{
// Remember which keys are being held down
keys[wParam] = TRUE;
}
return 0;
}
case WM_KEYUP:
{
keys[wParam] = FALSE;
return 0;
}
case WM_SIZE:
{
ResizeGLScreen(LOWORD(lParam),HIWORD(lParam));
return 0;
}
case WM_MOUSEWHEEL:
{
if (_CrtRender.ActiveInstanceCamera)
{
float gcWheelDelta = (short) HIWORD(wParam);
_CrtRender.ZoomIn((CrtFloat) (-gcWheelDelta * MouseWheelSpeed));
return 0;
}
}
case WM_MBUTTONDOWN:
{
// Change camera
_CrtRender.SetNextCamera();
return 0;
}
case WM_MOUSEMOVE:
{
// UI code to move camera in response to mouse movement.
static float lastx = 0, lasty = 0;
static int lastLeft = 0, lastRight = 0, lastMiddle = 0;
// Retrieve mouse screen position and button state
float x=(float) (short)LOWORD(lParam);
float y=(float) (short)HIWORD(lParam);
// bool controlButtonDown=((wParam & MK_CONTROL) !=0);
bool leftButtonDown=((wParam & MK_LBUTTON) !=0);
bool middleButtonDown=((wParam & MK_MBUTTON) !=0);
bool rightButtonDown=((wParam & MK_RBUTTON) !=0);
// Handle rotations if left button was pressed
if(leftButtonDown)
{
if(lastLeft && _CrtRender.ActiveInstanceCamera)
{
_CrtRender.ActiveInstanceCamera->SetPanAndTilt((lastx - x) * MouseRotateSpeed, (lasty - y) * MouseRotateSpeed);
lastx = x;
lasty = y;
}
else
{
//.........这里部分代码省略.........
示例4: ProcessInput
// Call ProcessInput once per frame to process input keys
void ProcessInput( bool keys[] )
{
// These keys we don't want to auto-repeat, so we clear them in "keys" after handling them once
if (keys['E'] && amplitudeGlobalParameter)
{
float value;
cgGetParameterValuefc(amplitudeGlobalParameter, 1, &value);
value += 0.1f;
cgSetParameter1f(amplitudeGlobalParameter, value);
keys['E'] = false;
}
if (keys['R'] && amplitudeGlobalParameter)
{
float value;
cgGetParameterValuefc(amplitudeGlobalParameter,1, &value);
value -= 0.1f;
cgSetParameter1f(amplitudeGlobalParameter, value);
keys['R'] = false;
}
if (keys[VK_TAB] )
{
// When 'C' is pressed, change cameras
_CrtRender.SetNextCamera();
keys[VK_TAB] = false;
}
if ( keys['M'] )
{
// Speed up UI by 25%
AdjustUISpeed(1.25f);
keys['M'] = false;
}
if ( keys['N'] )
{
// Slow down UI by 25%
AdjustUISpeed(0.75f); // Go 25% slower
keys['N'] = false;
}
if (keys['Q'])
{
if (togglewireframe) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
togglewireframe = FALSE;
} else {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
togglewireframe = TRUE;
}
keys['Q'] = false;
}
if (keys['K'])
{
if (togglehiearchy) {
_CrtRender.SetShowHiearchy(CrtTrue);
togglehiearchy = FALSE;
} else {
_CrtRender.SetShowHiearchy(CrtFalse);
togglehiearchy = TRUE;
}
keys['K'] = false;
}
if (keys['L'])
{
if (togglelighting) {
glDisable(GL_LIGHTING);
togglelighting = FALSE;
} else {
glEnable(GL_LIGHTING);
togglelighting = TRUE;
}
keys['L'] = false;
}
if (keys['P'] )
{
if (sAnimationEnable) {
_CrtRender.SetAnimationPaused( CrtTrue );
sAnimationEnable = false;
}
else {
_CrtRender.SetAnimationPaused( CrtFalse );
sAnimationEnable = true;
}
keys['P'] = false;
}
if (keys[VK_F1])
{
keys[VK_F1]=FALSE;
_CrtRender.Destroy();
DestroyGLWindow();
fullscreen=!fullscreen;
// Recreate Our OpenGL Window
if (!CreateGLWindow("Collada Viewer for PC", _CrtRender.GetScreenWidth(), _CrtRender.GetScreenHeight(),32,fullscreen))
{
exit(1);
}
if ( !_CrtRender.Load( cleaned_file_name ))
{
exit(0);
//.........这里部分代码省略.........
示例5: KeyboardCallback
static void KeyboardCallback(const unsigned char key, const int x, const int y)
{
(void)x;
(void)y;
switch (key)
{
case 9 : /* TAB key */
_CrtRender.SetNextCamera();
break;
case 'k' :
case 'K' :
sHierarchy = !sHierarchy;
if (!sHierarchy) {
_CrtRender.SetShowHiearchy( CrtFalse );
}
else {
_CrtRender.SetShowHiearchy( CrtTrue );
}
break;
case 'l' :
case 'L' :
sGlLighting = !sGlLighting;
if (sGlLighting) {
glEnable(GL_LIGHTING);
} else {
glDisable(GL_LIGHTING);
}
break;
case 'm' :
case 'M' :
AdjustUISpeed(1.25f);
break;
case 'n' :
case 'N' :
AdjustUISpeed(0.75f);
break;
case 'p' :
case 'P' :
sAnimation = !sAnimation;
if (!sAnimation) {
_CrtRender.SetAnimationPaused( CrtTrue );
}
else {
_CrtRender.SetAnimationPaused( CrtFalse );
}
break;
case 'q' :
case 'Q' :
sWireframe = !sWireframe;
if (sWireframe) {
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
} else {
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
break;
case 's' : //zoom in
case 'S' :
_CrtRender.ActiveInstanceCamera->MoveTransform(_CrtRender.GetAnimDelta() * KeyboardTranslateSpeed *0.5f, 0.0f, 0.0f);
break;
case 'w' : // zoom out
case 'W' :
_CrtRender.ActiveInstanceCamera->MoveTransform(- _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed * 0.5f, 0.0f, 0.0f);
break;
case 32 : // space key, UP
// UI code to move the camera farther up
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, 0.0f, _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed);
break;
case 'x' : // down
case 'X' :
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, 0.0f, - _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed);
break;
case 'd' : // right
case 'D' :
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, - _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed, 0.0f);
break;
case 'a' : // left
case 'A' :
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed, 0.0f);
break;
case 'f' :
case 'F' :
if(sCulling == 0)
{ // turn it front
glEnable( GL_CULL_FACE );
glCullFace(GL_FRONT);
sCulling = 1;
} else if(sCulling == 1)
{ // turn it both
glDisable( GL_CULL_FACE );
sCulling = 2;
} else
{ // turn it back
glEnable( GL_CULL_FACE );
glCullFace(GL_BACK);
sCulling = 0;
}
break;
default:
printf("unused key : %i\n", key );
//.........这里部分代码省略.........