Ejemplo n.º 1
0
//===========================================================================
void EnterMessageLoop()
{
	MSG message;
	while (GetMessage(&message,0,0,0))
	{
		TranslateMessage(&message);
		DispatchMessage(&message);
		Timer_StopTimer();
		while ((mode == MODE_RUNNING) || (mode == MODE_STEPPING))
		{
			if (PeekMessage(&message,0,0,0,PM_REMOVE))
			{
				if (message.message == WM_QUIT)
					return;
				TranslateMessage(&message);
				DispatchMessage(&message);
			}
			else if (mode == MODE_STEPPING)
				DebugContinueStepping();
			else
			{
				ContinueExecution();
				if (fullspeed)
					ContinueExecution();
			}
		}
	}
	while (PeekMessage(&message,0,0,0,PM_REMOVE));
}
Ejemplo n.º 2
0
//===========================================================================
void EnterMessageLoop(void)
{
	MSG message;

	PeekMessage(&message, NULL, 0, 0, PM_NOREMOVE);

	while (message.message!=WM_QUIT)
	{
		if (PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&message);
			DispatchMessage(&message);

			while ((g_nAppMode == MODE_RUNNING) || (g_nAppMode == MODE_STEPPING))
			{
				if (PeekMessage(&message,0,0,0,PM_REMOVE))
				{
					if (message.message == WM_QUIT)
						return;

					TranslateMessage(&message);
					DispatchMessage(&message);
				}
				else if (g_nAppMode == MODE_STEPPING)
				{
					DebugContinueStepping();
				}
				else
				{
					ContinueExecution();
					if (g_nAppMode != MODE_DEBUG)
					{
						if (g_bFullSpeed)
							ContinueExecution();
					}
				}
			}
		}
		else
		{
			if (g_nAppMode == MODE_DEBUG)
				DebuggerUpdate();
			else if ((g_nAppMode == MODE_LOGO) || (g_nAppMode == MODE_PAUSED))
				Sleep(100);		// Stop process hogging CPU
		}
	}
}
Ejemplo n.º 3
0
void CEffectsGame::Init()
{
	CGame::Init();

	// create drivable car
	car = new CCarEntity();	
	car->Move(-3,0.5f,-3);
	//AddEntity(car);
	//pCameraController = new COrbitController( pCamera, car, Vector3(+45,45,0), 5, Vector3(0,2,1) );
	

	bullets = new CSprite3D*[MAX_BULLETS];
	for (int i=0; i<MAX_BULLETS; i++) bullets[i] = NULL;
/*
	gLevelChunksMaterialID = NewtonMaterialCreateGroupID(pWorld);
	gLevelBlocksMaterialID = NewtonMaterialCreateGroupID(pWorld);
	gLevelFloorMaterialID = NewtonMaterialCreateGroupID(pWorld);

	

	NewtonMaterialSetDefaultCollidable(pWorld, gLevelChunksMaterialID, gLevelChunksMaterialID, 0);
	NewtonMaterialSetDefaultCollidable(pWorld, gLevelChunksMaterialID, gLevelBlocksMaterialID, 1);
	NewtonMaterialSetDefaultCollidable(pWorld, gLevelBlocksMaterialID, gLevelBlocksMaterialID, 0);		// blocks dont collide with each other
*/
	
	pCameraController = new CFlyController(pCamera);		// TEMP: Fly camera

	
	CreateScene();
	//CreateCar();

	//CreateBoxesScene();
	ContinueExecution();
	
	return;


	/*
	mat = new CMaterial();
	mat->pTexture = tex;
	//mat->blending = EBlending::Additive;
	mat->features = EShaderFeature::LIGHT | EShaderFeature::TEXTURE | EShaderFeature::FOG;

	CMesh *box = new CMesh( new CCubeGeometry(5, 5, 5));
	box->geometry->materials.AddToTail(mat);
	box->SetScale(-1);
	box->SetPosition(0,2.3f,0);
	for (int i=0; i<box->geometry->faces.Size(); i++)
	{
		box->geometry->faces[i].normal *= -1.0f;
		for (int j=0; j<3; j++)
		{
			box->geometry->faces[i].texcoord[j].y = 1.0f - box->geometry->faces[i].texcoord[j].y;
		}			
	}

	pScene->Add(box);

	pScene->fog = new SFog(SRGBA(0,0,0,255), 3, 8);
	pScene->ambientColor = SRGBA(55,55,55,255);

	pScene->Add( pLight = new CPointLight(Vector3(0,1,0), SRGBA(255,233,155,255)) );
	pLight->specular = SRGBA(255,233,155,100);
	pLight->range = 1;
	pLight->intensity = 1;
	pLight->specularAlpha = 0.3f;
	
	mat->specular = 0.04f;

	// Smoke
	CTexture *fxTex = new CTexture("textures/fx.png");		

	float posX = 0, posY = 1, posZ = 0;

	// add spirte
	CTexture *sprTex = new CTexture("textures/box.png");
	CSprite3D *spr1 = new CSprite3D(sprTex, 1, 1);
	spr1->SetPosition(3,3,-2);
	spr1->locked = true;
	spr1->lockedAxis = Vector3(0,1,0);

	spr2 = new CSprite3D(sprTex, 1, 1);
	spr2->SetPosition(3,3,0);
	spr2->locked = true;
	spr2->lockedAxis = Vector3(1,1,0);

	CSprite3D *spr3 = new CSprite3D(sprTex, 1, 1);
	spr3->SetPosition(3,3,2);
	spr3->locked = true;
	spr3->lockedAxis = Vector3(0,1,1);

	pScene->Add(spr1);
	pScene->Add(spr2);
	pScene->Add(spr3);

	//spr2->SetPosition(0,0.5f,2);
	//pCamera->Add(spr2);
	
	// Fog/Mist
	/*for (int i=0; i<10; i++)
	{
		float x = posX + (float)(rand()%100) / 150 - 0.0f;
		float y = posY + (float)(rand()%100) / 150 +0.5f;
		float z = posZ + (float)(rand()%100) / 150 - 0.0f;
		CSprite *spr = new CSprite(fxTex, 1.7f, 1.7f, false);
		spr->SetPosition(x,y,z);
		pScene->Add(spr);
		//spr->locked = true;
		x = rand()%2;
		y = rand()%2;
		//spr->additive = rand()%2 == 1 ? true : false;
		spr->texcoord[0] = Vector2(x*0.25,y*0.25);
		spr->texcoord[1] = Vector2(x*0.25+0.25,y*0.25+0.25);
		spr->color = SRGB(233,244,255);
		spr->opacity = 0.2;
		spr->additive = true;
	}*/

/*
	// 1) Flame/Smoke
	for (int i=0; i<4; i++)
	{
		float rnd = 0.05f;
		float x = posX + frand(-rnd,rnd);
		float y = posY + frand(-rnd,rnd)-0.5f;
		float z = posZ + frand(-rnd,rnd);
		CSprite3D *spr = new CSprite3D(fxTex, 1.0f+i*0.2f, 1.0f+i*0.2f, false);
		spr->SetPosition(x,y,z);
		pScene->Add(spr);
		//spr->locked = true;
		int type = i%4;
		x = type%2;
		y = type/2;
		spr->texcoord[0] = Vector2(x*0.25,y*0.25);
		spr->texcoord[1] = Vector2(x*0.25+0.25,y*0.25+0.25);
		spr->additive = true;

		spr->color = SRGB(178,95,16);;//SRGB(118,73,16);
		if (i == 0) spr->color = SRGB(255,224,222);
	}

	// 2) Flash
	/*for (int i=0; i<4; i++)
	{
		float rnd = 0.05f;
		float x = posX + frand(-rnd,rnd);
		float y = posY + frand(-rnd,rnd);
		float z = posZ + frand(-rnd,rnd);
		CSprite *spr = new CSprite(fxTex, 2.8f, 2.8f, false);
		spr->SetPosition(x,y,z);
		pScene->Add(spr);
		//spr->locked = true;
		int type = i%4;
		x = type%2;
		y = type/2;
		spr->texcoord[0] = Vector2(0.5+x*0.25,y*0.25);
		spr->texcoord[1] = Vector2(0.5+x*0.25+0.25,y*0.25+0.25);
		spr->additive = true;

		spr->color = SRGB(118,73,16);
		if (i == 0) spr->color = SRGB(255,224,222);
	}*/
/*
	CMaterial *fxMat = new CMaterial();
	fxMat->pTexture = fxTex;
	fxMat->features = EShaderFeature::TEXTURE;
	fxMat->color = SRGB(255,224,147);
	fxMat->blending = EBlending::Additive;
	fxMat->transparent = true;
	CGeometry *plane = new CPlaneGeometry(0.05f, 0.8f);

	float n = 0.1f;
	plane->faces[0].texcoord[0] = Vector2(1, 1.0f - n);
	plane->faces[0].texcoord[2] = Vector2(0.75f, 0.75f + n);
	plane->faces[0].texcoord[1] = Vector2(0.75f, 1.0f - n);

	plane->faces[1].texcoord[1] = Vector2(1, 0.75f+n);
	plane->faces[1].texcoord[0] = Vector2(0.75f, 0.75f + n);
	plane->faces[1].texcoord[2] = Vector2(1, 1.0f - n);

	fxMat->doubleSided = true;

	plane->materials.AddToTail(fxMat);

	int num = 40;
	
	for (int i=0; i<num; i++)
	{
		float rnd = 0.05f;
		float x = posX;// + frand(-rnd,rnd);
		float y = posY;// + frand(-rnd,rnd);
		float z = posZ;// + frand(-rnd,rnd);

		CMesh *spark = new CMesh(plane, fxMat);
		spark->SetPosition(x,y,z);

		if (i%8 == 0)
			spark->SetRotation(0, frand(0,90), frand(0,90) );
		else if (i % 8 == 1)
			spark->SetRotation(0, frand(90,180),  frand(0,90) );
		else if (i % 8 == 2)
			spark->SetRotation(0, frand(180,270),  frand(0,90) );
		else if (i % 8 == 3)
			spark->SetRotation(0, frand(270,360),  frand(0,90) );
		else if (i%8 == 4)
			spark->SetRotation(0, frand(0,90),  frand(-90,0) );
		else if (i % 8 == 5)
			spark->SetRotation(0, frand(90,180),  frand(-90,0) );
		else if (i % 8 == 6)
			spark->SetRotation(0, frand(180,270),  frand(-90,0) );
		else if (i % 8 == 7)
			spark->SetRotation(0, frand(270,360), frand(-90,0) );

		//spark->LookAt(Vector3(2,2,0));

		spark->SetScale(1,1,frand(0.5,0.75));
		spark->MoveForward(frand(0.3,0.6));
		
		pScene->Add(spark);	
		//spark->LookAt(Vector3(1.0f,2,0));
		//spark->SetRotationZ(90);
		
		sparks.AddToTail(spark);
	}

	// add car
	//CreateCar();

	

	// floor
	pFloor = new CMesh( new CCubeGeometry(15,0.1,15) );
	pFloorBody = CPhysics::CreateBox(pWorld, pFloor, 15, 0.1, 15);

	
	//pBox = (CMesh*)CModelLoader::Load("models/box.dae");;//new CMesh( new CCubeGeometry(1, 1, 1) );
	pBox = new CMesh( new CCubeGeometry(1, 1, 1) );
	
	pBox->SetPosition(0,3,0);
	pBox->SetRotation(0,0,0);
	pBoxBody = CPhysics::CreateBox(pWorld, pBox, 1, 1, 1, 1.0f);
	//pBox->SetScale(0.02f);

	/*AddBox(pScene, pWorld, Vector3(0,1,+1), Vector3(2,1,0.1), Vector3(0,0,0) );
	AddBox(pScene, pWorld, Vector3(0,1,-1), Vector3(2,1,0.1), Vector3(0,0,0) );
	AddBox(pScene, pWorld, Vector3(+0.7,4,0), Vector3(2,1,0.1), Vector3(0,90,0) );
	AddBox(pScene, pWorld, Vector3(-0.7,4,0),Vector3(2,1,0.1), Vector3(0,90,0) );
	
*/
/*	pScene->Add(pFloor);
	pScene->Add(pBox);
	

	NewtonBodySetForceAndTorqueCallback(pBoxBody, CEffectsGame::ApplyForceAndTorqueCallback);

	ReloadGeometry();
	

	pCamera->position.y = 2;*/
}