Example #1
0
/* functie care roteste un strat al cubului rubik in orice directie */
void Rubik::rotate_layer (int layer, float speed) {
	Point3d center;
	std::vector<int> to_move = get_layer(layer);

	for (int i = 0; i < to_move.size(); i++) {
		if (layer == LEFT || layer == RIGHT) {
			rotateX(to_move[i], cs->axiscenter, speed);
		}
			
		if (layer == TOP || layer == BOTTOM) {
			rotateY(to_move[i], cs->axiscenter, speed);
		}

		if (layer == BACK || layer == FRONT) {
			rotateZ(to_move[i], cs->axiscenter, speed);
		}

		if (layer == CENTER_X) {
			rotateY(to_move[i], cs->axiscenter, speed);
		}
			
		if (layer == CENTER_Y) {
			rotateX(to_move[i], cs->axiscenter, speed);
		}

		if (layer == CENTER_Z) {
			rotateZ(to_move[i], cs->axiscenter, speed);
		}
	}
}
Example #2
0
/*! The matrix is:\n
 *  \verbatim
 *  [0][0] = (RtFloat)(x*x + cosw*(1.0 - x*x));
 *  [0][1] = (RtFloat)(x*y*(1.0 - cosw) + z*sinw);
 *  [0][2] = (RtFloat)(z*x*(1.0 - cosw) - y*sinw);
 *  [1][0] = (RtFloat)(x*y*(1.0 - cosw) - z*sinw);
 *  [1][1] = (RtFloat)(y*y + cosw*(1.0 - y*y));
 *  [1][2] = (RtFloat)(y*z*(1.0 - cosw) + x*sinw);
 *  [2][0] = (RtFloat)(z*x*(1.0 - cosw) + y*sinw);
 *  [2][1] = (RtFloat)(y*z*(1.0 - cosw) - x*sinw);
 *  [2][2] = (RtFloat)(z*z + cosw*(1.0 - z*z));
 *  \endverbatim
 *  \param w degrees to rotate
 *  \param x x-coordinate of the axis vector
 *  \param y y-coordinate of the axis vector
 *  \param z z-coordinate of the axis vector
 */
void TMatrix3D::rotate(RtFloat w, RtFloat x, RtFloat y, RtFloat z) {
        TMatrix3D r;

        if ( x > 0.0 && y == 0.0 && z == 0.0 ) { rotateX(w); return; }
        if ( x < 0.0 && y == 0.0 && z == 0.0 ) { rotateX(-w); return; }
        if ( x == 0.0 && y > 0.0 && z == 0.0 ) { rotateY(w); return; }
        if ( x == 0.0 && y < 0.0 && z == 0.0 ) { rotateY(-w); return; }
        if ( x == 0.0 && y == 0.0 && z > 0.0 ) { rotateZ(w); return; }
        if ( x == 0.0 && y == 0.0 && z < 0.0 ) { rotateZ(-w); return; }

        w = deg2rad(w);

        RtFloat length = (RtFloat)sqrt(x*x + y*y + z*z);
        RtFloat sinw = (RtFloat)sin(w);
        RtFloat cosw = (RtFloat)cos(w);

        x /= length;
        y /= length;
        z /= length;


        r.m_Matrix[0][0] = (RtFloat)(x*x + cosw*(1.0 - x*x));
        r.m_Matrix[0][1] = (RtFloat)(x*y*(1.0 - cosw) + z*sinw);
        r.m_Matrix[0][2] = (RtFloat)(z*x*(1.0 - cosw) - y*sinw);
        r.m_Matrix[1][0] = (RtFloat)(x*y*(1.0 - cosw) - z*sinw);
        r.m_Matrix[1][1] = (RtFloat)(y*y + cosw*(1.0 - y*y));
        r.m_Matrix[1][2] = (RtFloat)(y*z*(1.0 - cosw) + x*sinw);
        r.m_Matrix[2][0] = (RtFloat)(z*x*(1.0 - cosw) + y*sinw);
        r.m_Matrix[2][1] = (RtFloat)(y*z*(1.0 - cosw) - x*sinw);
        r.m_Matrix[2][2] = (RtFloat)(z*z + cosw*(1.0 - z*z));
        concatTransform(r.m_Matrix);
}
Example #3
0
void Window::keyboard( unsigned char key, int x, int y ) {
    switch( key ) {
        case '1': setUpOrtho(); break;
		case '2': setUpFrustrum(); break;
		//rotations 
		case 'x': rotateX(ANGLEINC); break;
        case 'y': rotateY(ANGLEINC); break;
        case 'z': rotateZ(ANGLEINC); break;  
        case 'X': rotateX(-ANGLEINC); break;
		case 'Y': rotateY(-ANGLEINC); break;
		case 'Z': rotateZ(-ANGLEINC); break;
		case 'r': case 'R': //Press R to reload a shader
			shader->updateShader(); 
			break;
		case 'a': case 'A': //Press a to move left
			moveLeft(); 
			break;
		case 'd': case 'D': //Press d to move right
			moveRight(); 
			break;
		case 'w': case 'W': //Press w to move up
			moveUp(); 
			break;
		case 's': case 'S': //Press s to move down
			moveDown(); 
			break;
		case '+': changeAmbience(AMB_INC); break;
        case '=': changeAmbience(-AMB_INC); break;
		case 033:  // Escape key
        case 'q': case 'Q':
            exit( 0 ); 
			break;
    } 
    glutPostRedisplay();
}
Example #4
0
/* functie care roteste intreg cubul rubik in orice directie */
void Rubik::rotate_all (int direction, float speed) {
	
	for (int i = 0; i < rubik.size(); i++) {
		switch (direction) 
		{
			case LEFT:
				rotateY(i, cs->axiscenter, speed);
				break;

			case RIGHT:	
				rotateY(i, cs->axiscenter, -speed);
				break;

			case UP:
				rotateZ(i, cs->axiscenter, speed);
				break;

			case DOWN:
				rotateZ(i, cs->axiscenter, -speed);
				break;

			case BOTTOM:
				rotateX(i, cs->axiscenter, speed);
				break;

			case TOP:
				rotateX(i, cs->axiscenter, -speed);
				break;
		}	
	}
}
Example #5
0
void robot_clone_wars(int t)
{
#define SPACE_FLOOR 1
#define FINAL_WALK_ON 1
#define LINES 6
#define SPACING 16384
	int i, j;

	//rotateX(2560);
	if ( (t & 1) == 0 ) { // different camera for different screens
		translate(5120, 44032, 20480);
		rotateZ(1792);
	} else {
		rotateX(2560);
	}

#if SPACE_FLOOR
	push();
	translate(0, -6144, -4096*4);
	rotateX(-12867/2);
	scale(4096*16, 4096*10, 4096*10);
	spot(RGB15(0, 7, 3), RGB15(0, 2, 1), 0, -64);
	pop();
#endif

#if SPACE_FLOOR
	int z = t*256-16384;
#else
	int z = t*256*8-16384*8;
#endif
	if ( z > 0 )
		z = 0;

	int lines = (t-192+8)/8;

	if ( lines < 2 )
		lines = 2;
	else if ( lines > LINES )
		lines = LINES;

	for ( i = 1 ; i < lines ; i++ ) {
		translate(0, 0, -8192);
		for ( j = 0 ; j < i ; j++ ) {
			if ( j == 2 && i == 5 )
				continue;
			push();
				translate(j * SPACING - ((i-1)*SPACING)/2, jump(t-i*4)+z, 0);
#if FINAL_WALK_ON
				if ( t < 512 )
					robot(8, 256);
				else
					robot(8+t-512, 256);
#else
				robot(8);
#endif
			pop();
		}
	}
}
Example #6
0
bool BoundingBoxes::boxesAreWithin(shared_ptr<BoundingBoxes> otherBoxes) {
    bool collides = false;

    glm::mat4 rotationMatrix =
        rotateZ(otherBoxes->rotation.z) * rotateX(otherBoxes->rotation.x) * rotateY(otherBoxes->rotation.y);

    for (vector<vector<float> >::iterator vertex = otherBoxes->vertices.begin();
            vertex != otherBoxes->vertices.end(); ++vertex) {

        glm::vec4 otherCoords(vertex->at(0), vertex->at(1), vertex->at(2), 1.0f);
        glm::vec4 rotatedOtherCoords(0.0f, 0.0f, 0.0f, 1.0f);

        rotatedOtherCoords = rotationMatrix * otherCoords;

        rotatedOtherCoords.x += otherBoxes->offset.x;
        rotatedOtherCoords.y += otherBoxes->offset.y;
        rotatedOtherCoords.z += otherBoxes->offset.z;

        /*cout << "Checking " << rotatedOtherCoords.x << ", " << rotatedOtherCoords.y << ", " << rotatedOtherCoords.z <<
        " with " << boxesX << ", " << boxesY << ", " << boxesZ << " rotation " << boxesRotation << endl;*/
        if (pointIsWithin(rotatedOtherCoords.x, rotatedOtherCoords.y, rotatedOtherCoords.z)) {

            collides = true;
            break;
        }
    }

    return collides;
}
void Transform3d::rotateXRelativeToAnotherPoint (Point3d *pct, Point3d *ref, float angleInRadians) {
	translate (pct, -ref->x, -ref->y, -ref->z);

	rotateX(pct, angleInRadians);

	translate (pct, ref->x, ref->y, ref->z);
}
Example #8
0
void Door::open(){
	state = OPEN;
	ignoreCollision = true;
	printf("OPEN");
	rotateX(angleX + (3.14 / 2));

}
Example #9
0
void SWQtCamera::rotate(cfloat fX, cfloat fY, cfloat fZ, cfloat fAmount)
{
    QVector3D l_v(fX, fY, fZ);
    rotateX(fY/l_v.length() * fAmount);
    rotateY(fX/l_v.length() * fAmount);
    rotateZ(fZ/l_v.length() * fAmount);
}
Example #10
0
 void Matrix4x4<T>::smartMove(T inRX, T inRY, T inRZ, T inTX, T inTY, T inTZ)
 {
     translate(inTX, inTY, inTZ);
     rotateY(inRY);
     rotateX(inRX);
     rotateZ(inRZ);
 }
Example #11
0
void drawPlanet()
{   
	glUseProgram(planetShader);
	setupLighting(planetShader);
	vec3 Position = getCameraPosition();
	v = getViewMatrix();
		
	for(int i = 0; i < 11; i++)
	{	
		mat4 rotation = multiplymat4(rotateY(rotationSpeedArray[i]), rotateX(planetInstanceArray[i].axialTilt+45));
		mat4 translation = multiplymat4(translate(planetInstanceArray[i].radius*1000, 0.0, 0.0), rotation);
		mat4 b = translate(0.0, 0.0, -400.0);
		mat4 roty = rotateY(orbitSpeedArray[i]);
		mat4 rotxy = multiplymat4(b, roty);
		mat4 c = multiplymat4(rotxy, translation);
		m = multiplymat4(c, scale(planetInstanceArray[i].size*100));
		planetInstanceArray[i].planetLocation = m;
    	
		//mv = modelMatrices[i];
		initMVP(planetShader, m, v);
		glUniform3f(glGetUniformLocation(planetShader, "cameraPos"), Position.x, Position.y, Position.z);
    
    	glBindVertexArray (planetVAO);
    	bindTexture(GL_TEXTURE0, planetInstanceArray[i].texture);
    	bindTexture(GL_TEXTURE1, planetInstanceArray[i].normal);
    	glUniform1i(glGetUniformLocation(planetShader, "tex"), 0);
    	glUniform1i(glGetUniformLocation(planetShader, "normalTex"), 1);
    	glDrawArrays( GL_TRIANGLES, 0, planet.vertexNumber);
    	glBindVertexArray(0);
    }
}
Example #12
0
mat4& GDAnim::GetJoint(GDAnim** anims, float* weights, uint numAnims, uint jointID, float time)
{
	GDAnim* anim = anims[0];
		
	time = fmod(time, anim->animLength);

	vec3 vscale;
	vec3 rot;
	vec3 trans;
	
	vscale[0] = getAnimValue(anim->scaleKeys, anim->jointTimelines[jointID].s[0], time);
	vscale[1] = getAnimValue(anim->scaleKeys, anim->jointTimelines[jointID].s[1], time);
	vscale[2] = getAnimValue(anim->scaleKeys, anim->jointTimelines[jointID].s[2], time);
	
	rot[0] = getAnimValue(anim->rotKeys, anim->jointTimelines[jointID].r[0], time);
	rot[1] = getAnimValue(anim->rotKeys, anim->jointTimelines[jointID].r[1], time);
	rot[2] = getAnimValue(anim->rotKeys, anim->jointTimelines[jointID].r[2], time);
	
	trans[0] = getAnimValue(anim->transKeys, anim->jointTimelines[jointID].t[0], time);
	trans[1] = getAnimValue(anim->transKeys, anim->jointTimelines[jointID].t[1], time);
	trans[2] = getAnimValue(anim->transKeys, anim->jointTimelines[jointID].t[2], time);

	// TODO: Super slow! Fix this! Use SQT's probably
	mat4 t, rx, ry, rz, s;
	t = translate(trans);
	rx = rotateX(rot.x/360.f*2*PI);
	ry = rotateY(rot.y/360.f*2*PI);
	rz = rotateZ(rot.z/360.f*2*PI);
	s = scale(vscale.x, vscale.y, vscale.z);

	return t*rz*ry*rx;
}
Example #13
0
bool equals() {
	int i, j;
	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			if (strcmp(cubeA, cubeB) == 0)
				return true;
			rotateZ();
		}
		rotateX();
	}
	rotateY();
	for (j = 0; j < 4; j++) {
		if (strcmp(cubeA, cubeB) == 0)
			return true;
		rotateZ();
	}
	rotateY();
	rotateY();
	for (j = 0; j < 4; j++) {
		if (strcmp(cubeA, cubeB) == 0)
			return true;
		rotateZ();
	}
	return false;
}
void Jet::calcDir(){
	yaw = forward.angleFromZinXZ('r');
	Vector3d tempfor = rotateY(yaw).multiply(forward);
	pitch = tempfor.angleFromZinYZ('r');
	Vector3d tempup = rotateX(pitch).multiply(rotateY(yaw).multiply(up));
	roll = tempup.angleFromYinXY('r');
}
Example #15
0
int Viewfinder::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: processFrames((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: processFrame(); break;
        case 2: toggleCube(); break;
        case 3: toggleGourd(); break;
        case 4: paintCube(); break;
        case 5: paintGourd(); break;
        case 6: changeX(); break;
        case 7: changeY(); break;
        case 8: changeZ(); break;
        case 9: rotateX(); break;
        case 10: rotateY(); break;
        case 11: rotateZ(); break;
        case 12: plus(); break;
        case 13: minus(); break;
        case 14: openDirectory(); break;
        default: ;
        }
        _id -= 15;
    }
    return _id;
}
void AIController::run(int frameRate) {
    Controller::run(frameRate);
    coord[pos][0] = shipCoord().getX();
    coord[pos][1] = shipCoord().getY();
    pos++;
    it++;
    pos %= LOG_SIZE;
    if (it >= 5) {
        if (coord[pos][0] < coord[(pos + 1) % LOG_SIZE][0] && shipCoord().getX() < 0 && shipCoord().getZ() < 0 &&
            !rotated) {
//            std::cout << "*";
            if (getYaw() <= MAX_ROTATE_POWER) {
                plusYaw();
            }
        } else {
            rotateX();
            moveX();
            rotateY();
            moveY();
            moveForward();
            shoot();
        }
    }
//    std::cout << "coord: " << shipCoord().getX() << " " << shipCoord().getY() << " " << shipCoord().getZ() << " ";
//    std::cout << "speed: " << radar->targetSpeed().getX() << " " << radar->targetSpeed().getY() << " " <<
//    radar->targetSpeed().getZ() << " ";
//    std::cout << "angular: " << m_object->angularVelocity().getX() << " " << m_object->angularVelocity().getY() << " ";
//    std::cout << "thrust: " << thrust << " " << thrustY << " ";
//    std::cout << "power: " << power << " ";
//    std::cout << "premtion: " << preemption().getX() << " " << preemption().getY() << " " << preemption().getZ() << " ";
//    std::cout << "\n";
    m_object->run(frameRate);
}
Example #17
0
mat4 rotationSpace()
{
	vec2 rotation = getCameraRotation();
    mat4 rx = rotateX(rotation.y);
	mat4 ry = rotateY(rotation.x);
	mat4 rxry = multiplymat4(rx, ry);
	return rxry;
}
mat4 animate_camera(float t)
{
    float rx = -0.3f + 0.25f * sin(t * 0.1f);
    float ry = t * 0.4f;
    float zoom = 0.5f + 0.5f * sin(t * 0.25f);
    float z = -5.0f + 3.0f * sin(t * 0.25f);
    return translate(0.6f, -0.4f, z) * rotateX(rx) * rotateY(0.1f * t);
}
Example #19
0
void CTransformation::rotate(float ang, CPoint vectorEje, CPoint enRecta )
//Acumula el giro alrededor de un eje generico
{
	// enRecta es un punto que está en el eje de rotacion
	float lat= vectorEje.latitude();		//latitude
	float lon= vectorEje.longitude();		//longitude

	// Me llevo el sistema de coordenadas al punto que quiero girar
	traslate(enRecta);
	// Lo giro para que esté como el eje vectorEje
	rotateY(lon);
	rotateX(-lat);
	rotateZ(ang);
	// ahora a volver al sitio original
	rotateX(lat);
	rotateY(-lon);
	traslate(enRecta.negate());
};
Example #20
0
void		rotate3D(t_mat3 *m, t_vec3 deg)
{
  if (deg.z != 0.0)
    rotateZ(m, deg.z);
  if (deg.y != 0.0)
    rotateY(m, deg.y);
  if (deg.x != 0.0)
    rotateX(m, deg.x);
}
Example #21
0
void Camera::input()
{
	float sensitivity = 0.5f;
	float movAmt = (float)(10 * Time::getDelta());
	float rotAmt = (float)(100 * Time::getDelta());

	if (Input::getKey(KEY::KEY_ESCAPE))
	{
		Input::setCursor(true);
		mouseLocked = false;
	}

	if (mouseLocked)
	{
		Vector2f centerPosition = Vector2f((float)Window::getWidth() / 2.0f, (float)Window::getHeight() / 2.0f);
		Vector2f deltaPos = Input::getMousePosition() - centerPosition;

		bool rotY = deltaPos.x != 0;
		bool rotX = deltaPos.y != 0;

		if (rotY)
			rotateY(deltaPos.x * sensitivity);
		if (rotX)
			rotateX(deltaPos.y * sensitivity);

		if (rotY || rotX)
			Input::setMousePosition(centerPosition);
	}

	if (Input::getMouseDown(MOUSE::LEFT_MOUSE))
	{
		Vector2f centerPosition = Vector2f((float)Window::getWidth() / 2.0f, (float)Window::getHeight() / 2.0f);
		Input::setMousePosition(centerPosition);
		Input::setCursor(false);
		mouseLocked = true;
	}

	if (Input::getKey(KEY::KEY_W))
		move(getForward(), movAmt);
	if (Input::getKey(KEY::KEY_S))
		move(getForward(), -movAmt);
	if (Input::getKey(KEY::KEY_A))
		move(getLeft(), movAmt);
	if (Input::getKey(KEY::KEY_D))
		move(getRight(), movAmt);


	//if(Input::getKey(KEY::KEY_UP))
	//	rotateX(-rotAmt);
	//if(Input::getKey(KEY::KEY_DOWN))
	//	rotateX(rotAmt);
	//if(Input::getKey(KEY::KEY_LEFT))
	//	rotateY(-rotAmt);
	//if(Input::getKey(KEY::KEY_RIGHT))
	//	rotateY(rotAmt);
}
Example #22
0
void Vector::rotate(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{
	if (x != 0.0f)
		rotateX(angle);

	if (y != 0.0f)
		rotateY(angle);

	if (z != 0.0f)
		rotateZ(angle);
}
Example #23
0
Matr4::Matr4(const Vect4& rotVect, const Vect4& transVect, const Vect4& scaleVect)
{
   memset(_elems, 0, sizeof(_elems));
   setTranslate(transVect);

   rotateX(rotVect[0]);
   rotateY(rotVect[1]);
   rotateZ(rotVect[2]);

   scale(scaleVect);
}
int main(){

allegro_init();
install_keyboard();
/*
install_sound (DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
MIDI *music;
music = load_midi("./99.midd");
if (!music)
    {std::cerr<<"Couldn't load background music!"<<std::endl;exit(1);}
else
	play_midi(music,1);
*/
set_gfx_mode( GFX_AUTODETECT, 1920, 1200, 0, 0);
buffer = create_bitmap( 1920, 1200); 

 while ( !key[KEY_ESC] ){
    
        clear_keybuf();
        

        
        if (key[KEY_UP]) rotateY(-2);        
        else if (key[KEY_DOWN]) rotateY(2);    
        else if (key[KEY_RIGHT]) rotateX(2);
        else if (key[KEY_LEFT]) rotateX(-2);
		else if (key[KEY_PGUP]) rotateZ(-2);
		else if (key[KEY_PGDN]) rotateZ(2);

        draw();

	}
	/*
	if(music)
	{
	stop_midi();
	destroy_midi(music);
	}
	*/
return 0;
}
Example #25
0
void SimCalcs::rotateAtom(int aIdx, int pivotIdx, Real rotX, Real rotY,
                          Real rotZ, Real** aCoords) {
  Real pX = aCoords[X_COORD][pivotIdx];
  Real pY = aCoords[Y_COORD][pivotIdx];
  Real pZ = aCoords[Z_COORD][pivotIdx];

  translateAtom(aIdx, -pX, -pY, -pZ, aCoords);
  rotateX(aIdx, rotX, aCoords);
  rotateY(aIdx, rotY, aCoords);
  rotateZ(aIdx, rotZ, aCoords);
  translateAtom(aIdx, pX, pY, pZ, aCoords);
}
Example #26
0
void QuatCamera::input(CameraDirection dir_) {
    GLfloat movAmt = 0.5f;
    GLfloat rotAmt = 1.5f;

    switch (dir_) {
    case FORWARD:
        move(forward, movAmt);
        break;
    case BACK:
        move(forward, -movAmt);
        break;
    case LEFT:
        move(getLeft(), -movAmt);
        break;
    case RIGHT:
        move(getRight(), -movAmt);
        break;
    case UP:
        move(up, movAmt);
        break;
    case DOWN:
        move(up, -movAmt);
        break;
    case TILTDOWN:
        rotateX(rotAmt);
        break;
    case TILTUP:
        rotateX(-rotAmt);
        break;
    case LOOKLEFT:
        rotateY(rotAmt);
        break;
    case LOOKRIGHT:
        rotateY(-rotAmt);
        break;
    default:
        break;
    }
}
void drawAnimation() {
  //Rotate the SphereNormals display in the x-axis.
  scale(0.35, 0.35, 0.35);
  rotateX(a);
  rotateZ(a);
  translate(0, 0, 4);
  drawSphereNormals();
  glLoadIdentity();

  //Rotate the WireCone drawing in the y-axis.
  scale(0.35, 0.35, 0.35);
  rotateY(b);
  rotateX(b);
  translate(4, 0, 0);
  drawWireCone();
  glLoadIdentity();

  //Rotate the WireSphere drawing the the z-axis.
  scale(0.35, 0.35, 0.35);
  rotateZ(c);
  rotateY(c);
  translate(0, 4, 0);
  drawWireSphere();
  glLoadIdentity();

  //Rotate the ShadedSphere drawing (on the spot) through the x-, y- and z- axis.
  scale(0.35, 0.35, 0.35);
  rotateY(d);
  drawShadedSphere();
  glLoadIdentity();

  //Reset the camera to orthographic.
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  glOrtho(-2, 2, -2, 2, 2, -2);
  glMatrixMode(GL_MODELVIEW);
}
Example #28
0
//Disegno il cannone
void Cannone::draw(void) {
	glPushMatrix();
		rotateX(xRot);
		rotateY(yRot);
		rotateZ(zRot);
		applyTransform();
		glColor3f(0.6, 0.6, 0.6);
		glutSolidSphere(0.35, 25, 43);
		switch (getCityPosition()) {
		case 0:
			glPushMatrix();
				glTranslatef(0, 0, -28);
				drawMirino();
			glPopMatrix();
			glTranslatef(0, 0, -0.6);
			glScalef(1, 1, 2.5);
			break;
		case 1:
			glPushMatrix();
				glTranslatef(28, 0, 0);
				glRotatef(90, 0, 1, 0);
				drawMirino();
			glPopMatrix();
			glTranslatef(0.6, 0, 0);
			glScalef(2.5, 1, 1);
			glRotatef(90, 0, 1, 0);
			break;
		case 2:
			glPushMatrix();
				glTranslatef(0, 0, 28);
				drawMirino();
			glPopMatrix();
			glTranslatef(0, 0, 0.6);
			glScalef(1, 1, 2.5);
			break;
		case 3:
			glPushMatrix();
				glTranslatef(-28, 0, 0);
				glRotatef(90, 0, 1, 0);
				drawMirino();
			glPopMatrix();
			glTranslatef(-0.6, 0, 0);
			glScalef(2.5, 1, 1);
			glRotatef(90, 0, 1, 0);
			break;
		}
		glutSolidTorus(0.25, 0.30, 25, 43);
	glPopMatrix();
}
Example #29
0
void draw_scene(App *app)
{
    int n = 5;
    for (int zi = 0; zi <= n; zi++)
    for (int xi = 0; xi <= n; xi++)
    {
        float x = Centimeter(-100.0f) + 2.0f * Centimeter(100.0f * xi / n);
        float z = Centimeter(-100.0f * zi);
        int i = zi * n + xi;
        mat4 mat_model = translate(x, 0.0f, z) *
                         scale(Centimeter(5.0f)) *
                         rotateY(0.3f * app->elapsed_time + i * 1.57f) *
                         rotateX(0.2f * app->elapsed_time + i * 3.2f);
        uniformm4(cube, model, mat_model);
        GL_CHECK(glDrawArrays(GL_TRIANGLES, 0, 36));
    }

    mat4 mat_model = translate(0.0f, Centimeter(70.0f), Centimeter(400.0f)) *
                     scale(Centimeter(5.0f)) *
                     rotateY(0.3f * app->elapsed_time) *
                     rotateX(0.05f * app->elapsed_time);
    uniformm4(cube, model, mat_model);
    GL_CHECK(glDrawArrays(GL_TRIANGLES, 0, 36));
}
int MyGLWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QGLWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: rotateX((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: rotateY((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 2: rotateZ((*reinterpret_cast< int(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 3;
    }
    return _id;
}