Beispiel #1
0
void drawScene(camera_s* c, portal_s* p, int depth, u8 stencil)
{
	if(!c)return;

	gsMatrixMode(GS_MODELVIEW);
	gsPushMatrix();
		gsLoadIdentity();
		useCamera(c);

		drawRoom(&testRoom);

		drawCubeDispensers();
		drawEnergyDevices();
		drawEnergyBalls();
		drawPlatforms();
		drawBigButtons();
		drawTimedButtons();
		drawWallDoors();
		drawDoors();
		drawOBBs();

		if(p && depth)drawPlayer(&testPlayer);
		
		drawSludge(&testRoom);

		drawEmancipators();
		drawEmancipationGrids();

		if(p == &portals[0])drawPortals((portal_s*[]){&portals[0]}, 1, drawScene, c, depth, stencil);
// Constructor
BattleGround::BattleGround(void)
        : end(false)
{
    // Default settings
    //setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
    setAmbientLight(Ogre::ColourValue(1,1,1));
    // Create camera
    look_node = getManager().getRootSceneNode()->createChildSceneNode();
    cam_node = getManager().getRootSceneNode()->createChildSceneNode();
    useCamera(addCamera("BattleGround Camera", *cam_node, *look_node));

    // Ground
    addObject("cube", Ogre::Vector3(0,-5,0), Ogre::Vector3(10,1,1));
    addObject("cube", Ogre::Vector3(-23,7,0), Ogre::Vector3(3,0.5,1));
    addObject("cube", Ogre::Vector3(23,7,0), Ogre::Vector3(3,0.5,1));
    for (int i=0; i<5; i++)
        addObject("cube", Ogre::Vector3(0,5*i,0), Ogre::Vector3(0.6,0.6,0.6), 100);

    setStartingPosition(-10,10);
    setStartingPosition(10,10);

#if DEBUG_PHYSIC_SHAPES
    createDebugDrawer(getManager());
#endif

    bool hydrax = false, skyx = false;
    FtsEvaluator ev(ScriptManager::get().getL());
    ev.evalBool("Config.Hydrax", hydrax);
    ev.evalBool("Config.SkyX", skyx);

    if(hydrax)
        createWaterPlane();
    if(skyx)
        createSky();
}
Beispiel #3
0
void drawPlayerGun(player_s* p)
{
	if(!p)return;

	gsPushMatrix();
		useCamera(&p->camera);
		gsLoadIdentity();

		GPU_SetDepthTestAndWriteMask(true, GPU_ALWAYS, GPU_WRITE_DEPTH);
		gsSwitchRenderMode(-1);

		GPU_SetAttributeBuffers(
			2, // number of attributes
			(u32*)osConvertVirtToPhys(rectangleBaseAddr), // we use the start of linear heap as base since that's where all our buffers are located
			GPU_ATTRIBFMT(0, 3, GPU_FLOAT)|GPU_ATTRIBFMT(1, 2, GPU_FLOAT), // we want v0 (vertex position) and v1 (texcoord)
			0xFFC, // mask : we want v0 and v1
			0x10, // permutation : we use identity
			1, // number of buffers : we have one attribute per buffer
			(u32[]){(u32)rectangleVertexData-rectangleBaseAddr}, // buffer offsets (placeholders)
			(u64[]){0x10}, // attribute permutations for each buffer
			(u8[]){2} // number of attributes for each buffer
			);

		gsSetShader(&passthroughProgram);

		GPU_DrawArray(GPU_TRIANGLES, 6);

		GPU_SetDepthTestAndWriteMask(true, GPU_ALWAYS, GPU_WRITE_ALL);

		GPUCMD_AddWrite(GPUREG_ATTRIBBUFFER0_CONFIG0, (u32)crosshairVertexData-rectangleBaseAddr);
		textureBind(&crosshairTexture, GPU_TEXUNIT0);

		GPU_DrawArray(GPU_TRIANGLES, 6);

		GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
		gsSwitchRenderMode(md2GsMode);

		gsTranslate(1.3, -1.65, -3.1);
		gsRotateY(p->tempAngle.y);
		gsRotateX(-p->tempAngle.x);
		gsRotateX(-0.1);
		gsRotateZ(M_PI/2);
		gsRotateY(-M_PI/2);
		gsRotateX(-M_PI/2);
		gsScale(3.0f/8, 3.0f/8, 3.0f/8);

		md2InstanceDraw(&p->gunInstance);
	gsPopMatrix();
}
Beispiel #4
0
// topscreen
void renderMenuFrame(u32* outBuffer, u32* outDepthBuffer)
{
	GPU_SetViewport((u32*)osConvertVirtToPhys((u32)outDepthBuffer),(u32*)osConvertVirtToPhys((u32)outBuffer),0,0,240,400);
	
	GPU_DepthMap(-1.0f, 0.0f);
	GPU_SetFaceCulling(GPU_CULL_FRONT_CCW);
	GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
	GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP);
	GPU_SetBlendingColor(0,0,0,0);
	GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
	
	GPUCMD_AddMaskedWrite(GPUREG_0062, 0x1, 0); 
	GPUCMD_AddWrite(GPUREG_0118, 0);
	
	GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
	GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00);
	
	GPU_SetTextureEnable(GPU_TEXUNIT0);
	
	GPU_SetTexEnv(0, 
		GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
		GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
		GPU_TEVOPERANDS(0,0,0), 
		GPU_TEVOPERANDS(0,0,0), 
		GPU_MODULATE, GPU_MODULATE, 
		0xFFFFFFFF);
	GPU_SetDummyTexEnv(1);
	GPU_SetDummyTexEnv(2);
	GPU_SetDummyTexEnv(3);
	GPU_SetDummyTexEnv(4);
	GPU_SetDummyTexEnv(5);

	gsMatrixMode(GS_MODELVIEW);
	gsPushMatrix();
		gsLoadIdentity();
		useCamera(&menuCamera);

		gsSwitchRenderMode(md2GsMode);
		md2InstanceDraw(&gladosInstance);
		md2InstanceDraw(&gladosLairInstance);

	gsPopMatrix();

	GPU_SetDepthTestAndWriteMask(true, GPU_ALWAYS, GPU_WRITE_ALL);
	
	if(currentCameraState==2)
	{
		gsPushMatrix();
			gsSwitchRenderMode(-1);

			GPU_SetAttributeBuffers(
				1, // number of attributes
				(u32*)osConvertVirtToPhys(logoBaseAddr), // we use the start of linear heap as base since that's where all our buffers are located
				GPU_ATTRIBFMT(0, 3, GPU_FLOAT), // we want v0 (vertex position)
				0xFFE, // mask : we want v0
				0x0, // permutation : we use identity
				1, // number of buffers : we have one attribute per buffer
				(u32[]){(u32)logoRectangleVertexData-logoBaseAddr}, // buffer offsets (placeholders)
				(u64[]){0x0}, // attribute permutations for each buffer
				(u8[]){1} // number of attributes for each buffer
				);

			gsSetShader(&logoProgram);

			gsMatrixMode(GS_MODELVIEW);
			gsLoadIdentity();

			gsPushMatrix();
				gsTranslate(0.15f, 0.325f, 0.0f);
				gsScale(64.0f * 2.0f / 240.0f, 64.0f * 2.0f / 400.0f, 1.0f);

				gsTranslate(0.5f, 0.5f, 0.0f);
				gsRotateZ(logoangle+=0.01f);
				gsTranslate(-0.5f, -0.5f, 0.0f);

				gsUpdateTransformation();

				textureBind(&rotateLogoTexture, GPU_TEXUNIT0);
				GPU_SetFloatUniform(GPU_VERTEX_SHADER, logoUniformTextureDimensions, (u32*)(float[]){0.0f, 0.0f, 1.0f, 1.0f}, 1);