本文整理汇总了C++中CrtRender类的典型用法代码示例。如果您正苦于以下问题:C++ CrtRender类的具体用法?C++ CrtRender怎么用?C++ CrtRender使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CrtRender类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xAxis
void COLLADA_Viewer::SixAxis(float flX, float flY, float flZ, float flG)
{
(void) flG;
if (_CrtRender.UsingPhysics())
{
static float dampedX = 0.0f;
static float dampedY = 0.0f;
static float dampedZ = 0.0f;
dampedX=(flX + 10.f*dampedX)/11.f;
dampedY=(flY + 10.f*dampedY)/11.f;
dampedZ=(flZ + 10.f*dampedZ)/11.f;
btTransform floorTrans;
floorTrans.setIdentity();
btVector3 xAxis(1,0,0);
btVector3 zAxis(0,0,1);
btQuaternion rotX(zAxis,dampedX*10.f);
btQuaternion rotZ(xAxis,-dampedZ*10.f);
btQuaternion combinedRot = rotZ*rotX;
btMatrix3x3 orn;
orn.setRotation(combinedRot);
btVector3 up = orn.getColumn(1);
CrtVec3f newG = CrtVec3f(up.getX(),up.getY(),up.getZ());
_CrtRender.SetGravity(newG);
// printf("new gravity (%f, %f, %f)\n", newG.getX(), newG.getY(), newG.getZ());
}
}
示例2: DestroyCrt
static void DestroyCrt(void)
{
_CrtRender.Destroy();
DestroyGLWindow();
}
示例3: 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;
}
}
示例4: onShutdown
void COLLADA_Viewer::onShutdown()
{
FWGLApplication::onShutdown();
_CrtRender.Destroy();
cellDbgFontConsoleClose(mDbgFontID);
cellDbgFontExit();
}
示例5: specialKeyboardCallback
static void specialKeyboardCallback(int key, int x, int y)
{
(void)x;
(void)y;
switch (key)
{
case GLUT_KEY_F1:
fullscreen = !fullscreen;
if (fullscreen) {
Xpos = glutGet((GLenum)GLUT_WINDOW_X); /* Save parameters */
Ypos = glutGet((GLenum)GLUT_WINDOW_Y);
Xsize = glutGet((GLenum)GLUT_WINDOW_WIDTH);
Ysize = glutGet((GLenum)GLUT_WINDOW_HEIGHT);
glutFullScreen(); /* Go to full screen */
} else {
glutReshapeWindow(Xsize, Ysize); /* Restore us */
glutPositionWindow(Xpos,Ypos);
glutPostRedisplay();
}
break;
case GLUT_KEY_LEFT :
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed, 0.0f);
break;
case GLUT_KEY_RIGHT :
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, - _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed, 0.0f);
break;
case GLUT_KEY_UP :
// UI code to move the camera farther up
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, 0.0f, _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed);
break;
case GLUT_KEY_DOWN :
_CrtRender.ActiveInstanceCamera->MoveTransform(0.0f, 0.0f, - _CrtRender.GetAnimDelta() * KeyboardTranslateSpeed);
break;
default:
printf("unused (special) key : %i\n", key );
break;
}
}
示例6: ResizeGLScreen
//----------------------------------------------------------------------------------------------------
// Resize And Initialize The GL Window
GLvoid ResizeGLScreen(GLsizei width, GLsizei height)
{
// Prevent A Divide By Zero By
if (height==0)
{
height=1;
}
glViewport(0,0,width,height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Reset the renderer's screen size to the new size
_CrtRender.SetScreenWidth( width);
_CrtRender.SetScreenHeight( height);
}
示例7: DrawGLScene
//----------------------------------------------------------------------------------------------------
// Render routine
//----------------------------------------------------------------------------------------------------
void DrawGLScene(void)
{
// Clear The Screen And The Depth Buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
CrtMaterial mat;
mat.Ambient = CrtColor3f( 1,1,1 );
mat.Diffuse = CrtColor3f( 1,1,1 );
glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, (GLfloat *)&mat.Diffuse );
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, (GLfloat *)&mat.Ambient );
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, (GLfloat *)&mat.Specular );
glMaterialf( GL_FRONT_AND_BACK, GL_SHININESS, (GLfloat )mat.Shininess );
if(_CrtRender.GetScene())
_CrtRender.Render();
glutSwapBuffers();
}
示例8: glPolygonMode
void COLLADA_Viewer::onRender()
{
// base implementation clears screen and sets up camera
FWGLApplication::onRender();
if (!load_ok)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
Browser.onRender();
cellDbgFontPuts(0.5f, 0.5f, 1.0f, 0xff00ffff, "Load Error!");
cellDbgFontDraw();
return;
}
if (mRunning==false)
return;
glPushMatrix();
glEnable(GL_DEPTH_TEST);
_CrtRender.Render();
glPopMatrix();
// FPS REPORTING
glDisable(GL_VSYNC_SCE);
// get current timing info
FWTimeVal timeNow = FWTime::getCurrentTime();
float fElapsedInFrame = (float)(timeNow - mLastTime);
mLastTime = timeNow;
++frames;
timeElapsed+=fElapsedInFrame;
// report fps at appropriate interval
if (timeElapsed>=timeReport)
{
//printf("FPS: %.2f\n",(frames-framesLastReport)*1.f/(float)(timeElapsed-timeLastReport));
timeReport+=REPORT_TIME;
timeLastReport=timeElapsed;
framesLastReport=frames;
}
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
Browser.onRender();
cellDbgFontDraw();
}
示例9: if
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 {
//.........这里部分代码省略.........
示例10: glClearColor
bool COLLADA_Viewer::onInit(int argc, char **ppArgv)
{
FWGLApplication::onInit(argc, ppArgv);
glClearColor(0.3f,0.3f,0.7f, 0.0f);
glClearDepthf(1.0f);
glEnable(GL_DEPTH_TEST);
FWDebugFont::setColor(1.f, 1.f, 1.f, 1.f);
InitFS();
Browser.Init();
psglLoadShaderLibrary("/app_home/shaders.bin");
// Initialize the renderer
_CrtRender.Init();
_CrtRender.SetUsingVBOs(CrtTrue);
_CrtRender.SetShowHiearchy(CrtTrue);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 1.0f, 0.5f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable( GL_CULL_FACE );
glCullFace( GL_BACK );
cgRTCgcInit();
ParseDir("/app_home/");
// Load the target file
Browser.onUpdate();
if (argc > 0)
{
char path_name[1024];
mCurrentFile = ppArgv[0];
sprintf(path_name, "%s%s", "/app_home/", ppArgv[0]);
printf(path_name);
load_ok = _CrtRender.Load(path_name, NULL);
if ( !load_ok )
return false;
}
else if (Browser.GetSize() > 0)
{
mCurrentFile = Browser.GetThumbnail(0)->GetDocument();
load_ok = _CrtRender.Load(mCurrentFile, NULL);
if ( !load_ok )
return false;
}
// Get the gamepad so we can read it later
mpPad = FWInput::getDevice(FWInput::DeviceType_Pad,0);
if(mpPad==NULL)
{
printf("Error, couldn't get a pad\n");
exit(0);
}
mpInputX0 = mpPad->bindFilter();
mpInputX0->setChannel(FWInput::Channel_XAxis_0);
mpInputX0->setGain( 1.0f );
mpInputX0->setDeadzone( 0.3f );
mpInputY0 = mpPad->bindFilter();
mpInputY0->setChannel(FWInput::Channel_YAxis_0);
mpInputY0->setGain( 1.0f );
mpInputY0->setDeadzone( 0.3f );
mpInputX1 = mpPad->bindFilter();
mpInputX1->setChannel(FWInput::Channel_XAxis_1);
mpInputX1->setGain( 1.0f );
mpInputX1->setDeadzone( 0.3f );
mpInputY1 = mpPad->bindFilter();
mpInputY1->setChannel(FWInput::Channel_YAxis_1);
mpInputY1->setGain( 1.0f );
mpInputY1->setDeadzone( 0.3f );
// initialize debug font library, then open console.
int ret;
CellDbgFontConfig cfg;
memset(&cfg, 0, sizeof(CellDbgFontConfig));
cfg.bufSize = 512;
cfg.screenWidth = mDispInfo.mWidth;
cfg.screenHeight = mDispInfo.mHeight;
ret = cellDbgFontInit(&cfg);
if (ret != CELL_OK) {
printf("cellDbgFontInit() failed %x\n", ret);
return true;
}
CellDbgFontConsoleConfig ccfg;
memset(&ccfg, 0, sizeof(CellDbgFontConsoleConfig));
ccfg.posLeft = 0.1f;
ccfg.posTop = 0.6f;
ccfg.cnsWidth = 16;
ccfg.cnsHeight = 4;
//.........这里部分代码省略.........
示例11: WinMain
//----------------------------------------------------------------------------------------------------
// Standard windows mainline, this is the program entry point
//
CrtInt32 WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
CrtInt32 nCmdShow)
{
(void)hPrevInstance; // Avoid warnings
(void)nCmdShow; // Avoid warnings
(void)hInstance; // Avoid warnings
#ifndef NO_DEVIL
ilInit();
#endif
MSG msg;
BOOL done=FALSE;
// Avoid warnings later
msg.wParam = 0;
// Turns on windows heap debugging
#if HEAP_DEBUG
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF /*| _CRTDBG_DELAY_FREE_MEM_DF*/);
#endif
// Ask The User Which Screen Mode They Prefer
// if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
{
fullscreen=FALSE;
}
// Set the default screen size
_CrtRender.SetScreenWidth( 640);
_CrtRender.SetScreenHeight( 480);
// Create an OpenGL Window
if (!CreateGLWindow("Collada Viewer for PC", _CrtRender.GetScreenWidth(), _CrtRender.GetScreenHeight(),32,fullscreen))
{
return 0;
}
// Turn data dumping (debug) off
//CrtBool dumpData = CrtFalse;
// Initialize the renderer
// !!!GAC for compatibility with the new COLLADA_FX code, Init now forces UsingCg and UsingVBOs to
// !!!GAC false. It also calls CrtInitCg, creating the CG context and calling cgGLRegisterStates.
// !!!GAC All these things are currently required for the cfx rendering path to work, changing them
// !!!GAC may cause problems. This is work in progress and will be much cleaner when the refactor is done.
_CrtRender.Init();
//_CrtRender.SetRenderDebug( CrtTrue );
// !!!GAC kept for reference, changing these may cause problems with the cfx include path
//_CrtRender.SetUsingCg( CrtFalse );
// Turn off VBOs (the GL skinning path doesn't work with VBOs yet)
_CrtRender.SetUsingVBOs( CrtTrue );
_CrtRender.SetUsingNormalMaps( CrtTrue );
//_CrtRender.SetRenderDebug( CrtTrue );
//_CrtRender.SetUsingShadowMaps(CrtTrue);
// We might get a windows-style path on the command line, this can mess up the DOM which expects
// all paths to be URI's. This block of code does some conversion to try and make the input
// compliant without breaking the ability to accept a properly formatted URI. Right now this only
// displays the first filename
char
file[512],
*in = lpCmdLine,
*out = file;
*out = NULL;
// If the first character is a ", skip it (filenames with spaces in them are quoted)
if(*in == '\"')
{
in++;
}
if(*(in+1) == ':')
{
// Second character is a :, assume we have a path with a drive letter and add a slash at the beginning
*(out++) = '/';
}
int i;
for(i =0; i<512; i++)
{
// If we hit a null or a quote, stop copying. This will get just the first filename.
if(*in == NULL || *in == '\"')
break;
// Copy while swapping backslashes for forward ones
if(*in == '\\')
{
*out = '/';
}
else
{
*out = *in;
}
in++;
out++;
}
//.........这里部分代码省略.........
示例12: 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
{
//.........这里部分代码省略.........
示例13: 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);
//.........这里部分代码省略.........
示例14: main
//----------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------
int main(int LArgC, char** LArgV)
{
atexit(DestroyCrt); // Need this, because old GLUT never returns from glutMainLoop()
// Create an OpenGL Window
if (!CreateGLWindow(LArgC, LArgV, (char*)"COLLADA_DOM Sample Viewer", _CrtRender.GetScreenWidth(), _CrtRender.GetScreenHeight()))
{
return 0;
}
// Initialize the renderer
// !!!GAC for compatibility with the new COLLADA_FX code, Init now forces UsingCg and UsingVBOs to
// !!!GAC false. It also calls CrtInitCg, creating the CG context and calling cgGLRegisterStates.
// !!!GAC All these things are currently required for the cfx rendering path to work, changing them
// !!!GAC may cause problems. This is work in progress and will be much cleaner when the refactor is done.
_CrtRender.Init();
_CrtRender.SetUsingVBOs( CrtTrue );
_CrtRender.SetUsingNormalMaps( CrtTrue );
// Load the file name provided on the command line
if(LArgC > 1 && LArgV[1])
{
printf("%s(): Loading %s...\n", __FUNCTION__, LArgV[1]);
fflush(stdout);
if ( !_CrtRender.Load( LArgV[1] ))
{
exit(0);
}
}
else
{
printf("%s(): Loading default document cage.dae... \n", __FUNCTION__);
fflush(stdout);
if ( !_CrtRender.Load( "cage.dae" ))
{
exit(0);
}
}
// This block of code shows how to enumerate all the effects, get their parameters and then
// get their UI information.
#if 1
if(_CrtRender.GetScene())
{
// Get the scene and setup to iterate over all the effects stored in the cfxLoader
CrtScene *scene = _CrtRender.GetScene();
std::map<std::string, cfxEffect*>::iterator effectIterator;
effectIterator = scene->cfxEffects.begin();
// Iterate over all the effects
while(effectIterator != scene->cfxEffects.end())
{
// This is the effect name you would use in a UI
CrtPrint("Effect name %s\n", effectIterator->first.c_str());
cfxEffect *thiscfxEffect = effectIterator->second;
CGeffect thisCGEffect = thiscfxEffect->getEffect();
CGparameter thisCGParameter = cgGetFirstEffectParameter(thisCGEffect);
while(thisCGParameter != NULL)
{
// This is the parameter name you would use in the UI
const char *parameterName = cgGetParameterName(thisCGParameter);
// This is for the example of how to tweek a parameter (doesn't work yet)
if(CrtCmp(parameterName, "Amplitude"))
{
// Capture the parameter and save it in a global, in a GUI you would
// save this handle in the widget so it would know what to tweek.
amplitudeGlobalParameter = thisCGParameter;
}
#if 0
// This is here for debugging, it iterates over all the annotations and prints them out
// so you can see what's in them. Normally this code will be turned off.
CrtPrint(" Parameter name %s\n",parameterName);
CGannotation dbgCGAnnotation = cgGetFirstParameterAnnotation(thisCGParameter);
while(dbgCGAnnotation != NULL)
{
const char *annotationName = cgGetAnnotationName(dbgCGAnnotation);
CrtPrint(" Annotation: %s",annotationName);
if(cgGetAnnotationType(dbgCGAnnotation) == CG_STRING)
{
const char *annotationString = cgGetStringAnnotationValue(dbgCGAnnotation);
CrtPrint(" value: %s\n",annotationString);
}
else if(cgGetAnnotationType(dbgCGAnnotation) == CG_FLOAT)
{
int nvalues;
const float *value = cgGetFloatAnnotationValues(dbgCGAnnotation, &nvalues);
CrtPrint(" value: %f\n",*value); // Assume there is one value
}
else
{
CrtPrint("\n");
}
dbgCGAnnotation = cgGetNextAnnotation(dbgCGAnnotation);
}
#endif
//.........这里部分代码省略.........
示例15: 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 );
//.........这里部分代码省略.........