Exemplo n.º 1
0
void 
CubeViewer::
init()
{
    // initialize parent
    TrackballViewer::init();

	// create uniform cube
    m_meshes.push_back(createCube());
    m_meshes.push_back(createCube());
    m_meshes.push_back(createCube());

	
	// move cube to (0,0,1)
	m_meshes[0]->scaleObject( Vector3(2,2,2) );
	m_meshes[0]->translateWorld( Vector3(0,0,1) );
    
    // make second smaller cube
    m_meshes[1]->rotateObject(Vector3(0,-1,0), M_PI);
	m_meshes[1]->translateWorld( Vector3(-1,1,0) );
    m_meshes[1]->scaleObject( Vector3(0.6,0.6,0.6) );
    
    // make a third even smaller cube
    m_meshes[2]->rotateAroundAxisObject(Vector3(0.2,0.4,-0.3), Vector3(0.6,0.4,1).normalize(), 5*M_PI/6);
	m_meshes[2]->translateObject( Vector3(-1,1,1) );

	// set camera to look at world coordinate center
    set_scene_pos(Vector3(0.0, 0.0, 0.0), 2.0);
	
	// load cube shader
	m_cubeShader.create("cube.vs", "cube.fs");
}
Exemplo n.º 2
0
void test_front_side_corner_solver2(void){

  int value[6][9] = {{5,3,5,3,0,0,3,2,1},

                    {0,0,0,1,1,1,1,1,1},

                    {2,1,2,0,2,5,2,2,2},

                    {0,2,0,3,3,5,3,3,3},

                    {4,4,4,4,4,4,4,4,4},

                    {5,5,5,5,5,0,1,2,3}};

  int expectedValue[6][9] = {{0,2,2,3,0,1,1,3,5},

                             {5,0,2,1,1,1,1,1,1},

                             {0,2,1,2,2,5,2,2,2},

                             {0,0,3,3,3,5,3,3,3},

                             {4,4,4,4,4,4,4,4,4},

                             {5,5,5,5,5,0,3,0,0}};

  Cube *expectedCube = createCube(expectedValue);

  Cube *cube = createCube(value);

  sideCornerSolver(cube,0);

 ; customTestAssertCube(expectedCube, cube, 281);;

}
Exemplo n.º 3
0
void test_base_side_full_solver_with_different_cube(){

  int value[6][9] = {{4,3,2,3,0,2,2,4,5},

                    {2,0,3,5,1,4,2,2,5},

                    {0,3,0,2,2,4,1,4,4},

                    {3,0,1,1,3,0,3,0,1},

                    {4,5,5,3,4,5,1,1,0},

                    {0,2,5,1,5,1,3,5,4}};

  Cube *cube = createCube(value);

  int expectedValue[6][9] = {{3,0,1,3,0,3,0,2,2},

              {4,2,2,3,1,5,0,1,3},

              {3,0,1,1,2,5,5,2,1},

              {4,5,0,0,3,2,4,3,0},

              {4,4,5,4,4,4,2,4,3},

              {1,5,5,0,5,1,2,1,5}};

  Cube *expectedCube = createCube(expectedValue);

 baseSideFullSolver(cube,0);

 ; customTestAssertCube(expectedCube, cube, 136);;

}
Exemplo n.º 4
0
void test_base_side_solver_one_time(){

  int value[6][9] = {{0,0,4,1,0,4,4,2,5},

                    {2,5,1,2,1,2,3,2,1},

                    {5,0,3,4,2,4,5,3,3},

                    {4,3,2,5,3,5,2,0,3},

                    {0,0,0,1,4,1,0,4,2},

                    {5,1,4,3,5,3,1,5,1}};

  Cube *cube = createCube(value);

  int expectedValue[6][9] = {{0,0,0,1,0,1,4,2,2},

              {2,5,1,2,1,2,3,2,1},

              {5,0,4,4,2,3,5,3,1},

              {3,0,2,5,3,5,2,3,4},

              {0,0,4,1,4,4,0,4,5},

              {5,1,3,3,5,4,1,5,3}};

  Cube *expectedCube = createCube(expectedValue);

 baseSideSolver(cube,0);

 ; customTestAssertCube(expectedCube, cube, 36);;

}
Exemplo n.º 5
0
void test_base_side_full_solver_with_same_cube_above(){

  int value[6][9] = {{0,0,4,1,0,4,4,2,5},

                    {2,5,1,2,1,2,3,2,1},

                    {5,0,3,4,2,4,5,3,3},

                    {4,3,2,5,3,5,2,0,3},

                    {0,0,0,1,4,1,0,4,2},

                    {5,1,4,3,5,3,1,5,1}};

  Cube *cube = createCube(value);

  int expectedValue[6][9] = {{3,0,4,3,0,3,1,2,1},

              {5,2,2,2,1,5,0,1,5},

              {0,0,0,1,2,0,3,2,1},

              {5,5,3,3,3,0,4,3,1},

              {0,4,5,4,4,4,3,4,4},

              {2,5,2,1,5,1,4,5,2}};

  Cube *expectedCube = createCube(expectedValue);

 baseSideFullSolver(cube,0);

 ; customTestAssertCube(expectedCube, cube, 117);;

}
Exemplo n.º 6
0
void test_solver_side_corner(){

  int value[6][9] = {{5,1,2,0,0,1,5,5,2},

                     {3,5,1,0,1,2,1,1,1},

                     {0,3,0,3,2,3,2,2,2},

                     {1,2,3,0,3,0,3,3,3},

                     {4,4,4,4,4,4,4,4,4},

                     {5,5,5,1,5,2,0,5,0}};

  int expectedValue[6][9] = {{0,3,0,2,0,5,0,1,0},

                             {3,0,3,1,1,1,1,1,1},

                             {5,0,5,2,2,2,2,2,2},

                             {1,0,1,3,3,3,3,3,3},

                             {4,4,4,4,4,4,4,4,4},

                             {5,5,5,5,5,5,2,0,2}};

  Cube *cube = createCube(value);

  Cube *expectedCube = createCube(expectedValue);

  fullSideCornerSolver(cube,0);

 ; customTestAssertCube(expectedCube, cube, 320);;

}
Exemplo n.º 7
0
void test_full_solver_with_random_cube_by_using_createMessyCube_function_with_random_cube2(){

  int value[6][9] = {{1,1,0,5,0,0,4,0,5},

                    {5,3,2,1,1,4,2,1,4},

                    {1,2,0,5,2,5,5,2,3},

                    {3,3,2,1,3,0,5,3,2},

                    {1,4,4,0,4,2,3,3,0},

                    {4,4,1,2,5,5,0,4,3}};

 Cube *cube = createCube(value);

 Cube *correctCube = createCube(correctValue);

  createMessyCube(cube);

 fullSolver(cube,0);

  ; customTestAssertCube(correctCube, cube, 833);;

}
Exemplo n.º 8
0
void test_top_face_solver(){

  int value[6][9] = {{0,1,0,2,0,0,0,0,0},

                     {1,0,3,1,1,1,1,1,1},

                     {5,5,1,2,2,2,2,2,2},

                     {2,3,2,3,3,3,3,3,3},

                     {4,4,4,4,4,4,4,4,4},

                     {5,5,5,5,5,5,5,0,3}};

  int expectedValue[6][9] = {{3,0,5,0,0,0,0,0,0},

                             {2,2,1,1,1,1,1,1,1},

                             {2,3,3,2,2,2,2,2,2},

                             {5,1,1,3,3,3,3,3,3},

                             {4,4,4,4,4,4,4,4,4},

                             {5,5,5,5,5,5,0,5,0}};

  Cube *cube = createCube(value);

  Cube *expectedCube = createCube(expectedValue);

  topFaceSideSolver(cube, 2,8,0);

  ; customTestAssertCube(expectedCube, cube, 362);;

}
Exemplo n.º 9
0
void test_full_solver_with_random_cube_by_using_createMessyCube_function_with_correct_cube1(){

 Cube *correctCube = createCube(correctValue);

  int value[6][9] = {{5,5,2,3,0,1,2,2,5},

                    {0,0,3,3,1,2,1,1,1},

                    {0,0,0,3,2,5,2,2,2},

                    {3,0,0,1,3,2,3,3,3},

                    {4,4,4,4,4,4,4,4,4},

                    {5,5,5,5,5,1,1,0,1}};

 Cube *cube = createCube(value);

  createMessyCube(cube);

 fullSolver(cube,0);

  ; customTestAssertCube(correctCube, cube, 791);;

}
Exemplo n.º 10
0
void test_full_solver_with_random_cube_by_using_createMessyCube_function_with_random_cube1(){

  int value[6][9] = {{0,0,4,1,0,4,4,2,5},

                    {2,5,1,2,1,2,3,2,1},

                    {5,0,3,4,2,4,5,3,3},

                    {4,3,2,5,3,5,2,0,3},

                    {0,0,0,1,4,1,0,4,2},

                    {5,1,4,3,5,3,1,5,1}};

 Cube *cube = createCube(value);

 Cube *correctCube = createCube(correctValue);

  createMessyCube(cube);

 fullSolver(cube,0);

  ; customTestAssertCube(correctCube, cube, 819);;

}
Exemplo n.º 11
0
void test_top_face_full_solver_with_pattern_3(){

  int value[6][9] = {{0,1,0,2,0,0,0,0,0},

                     {1,0,3,1,1,1,1,1,1},

                     {5,5,1,2,2,2,2,2,2},

                     {2,3,2,3,3,3,3,3,3},

                     {4,4,4,4,4,4,4,4,4},

                     {5,5,5,5,5,5,5,0,3}};

  int expectedValue[6][9] = {{3,0,5,0,0,0,0,0,0},

                             {2,2,1,1,1,1,1,1,1},

                             {2,3,3,2,2,2,2,2,2},

                             {5,1,1,3,3,3,3,3,3},

                             {4,4,4,4,4,4,4,4,4},

                             {5,5,5,5,5,5,0,5,0}};

  Cube *cube = createCube(value);

  Cube *expectedCube = createCube(expectedValue);

  fullTopFaceSideSolver(cube,0);

  ; customTestAssertCube(expectedCube, cube, 400);;

}
Exemplo n.º 12
0
void test_base_corner_full_solver_to_solve_four_corner(){

  int value[6][9] = {{3,3,3,0,0,1,3,5,5},

                    {0,5,4,1,1,0,2,1,1},

                    {5,1,4,3,2,2,5,2,2},

                    {1,2,2,3,3,0,4,3,0},

                    {0,4,1,4,4,4,0,4,1},

                    {3,5,2,0,5,2,5,5,4}};

  Cube *cube = createCube(value);

  int expectedValue[6][9] = {{2,1,5,3,0,5,3,3,3},

              {1,2,5,1,1,0,1,1,1},

              {0,5,0,3,2,2,2,2,2},

              {2,0,1,1,3,0,3,3,3},

              {4,4,4,4,4,4,4,4,4},

              {5,5,5,0,5,2,0,5,0}};

  Cube *expectedCube = createCube(expectedValue);

 baseCornerFullSolver(cube,0);

 ; customTestAssertCube(expectedCube, cube, 240);;

}
Exemplo n.º 13
0
void test_full_solver(void){

  int value[6][9] = {{2,1,0,0,0,3,0,2,5},

                    {0,5,5,3,1,2,1,1,1},

                    {1,0,0,3,2,1,2,2,2},

                    {3,0,1,0,3,2,3,3,3},

                    {4,4,4,4,4,4,4,4,4},

                    {5,5,5,5,5,1,3,5,2}};

  Cube *cube = createCube(value);

 int print = 0;



 Cube *correctCube = createCube(correctValue);

 fullSolver(cube);

  ; customTestAssertCube(correctCube, cube, 756);;

}
Exemplo n.º 14
0
void test_full_top_side_solver_side_D_is_correct(){

  int value[6][9] = {{0,0,0,0,0,0,0,0,0},

                     {1,3,1,1,1,1,1,1,1},

                     {2,1,2,2,2,2,2,2,2},

                     {3,2,3,3,3,3,3,3,3},

                     {4,4,4,4,4,4,4,4,4},

           {5,5,5,5,5,5,5,5,5}};



  Cube *cube = createCube(value);

 Cube *correctCube = createCube(correctValue);

 topSideSolver(cube,0);

  ; customTestAssertCube(correctCube, cube, 741);;

}
Exemplo n.º 15
0
void test_top_face_corner_solver(){

  int value[6][9] = {{1,0,2,0,0,0,0,0,3},

                     {5,2,3,1,1,1,1,1,1},

                     {5,3,0,2,2,2,2,2,2},

                     {2,5,0,3,3,3,3,3,3},

                     {4,4,4,4,4,4,4,4,4},

                     {5,5,5,5,5,5,0,1,1}};

  int expectedValue[6][9] = {{0,0,0,0,0,0,0,0,0},

                             {3,1,1,1,1,1,1,1,1},

                             {2,3,5,2,2,2,2,2,2},

                             {1,2,3,3,3,3,3,3,3},

                             {4,4,4,4,4,4,4,4,4},

                             {5,5,5,5,5,5,2,5,5}};

  Cube *cube = createCube(value);

  Cube *expectedCube = createCube(expectedValue);

  topFaceCornerSolver(cube,0);

  ; customTestAssertCube(expectedCube, cube, 441);;

}
Exemplo n.º 16
0
void test_full_top_face_corner_solver_with_no_corner_is_white(){

  int value[6][9] = {{5,0,2,0,0,0,5,0,2},

                     {0,1,0,1,1,1,1,1,1},

                     {3,5,3,2,2,2,2,2,2},

                     {0,3,0,3,3,3,3,3,3},

                     {4,4,4,4,4,4,4,4,4},

                     {5,5,5,5,5,5,1,2,1}};

  int expectedValue[6][9] = {{0,0,0,0,0,0,0,0,0},

                             {1,3,3,1,1,1,1,1,1},

                             {5,5,2,2,2,2,2,2,2},

                             {3,2,1,3,3,3,3,3,3},

                             {4,4,4,4,4,4,4,4,4},

                             {5,5,5,5,5,5,5,1,2}};

  Cube *cube = createCube(value);

  Cube *expectedCube = createCube(expectedValue);

  fullTopFaceCornerSolver(cube,0);

  ; customTestAssertCube(expectedCube, cube, 501);;

}
Exemplo n.º 17
0
void test_full_solver_with_random_cube_by_using_createMessyCube_function_with_correct_cube(){

 Cube *correctCube = createCube(correctValue);

 Cube *cube = createCube(correctValue);

  createMessyCube(cube);

 fullSolver(cube,0);

  ; customTestAssertCube(correctCube, cube, 777);;

}
Exemplo n.º 18
0
 void initialize(int colors[], GLfloat l = 1.0f, GLfloat h = 1.0f, GLfloat b = 1.0f) {
   length = l;
   height = h;
   breadth = b;
   for (int i=0; i<6; i++)
     color_scheme[i] = colors[i];
   createCube();
 }
Exemplo n.º 19
0
Graphics::Graphics(HWND outputWindow, int width, int height) : width(width), height(height) {
	initializeDirect3d11App(outputWindow, width, height);

	light.diffuse = 0.6;
	light.ambient = XMFLOAT4(0.3, 0.3, 0.3, 0.0);
	light.position = XMFLOAT3(3.0, 7.0, 10.0);

	Model *bunny = loadObjModel("resources\\bunny.3dobj", 0.01);
	Model *cube = createCube();
	Model *allModel = concatModel(createCube(), bunny, 3, 0, 0);

	model = bunny;

	initCamera();

	initPass();
	initDebugPass();

	XMMATRIX trans = XMMatrixTranslation(3, 0, 0);
	XMFLOAT4X4 transMatrix;
	XMStoreFloat4x4(&transMatrix, trans);
	pass->setWorldMatrix(transMatrix);

	skyMapPass = new SkyMapPass(device, context, camera, defaultRenderTarget);
	skyMapPass->init("resources\\skymap.dds", width, height);

	renderDepthPass = new RenderDepthPass(device, context, camera, depthRenderTarget);
	renderDepthPass->init(allModel, &light, width, height);

	shadowMapPass = new ShadowMapPass(device, context, camera, defaultRenderTarget);
	shadowMapPass->init(createPlane(), &light, "resources\\grass.jpg", depthRenderTarget->getTexture(), width, height);

	normalMapPass = new NormalMapPass(device, context, camera, defaultRenderTarget);
	normalMapPass->init(createCube(), "resources\\brick_bump.jpg", "resources\\brick.jpg", &light, width, height);

	// instances
	InstanceType* instances = new InstanceType[2];
	instances[0].offset = XMFLOAT3(1, 0, 0);
	instances[1].offset = XMFLOAT3(5, 0, 0);

	ModelInstance *twoCube = new ModelInstance(*createCube(), instances, 2);
	instancesPass = new InstancesPass(device, context, camera, defaultRenderTarget);
	instancesPass->init(twoCube, width, height);
}
Exemplo n.º 20
0
__fastcall TActiveFormX::TActiveFormX(TComponent* AOwner) : TActiveForm(AOwner)
{

    // create a new world
    world = new cWorld();

    // set background color
    world->setBackgroundColor(0.0f,0.0f,0.0f);

    // Create a camera
    camera = new cCamera(world);
    world->addChild(camera);

    // Create a light source and attach it to camera
    light = new cLight(world);
    light->setEnabled(true);
    light->setPos(cVector3d(2,1,1));

    // define camera position
    cameraAngleH = 10;
    cameraAngleV = 20;
    cameraDistance = 2.0;
    flagCameraInMotion = false;
    updateCameraPosition();
    camera->setClippingPlanes(0.01, 10.0);

    // create a display for graphic rendering
    viewport = new cViewport(Panel1->Handle, camera, true);
    viewport->setStereoOn(false);

    // create a mesh - we will build a simple cube, and later let the
    // user load 3d models
    object = new cMesh(world);
    world->addChild(object);

    // create a nice little cube
    createCube(object, 0.2);

    // define a material property for this object
    cMaterial material;
    material.m_ambient.set( 0.4, 0.2, 0.2, 1.0 );
    material.m_diffuse.set( 0.8, 0.6, 0.6, 1.0 );
    material.m_specular.set( 0.9, 0.9, 0.9, 1.0 );
    material.setShininess(100);
    material.setStiffness(20 );
    object->m_material = material;

    // update camera position
    updateCameraPosition();

    // don't start the haptics loop yet
    flagSimulationOn = false;
    flagHasExitedSimulation = true;
}
Exemplo n.º 21
0
Arquivo: bounceGL.c Projeto: shua/jams
int setupGL() {
	if(!glfwInit()) {
		printf("glfwInit failed \n");
		return 1;
	}

	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_COMPAT_PROFILE);
	glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);

	window = glfwCreateWindow(800, 600, "bounce", NULL, NULL);
	if(!window) {
		glfwTerminate();
		printf("window creation failed \n");
		return 1;
	}

	glewExperimental = GL_TRUE;
	if(glewInit() != GLEW_OK) {
		glfwTerminate();
		printf("glewInit failed \n");
		return 1;
	}

	glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
	glfwSetWindowSizeCallback(window, cb_resize);
	glfwSetWindowCloseCallback(window, cb_close);
	glfwSwapInterval(1);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	glEnable(GL_CULL_FACE);
	glFrontFace(GL_CCW);
	glCheck(glClearColor(0.06, 0.06, 0.06, 0.f)); // One check right at the end

	GLuint vao;
	glGenVertexArrays(1, &vao);
	glBindVertexArray(vao);
	if(createShader() != 0) {
		glfwTerminate();
		printf("shader creation failed \n");
		return 1;
	}

	projection_matrix = perspective(60.f, (float)800/600, 0.1f, 100.f);
	hud_projection_matrix = orthogonal(-40, 40, -30, 30);
	glCheck(glUniformMatrix4fv(prjMatUniLoc, 1, GL_FALSE, &(projection_matrix.m[0])));
	view_matrix = IDENTITY_MATRIX;
	model_matrix = IDENTITY_MATRIX;
	glCheck(createCube());
	return 0;
}
Exemplo n.º 22
0
int main(int argc,const char *argv[])
{
    s32 ret,i;
    padInfo padinfo;
    padData paddata;
    rsxProgramConst *consts = rsxFragmentProgramGetConsts(fpo);

    initialize();
    ioPadInit(7);

    sphere = createSphere(3.0f,32,32);
    donut = createDonut(3.0f,1.5f,32,32);
    cube = createCube(5.0f);

    rsxConstOffsetTable *co_table = rsxFragmentProgramGetConstOffsetTable(fpo,consts[lightColor_id].index);
    u32 const_addr = (u32)((u64)fp_buffer + co_table->offset[0]);
    setup_shared_buffer(const_addr,(u32)(u64)mem_align(128,128),(u32)(u64)gcmGetLabelAddress(64));
    signal_spu_ppu();
    signal_spu_rsx();

    P = transpose(Matrix4::perspective(DEGTORAD(45.0f),aspect_ratio,1.0f,3000.0f));

    setRenderTarget(curr_fb);
    rsxFinish(context,0);

    ret = atexit(program_exit_callback);
    ret = sysUtilRegisterCallback(0,sysutil_exit_callback,NULL);

    delete cube;

    running = 1;
    while(running) {
        ret = sysUtilCheckCallback();

        ioPadGetInfo(&padinfo);
        for(i=0; i<MAX_PADS; i++) {
            if(padinfo.status[i]) {
                ioPadGetData(i, &paddata);

                if(paddata.BTN_CROSS) {
                    return 0;
                }
            }

        }

        drawFrame();
        flip();
    }

    return 0;
}
Exemplo n.º 23
0
void render() {

    if (initialized == false) {
        createProgram();
        createCube();
        setSwapInterval(0);
        startTimeMillis = currentTimeMillis();
        initialized = true;
    }

    frameCount++;
    totalFrameCount++;
    long now = currentTimeMillis();
    long elapsed = now - startTimeMillis;
    static long lastTimerCall = 0;
    if ((now - lastTimerCall) > 250) {
        timer(0);
        lastTimerCall = now;
    }

    glClear(GL_COLOR_BUFFER_BIT);
    glEnable(GL_CULL_FACE);
    glUseProgram(programId);

    //
    // calculate the ModelViewProjection and ModelViewProjection matrices
    //
    matrix44 tmp, mv, mvp, frustumMat, translateMat, rotateMat1, rotateMat2;
    frustum(frustumMat, left, right, bottom / aspectRatio, top / aspectRatio, nearPlane, farPlane);
    translate(translateMat, 0.0f, 0.0f, -3.0f);
    rotate(rotateMat1, 1.0f * elapsed / 100, 1.0f, 0.0f, 0.0f);
    rotate(rotateMat2, 1.0f * elapsed / 50, 0.0f, 1.0f, 0.0f);
    multm(tmp, rotateMat1, rotateMat2);
    multm(mv, translateMat, tmp);
    multm(mvp, frustumMat, mv);

    // set the uniforms before rendering
    GLuint mvpMatrixUniform = glGetUniformLocation(programId, "mvpMatrix");
    GLuint mvMatrixUniform = glGetUniformLocation(programId, "mvMatrix");
    GLuint colorUniform = glGetUniformLocation(programId, "color");
    GLuint lightDirUniform = glGetUniformLocation(programId, "lightDir");
    glUniformMatrix4fv(mvpMatrixUniform, 1, false, mvp);
    glUniformMatrix4fv(mvMatrixUniform, 1, false, mv);
    glUniform3f(colorUniform, 0.0f, 1.0f, 0.0f);
    glUniform3f(lightDirUniform, 0.0f, 0.0f, -1.0f);
    
	// render the cube
    renderCube();

    // display rendering buffer
    SDL_GL_SwapBuffers();
}
Exemplo n.º 24
0
int SkyBox::init(void) {
  int rc;
  rc = s.createShaderProgram("skybox.vert","skybox.frag", &shaderProg);
  if (rc != 0) {
    printf(" error after generating skybox shaders \n");
    getchar();
    exit(1);
  }

  createCube();

  return 0;
}
Exemplo n.º 25
0
void test_base_side_full_solver_with_random_cube(){

  int value[6][9] = {{2,0,5,2,0,3,0,0,5},

                    {0,1,5,1,1,3,3,1,4},

                    {1,2,3,5,2,0,1,2,2},

                    {4,2,4,3,3,1,3,3,0},

                    {2,4,4,5,4,4,0,5,1},

                    {5,4,2,4,5,0,3,5,1}};

  Cube *cube = createCube(value);

  Cube *expectedCube = createCube(correctValue);

 int print = 10;

 baseSideFullSolver(cube,print);

 baseCornerFullSolver(cube,print);

 fullSideCornerSolver(cube,print);

 fullTopFaceSideSolver(cube,print);

 fullTopFaceCornerSolver(cube,print);

 topCornerFullSolver(cube,print);

 topSideSolver(cube,print);



 ; customTestAssertCube(expectedCube, cube, 854);;

}
Exemplo n.º 26
0
void test_base_corner_solver_to_solve_three_corner_by_run_base_corner_solver_three_times(){

  int value[6][9] = {{3,3,3,0,0,1,3,5,5},

                    {0,5,4,1,1,0,2,1,1},

                    {5,1,4,3,2,2,5,2,2},

                    {1,2,2,3,3,0,4,3,0},

                    {0,4,1,4,4,4,0,4,1},

                    {3,5,2,0,5,2,5,5,4}};

  Cube *cube = createCube(value);

  int expectedValue[6][9] = {{2,3,2,1,0,1,3,3,1},

              {0,2,5,1,1,0,1,1,1},

              {0,5,4,3,2,0,5,2,2},

              {2,5,0,5,3,0,3,3,3},

              {0,4,4,4,4,4,4,4,4},

              {5,5,5,0,5,2,3,2,1}};

  Cube *expectedCube = createCube(expectedValue);

 baseCornerSolver(cube,0);

 baseCornerSolver(cube,0);

 baseCornerSolver(cube,0);

 ; customTestAssertCube(expectedCube, cube, 197);;

}
Exemplo n.º 27
0
int LessonCube::onInit()
{
	glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
    
    g_scene = new Scene();

    //cube1
    GameObjectPtr cube1 = createCube();
    cube1->setTag(Tag_Cube1);
    
    cube1->getTransform()->setPosition(0, 0, 0);
    
    g_scene->getRoot()->addChild(cube1);
    
    //cube2
    GameObjectPtr cube2 = createCube();
    cube2->setTag(Tag_Cube2);
    
    cube2->getTransform()->setPosition(2, 0, 0);
    
    g_scene->getRoot()->addChild(cube2);
    
    //camera
    int screenWidth = Application::GetScreenWidth();
    int screenHeight = Application::GetScreenHeight();
    
    GameObjectPtr camera = g_scene->createCamera();
    camera->getCamera()->setPerspectiveProjection(60.0f, 0.1f, 100.0f, (float)screenWidth/screenHeight);
    camera->getTransform()->setPosition(0, 0, 10);
    camera->getCamera()->setTarget(Vector3(0,0,0));
    
    g_scene->getRoot()->addChild(camera);
    g_scene->setCurrentCamera(camera);
    
	glEnable(GL_DEPTH_TEST);

	return 1;
}
Exemplo n.º 28
0
void test_full_solver1(void){

  int value[6][9] = {{5,5,2,3,0,1,2,2,5},

                    {0,0,3,3,1,2,1,1,1},

                    {0,0,0,3,2,5,2,2,2},

                    {3,0,0,1,3,2,3,3,3},

                    {4,4,4,4,4,4,4,4,4},

                    {5,5,5,5,5,1,1,0,1}};

  Cube *cube = createCube(value);

 Cube *correctCube = createCube(correctValue);

 fullSolver(cube,0);

  ; customTestAssertCube(correctCube, cube, 769);;

}
Exemplo n.º 29
0
void test_full_top_corner_solver_A_and_D_is_correct(){

  int value[6][9] = {{0,0,0,0,0,0,0,0,0},

                     {1,3,3,1,1,1,1,1,1},

                     {5,5,2,2,2,2,2,2,2},

                     {3,2,1,3,3,3,3,3,3},

                     {4,4,4,4,4,4,4,4,4},

           {5,5,5,5,5,5,5,1,2}};



  int expectedValue[6][9] = {{0,0,0,0,0,0,0,0,0},

                             {1,5,1,1,1,1,1,1,1},

                             {2,2,2,2,2,2,2,2,2},

                             {3,1,3,3,3,3,3,3,3},

                             {4,4,4,4,4,4,4,4,4},

                             {5,5,5,5,5,5,5,3,5}};

  Cube *cube = createCube(value);

  Cube *expectedCube = createCube(expectedValue);

 topCornerFullSolver(cube,0);

  ; customTestAssertCube(expectedCube, cube, 666);;

}
Exemplo n.º 30
0
int main(int argc,const char *argv[])
{
	s32 ret,i;
	padInfo padinfo;
	padData paddata;
	void *host_addr = memalign(1024*1024,HOST_SIZE);

	printf("rsxtest started...\n");

	init_screen(host_addr,HOST_SIZE);
	ioPadInit(7);
	init_shader();
	init_texture();

	sphere = createSphere(3.0f,32,32);
	donut = createDonut(3.0f,1.5f,32,32);
	cube = createCube(5.0f);

	ret = atexit(program_exit_callback);
	ret = sysUtilRegisterCallback(0,sysutil_exit_callback,NULL);

	P = transpose(Matrix4::perspective(DEGTORAD(45.0f),aspect_ratio,1.0f,3000.0f));

	setTexture();
	setDrawEnv();
	setRenderTarget(curr_fb);

	running = 1;
	while(running) {
		ret = sysUtilCheckCallback();

		ioPadGetInfo(&padinfo);
		for(i=0; i<MAX_PADS; i++){
			if(padinfo.status[i]){
				ioPadGetData(i, &paddata);

				if(paddata.BTN_CROSS){
					return 0;
				}
			}

		}
		
		drawFrame();
		flip();
	}

	return 0;
}