本文整理汇总了C++中Obstacle::setFriction方法的典型用法代码示例。如果您正苦于以下问题:C++ Obstacle::setFriction方法的具体用法?C++ Obstacle::setFriction怎么用?C++ Obstacle::setFriction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Obstacle
的用法示例。
在下文中一共展示了Obstacle::setFriction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
// Main function
int main(int argc, char *argv[])
{
// random seed
randomSeed = static_cast<unsigned int>(time(NULL));
// Sets the update step
System::setClampStep(true,0.01f); // clamp the step to 10 ms
System::useRealStep();
SDL_Event event;
// inits SDL
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("SPARK Flakes Demo",NULL);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
// vsync
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL,0);
SDL_SetVideoMode(0,0,32,SDL_OPENGL | SDL_FULLSCREEN);
SDL_ShowCursor(0);
SDL_Surface screen = *SDL_GetVideoSurface();
renderFirstFrame();
// inits openGL
screenWidth = screen.w;
screenHeight = screen.h;
screenRatio = (float)screen.w / (float)screen.h;
glClearColor(0.0f,0.0f,0.0f,1.0f);
glViewport(0,0,screen.w,screen.h);
// Loads texture font
FTGLTextureFont font = FTGLTextureFont("res/font.ttf");
if(font.Error())
return 1;
font.FaceSize(24);
fontPtr = &font;
// Inits Particle Engine
// Renderers
GLPointRenderer* basicRenderer = GLPointRenderer::create();
GLPointRenderer* particleRenderer = GLPointRenderer::create(1.0f);
particleRenderer->setBlending(BLENDING_ADD);
particleRenderer->enableRenderingHint(DEPTH_TEST,false);
// Model
Model* particleModel = Model::create(FLAG_RED | FLAG_GREEN | FLAG_BLUE | FLAG_ALPHA);
particleModel->setParam(PARAM_RED,1.0f);
particleModel->setParam(PARAM_GREEN,0.8f);
particleModel->setParam(PARAM_BLUE,0.3f);
particleModel->setParam(PARAM_ALPHA,0.4f);
particleModel->setImmortal(true);
// Zone
Sphere* sphere = Sphere::create(Vector3D(),1.0f);
// Obstacle
Obstacle* obstacle = Obstacle::create(sphere);
obstacle->setFriction(0.9f);
obstacle->setBouncingRatio(0.9f);
// Group
Vector3D gravity(0.0f,-0.5f,0.0f);
particleGroup = Group::create(particleModel,NB_PARTICLES[NB_PARTICLES_SIZE - 1]);
particleGroup->setRenderer(particleRenderer);
particleGroup->setGravity(gravity);
particleGroup->addModifier(obstacle);
particleGroup->setFriction(0.2f);
particleSystem = System::create();
particleSystem->addGroup(particleGroup);
// Particles are added to the group
particleGroup->addParticles(NB_PARTICLES[nbParticlesIndex],sphere,Vector3D());
particleGroup->flushAddedParticles();
bool exit = false;
bool paused = false;
// renderValue :
// 0 : normal
// 1 : basic render
// 2 : no render
unsigned int renderValue = 0;
cout << "\nSPARK FACTORY AFTER INIT :" << endl;
SPKFactory::getInstance().traceAll();
SDL_Delay(3000);
while (SDL_PollEvent(&event)){}
std::deque<unsigned int> frameFPS;
frameFPS.push_back(SDL_GetTicks());
while(!exit)
{
//.........这里部分代码省略.........