Beispiel #1
0
void initRoomEdition(void)
{
	initLights();
	initBlocks();
	initEntities();
	initInterface();
	initEditorRoom(&editorRoom);
	initContextButtons();
	initSelection(NULL);
	initCamera(&editorCamera);
	// initProjectionMatrixOrtho(&editorCamera, inttof32(-128), inttof32(127),inttof32(-96), inttof32(95), inttof32(-1000), inttof32(1000));
	initProjectionMatrix(&editorCamera, 70*90, inttof32(4)/3, inttof32(1)/10, inttof32(1000)); //TEMP?
	editorCamera.position=vect(0,0,0);
	editorTranslation=vect(0,0,inttof32(-1));
	editorScale=inttof32(1);
	lineOfTouchOrigin=vect(0,0,0);
	lineOfTouchVector=vect(0,0,0);
	currentScreen=false;

	//initial camera setup
	rotateMatrixY(editorCamera.transformationMatrix, 2048+384, true);
	rotateMatrixX(editorCamera.transformationMatrix, 1024+128, false);
	editorScale=inttof32(8*20);

	//controls stuff
	touchRead(&currentTouch);
	oldTouch=currentTouch;

	//cosmetics
	glSetOutlineColor(0,RGB15(0,0,0));
	glSetOutlineColor(1,RGB15(29,15,3));

	glMaterialf(GL_AMBIENT, RGB15(8,8,8));
	glMaterialf(GL_DIFFUSE, RGB15(24,24,24));
	glMaterialf(GL_SPECULAR, RGB15(0,0,0));
	glMaterialf(GL_EMISSION, RGB15(0,0,0));

	glSetToonTableRange(0, 2, RGB15(8,8,8));
	glSetToonTableRange(3, 31, RGB15(24,24,24));

	glLight(0, RGB15(31,31,31), cosLerp(4096)>>3, 0, sinLerp(4096)>>3);
}
Beispiel #2
0
static void set3DView()
{
    static const float nearZ = 0.01f, farZ = 100.0f;
    mtx44 projection, modelView;

    // standard perspective projection
    initProjectionMatrix((float*) projection, 80.0f*M_PI/180.0f, 240.0f/400.0f, nearZ, farZ);
    rotateMatrixZ((float*) projection, M_PI/2, false);   //because framebuffer is sideways...
    glPerspectiveProjectionMatrixfCTR((float*) projection,
            nearZ,  // must match the value passed to initProjectionMatrix

            -5.0f,  // depth of the plane that will converge at screen depth in stereo,
                    // e.g. everything further will be behind the screen, everything closer will pop out

            0.2f    // determine experimentally; allows you to mix multiple views in one coherent stereo
            );

    // poor man's camera control
    loadIdentity44((float*) modelView);
    translateMatrix((float*) modelView, position.x, position.y, position.z);
    rotateMatrixX((float*) modelView, angle.x, false);
    rotateMatrixY((float*) modelView, angle.y, false);
    glModelviewMatrixfCTR((float*) modelView);
}
Beispiel #3
0
void menuFrame(void)
{
	if(!d3dScreen)initProjectionMatrix(&menuCamera, 70*90, inttof32(4)/3, inttof32(2), inttof32(1000));
	else initProjectionMatrixBottom(&menuCamera, 70*90, inttof32(4)/3, inttof32(2), inttof32(1000));

	projectCamera(&menuCamera);
	glLoadIdentity();

	glLight(0, RGB15(31,31,31), cosLerp(lightAngle)>>3, 0, sinLerp(lightAngle)>>3);

	GFX_CLEAR_COLOR=RGB15(0,0,0)|(31<<16);

	scanKeys();
	touchRead(&currentTouch);

	if((keysHeld() & KEY_R) && (keysHeld() & KEY_L))changeState(&menuState);

	if(keysHeld() & KEY_R)tempState.position=addVect(tempState.position,vect(0,0,inttof32(1)/64));
	if(keysHeld() & KEY_L)tempState.position=addVect(tempState.position,vect(0,0,-inttof32(1)/64));
	if(keysHeld() & KEY_UP)tempState.position=addVect(tempState.position,vect(0,inttof32(1)/64,0));
	if(keysHeld() & KEY_DOWN)tempState.position=addVect(tempState.position,vect(0,-inttof32(1)/64,0));
	if(keysHeld() & KEY_RIGHT)tempState.position=addVect(tempState.position,vect(inttof32(1)/64,0,0));
	if(keysHeld() & KEY_LEFT)tempState.position=addVect(tempState.position,vect(-inttof32(1)/64,0,0));

	//TEMP (updateCamera stuff)
		menuCamera.viewPosition=menuCamera.position;

	// if(keysHeld() & KEY_A)lightAngle+=128;
	// else if(keysHeld() & KEY_B)lightAngle-=128;
		
	if(keysHeld() & KEY_A)tempState.angle.x+=64;
	if(keysHeld() & KEY_B)tempState.angle.x-=64;
	if(keysHeld() & KEY_X)tempState.angle.y+=64;
	if(keysHeld() & KEY_Y)tempState.angle.y-=64;
	if(keysHeld() & KEY_START)tempState.angle.z+=64;
	if(keysHeld() & KEY_SELECT)tempState.angle.z-=64;

	// if(keysUp() & KEY_TOUCH)
	// {
	// 	if(tempbool)testTransition=startCameraTransition(&cameraStates[1],&cameraStates[0],64);
	// 	else testTransition=startCameraTransition(&cameraStates[0],&cameraStates[1],64);

	// 	tempbool^=1;
	// }

	if(!(keysHeld() & KEY_TOUCH)) updateSimpleGui(-1, -1);
	else updateSimpleGui(currentTouch.px, currentTouch.py);

	// applyCameraState(&menuCamera,&tempState);
	updateCameraTransition(&menuCamera,&testTransition);

	drawMenuScene();

	switch(d3dScreen)
	{
		case true:
			drawSimpleGui();
			updateMenuScene();
			break;
		default:
			if(logoAlpha)drawLogo();
			break;
	}
	
	glFlush(0);
	swiWaitForVBlank();

	updateD3D();
}