Example #1
0
void RenderCallback()
{
    // Clear buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	ProcessCameraKeys();
	SetupCamera();

    if (gScene && !bPause)
	{
		GetPhysicsResults();
        ProcessInputs();
		StartPhysics();
	}

    // Display scene
 	RenderActors(bShadows);

	if (bForceMode)
		DrawForce(gSelectedActor, gForceVec, NxVec3(1,1,0));
	else
		DrawForce(gSelectedActor, gForceVec, NxVec3(0,1,1));
	gForceVec = NxVec3(0,0,0);

	// Render HUD
	hud.Render();

    glFlush();
    glutSwapBuffers();
}
/**-----------------------------------------------------------------------------
 * 애니메이션 설정
 *------------------------------------------------------------------------------
 */
VOID Animate()
{
	D3DXMatrixIdentity( &g_matAni );

	SetupLights();
	ProcessInputs();

	LogFPS();
}
Example #3
0
File: game.c Project: jc429/276game
void UpdateVersus(){
	if(!pause){	
		UpdateStage(stage);
		if((f2.state!=DEAD)&&(f1.state!=DEAD)){
			if(f1.state!=HIT&&f1.state!=DEAD)
				UpdateFrame(&f1);
			if(f2.state!=HIT&&f2.state!=DEAD)
				UpdateFrame(&f2);
			UpdateInputs(&f1,p1input);
			UpdateInputs(&f2,p2input);
			ProcessInputs(&f1);
			ProcessInputs(&f2);
			FighterThink(&f2);
			FighterThink(&f1);
			FighterUpdate(&f1);
			FighterUpdate(&f2);
			
		}
		if(nexttimer>0){
			if(f2.state==DEAD && f1.state==DEAD)
				DrawSprite(drawvic,screen,0,0,0);
			else if(f2.state==DEAD)
				DrawSprite(p1vic,screen,0,0,0);
			else
				DrawSprite(p2vic,screen,0,0,0);
			nexttimer--;
		}if(nexttimer==0){
			nexttimer--;
			if(stage==ST_PLATFORM)
				stage = ST_FIELD;
			else
				stage = ST_PLATFORM;
			ClearFighter(&f1);
			ClearFighter(&f2);
			InitVersus();
		}
		
	}
	else
		DrawPause(pausescr);
}
/**-----------------------------------------------------------------------------
 * 애니메이션 설정
 *------------------------------------------------------------------------------
 */
VOID Animate()
{
    /// 0 ~ 2PI 까지(0~360도) 값을 변화시킴 Fixed Point기법 사용
    DWORD d = GetTickCount() % ( (int)((D3DX_PI*2) * 1000) );
    /// Y축 회전행렬
//	D3DXMatrixRotationY( &g_matAni, d / 1000.0f );
    D3DXMatrixIdentity( &g_matAni );

    LogFPS();

    SetupLights();
    ProcessInputs();
}
Example #5
0
void RenderCallback()
{
	// Clear buffers
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	ProcessCameraKeys();
	SetupCamera();

	UpdateEmitterPosition();

	if (gScene && !bPause)
	{
		GetPhysicsResults();
		ProcessInputs();
		StartPhysics();
	}

	// Display scene
	RenderActors(bShadows);

	RenderFluid();

	if (bForceMode)
		DrawForce(gSelectedActor, gForceVec, NxVec3(1,1,0));
	else
		DrawForce(gSelectedActor, gForceVec, NxVec3(0,1,1));
	gForceVec = NxVec3(0,0,0);

	if (bEmitterWireframe)
	{
		NxMat34 fluidEmitterMat = fluidEmitter->getGlobalPose();
		NxVec3 fluidEmitterPos, fluidEmitterDir;
		fluidEmitterPos = fluidEmitterMat.t;
		fluidEmitterMat.M.getColumn(2,fluidEmitterDir);

		DrawArrow(fluidEmitterPos, fluidEmitterPos + fluidEmitterDir, NxVec3(0,0,1)); 
		DrawEllipse(20, fluidEmitter->getGlobalPose(), NxVec3(0.5,0,0.5), fluidEmitter->getDimensionX(), fluidEmitter->getDimensionY());
	}

	if (!bPause)
	{
		if (gDeltaTime < 10)  gTotalTime += gDeltaTime;
	}

	// Render HUD
	hud.Render();

	glFlush();
	glutSwapBuffers();
}
Example #6
0
bool ServerManager::Tick( )
{
	bool ret;

	ret = Select( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,Select Faild",0,0);
	}

	ret = ProcessExceptions( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessExceptions Faild",0,0);
	}

	ret = ProcessInputs( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessInputs Faild",0,0);
	}

	ret = ProcessOutputs( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessOutputs Faild",0,0);
	}

	ret = ProcessCommands( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessCommands Faild",0,0);
	}

	ret = ProcessCacheCommands( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,ProcessCacheCommands Faild",0,0);
	}

	ret = HeartBeat( );
	if(!ret)
	{
		g_pLog->log_debug("%u,%u,HeartBeat Faild",0,0);
	}

	//ret = SendQueuePlayerToWorld( );
	
	return true;
}
/**-----------------------------------------------------------------------------
 * 애니메이션 설정
 *------------------------------------------------------------------------------
 */
VOID Animate()
{
	D3DXMatrixIdentity( &g_matAni );

	SetupLights();
	ProcessInputs();

	D3DXMATRIXA16	m;
	D3DXMATRIXA16	*pView;
	pView = g_pCamera->GetViewMatrix();	// 카메라 클래스로부터 행렬정보를 얻는다.
	m = *pView * g_matProj;				// World좌표를 얻기위해서 View * Proj행렬을 계산한다.
	if ( !g_bLockFrustum )
	{
		g_pFrustum->Make( &m );	// View*Proj행렬로 Frustum을 만든다.
	}
	ProcessFrustumCull();		// Frustum정보를 기반으로, 보여질 삼각형의 인덱스를 만든다.

	LogFPS();
}
Example #8
0
void RenderCallback()
{
    // Clear buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    ProcessCameraKeys();
	SetupCamera();

    if (gScene && !bPause)
	{
		GetPhysicsResults();
        ProcessInputs();
		StartPhysics();
	}

    // Display scene
 	RenderActors(bShadows);

	// Display kernel Info
	if (gForceField)
	{
		if (gForceField->getForceFieldKernel() == gCustomKernel)
		{
			hud.SetDisplayString(2, "Using CustomKernel", 0.14f, 0.92f);
		}
		else if (gForceField->getForceFieldKernel() == gLinearKernel)
		{
			hud.SetDisplayString(2, "Using LinearKernel", 0.14f, 0.92f);
		}
	}
	
	// Render the HUD
	hud.Render();

    glFlush();
    glutSwapBuffers();
}
void RenderCallback()
{
    if (gScene && !bPause)
	{
		StartPhysics();	
		GetPhysicsResults();
	}

    // Clear buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	ProcessInputs();
	ProcessCameraKeys();
	SetupCamera();

 	RenderActors(bShadows);

    // Render all the cloths in the scene
	for (MyCloth **cloth = gCloths.begin(); cloth != gCloths.end(); cloth++)
	{
		glColor4f(1.0f, 0.0f, 0.0f,1.0f);
		(*cloth)->draw(bShadows);
	}

	if (bForceMode)
		DrawForce(gSelectedActor, gForceVec, NxVec3(1,1,0));
	else
		DrawForce(gSelectedActor, gForceVec, NxVec3(0,1,1));
	gForceVec = NxVec3(0,0,0);

	// Render HUD
	hud.Render();

    glFlush();
    glutSwapBuffers();
}
Example #10
0
int
main()
{
    SetupOpenGL();

    std::unique_ptr<btBroadphaseInterface> broadphase { new btDbvtBroadphase };
    std::unique_ptr<btDefaultCollisionConfiguration> collisionConfiguration {
        new btDefaultCollisionConfiguration
    };
    std::unique_ptr<btCollisionDispatcher> dispatcher { new btCollisionDispatcher {
        collisionConfiguration.get()
    } };
    std::unique_ptr<btSequentialImpulseConstraintSolver> solver {
        new btSequentialImpulseConstraintSolver
    };
    std::unique_ptr<btDiscreteDynamicsWorld> dynamicsWorld { new btDiscreteDynamicsWorld {
        dispatcher.get(), broadphase.get(), solver.get(), collisionConfiguration.get()
    } };
    dynamicsWorld->setGravity(btVector3 { 0, -10, 0 });
    std::unique_ptr<btCollisionShape> groundShape {
        new btStaticPlaneShape { btVector3 { 0, 1, 0 }, 1 }
    };
    std::unique_ptr<btSphereShape> fallShape { new btSphereShape { 1 } };
    std::unique_ptr<btDefaultMotionState> groundMotionState { new btDefaultMotionState {
        btTransform { btQuaternion { 0, 0, 0, 1 }, btVector3 { 0, -1, 0 } }
    } };
    btRigidBody::btRigidBodyConstructionInfo groundRigidBodyConstructionInfo {
        0, groundMotionState.get(), groundShape.get(), btVector3 { 0, 0, 0 }
    };
    std::unique_ptr<btRigidBody> groundRigidBody { new btRigidBody {
        groundRigidBodyConstructionInfo
    } };

    dynamicsWorld->addRigidBody(groundRigidBody.get());

    std::unique_ptr<btDefaultMotionState> fallMotionState { new btDefaultMotionState {
        btTransform { btQuaternion { 0, 0, 0, 1 }, btVector3 { 0, 50, 0 } }
    } };
    btScalar mass { 1 };
    btVector3 fallInertia { 0, 0, 0 };

    fallShape->calculateLocalInertia(mass, fallInertia);

    btRigidBody::btRigidBodyConstructionInfo fallRigidBodyConstructionInfo {
        mass, fallMotionState.get(), fallShape.get(), fallInertia
    };
    std::unique_ptr<btRigidBody> fallRigidBody { new btRigidBody {
        fallRigidBodyConstructionInfo
    } };

    dynamicsWorld->addRigidBody(fallRigidBody.get());

    glm::mat4 projectionMatrix = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.0f);
    glm::mat4 viewMatrix;
    glm::mat4 modelMatrix;
    glm::mat4 mvp;
    glm::vec3 lightPosition { 3, 3, 3 };
    glm::vec3 lightColor { 1, 1, 1 };
    float lightPower { 50.0f };

    btTransform transformation;

    double currentTime, lastTime = glfwGetTime();
    double fps { 0.0 };
    size_t nFrames { 0l };

    do {
        dynamicsWorld->stepSimulation(1 / 60.0f, 10);
        fallRigidBody->getMotionState()->getWorldTransform(transformation);

        ProcessInputs();
        modelMatrix = glm::translate(glm::mat4 { 1.0f }, glm::vec3 {
            transformation.getOrigin().getX(),
            transformation.getOrigin().getY(),
            transformation.getOrigin().getZ()
        });
        viewMatrix = glm::lookAt(
            s_position,
            s_position + s_direction,
            s_up
        );
        mvp = projectionMatrix * viewMatrix * modelMatrix;

        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glUseProgram(s_programId);
        glUniformMatrix4fv(s_mvpMatrixId, 1, GL_FALSE, &mvp[0][0]);
        glUniformMatrix4fv(s_modelMatrixId, 1, GL_FALSE, &modelMatrix[0][0]);
        glUniformMatrix4fv(s_viewMatrixId, 1, GL_FALSE, &viewMatrix[0][0]);
        glUniform3f(s_lightPositionId, lightPosition.x, lightPosition.y, lightPosition.z);
        glUniform3f(s_lightColorId, lightColor.x, lightColor.y, lightColor.z);
        glUniform1f(s_lightPowerId, lightPower);

        glActiveTexture(GL_TEXTURE0);
        glBindTexture(GL_TEXTURE_2D, s_textureId);
        glUniform1i(s_uniformTextureId, 0);

        glEnableVertexAttribArray(0);
        glBindBuffer(GL_ARRAY_BUFFER, s_vertexBufferId);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, nullptr);

        glEnableVertexAttribArray(1);
        glBindBuffer(GL_ARRAY_BUFFER, s_uvCoordBufferId);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, nullptr);

        glEnableVertexAttribArray(2);
        glBindBuffer(GL_ARRAY_BUFFER, s_normalBufferId);
        glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, 0, nullptr);

        glDrawArrays(GL_TRIANGLES, 0, s_model.vertices().size());

        glDisableVertexAttribArray(0);
        glDisableVertexAttribArray(1);
        glDisableVertexAttribArray(2);

        currentTime = glfwGetTime();
        ++nFrames;
        if (currentTime - lastTime > 1.0) {
            fps = 1000.0/nFrames;
            nFrames = 0;
            lastTime += 1.0;
        }
        ShowStatus(transformation.getOrigin().getY(), fps);

        glfwSwapBuffers(s_window);
        glfwPollEvents();
    } while (glfwGetKey(s_window, GLFW_KEY_ESCAPE) != GLFW_PRESS
             && glfwGetKey(s_window, GLFW_KEY_Q) != GLFW_PRESS
             && glfwWindowShouldClose(s_window) == 0);
    dynamicsWorld->removeRigidBody(fallRigidBody.get());
    dynamicsWorld->removeRigidBody(groundRigidBody.get());
    CleanupOpenGL();

    return 0;
}