void aftertranslate(int dummy)
{
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_LINE_LOOP);
    glVertex2d(nx[0],ny[0]);
    glVertex2d(nx[1],ny[1]);
    glVertex2d(nx[2],ny[2]);
    glVertex2d(nx[3],ny[3]);
    glEnd();
    glBegin(GL_LINE_LOOP);
    glVertex2d(nx[4],ny[4]);
    glVertex2d(nx[5],ny[5]);
    glVertex2d(nx[6],ny[6]);
    glVertex2d(nx[7],ny[7]);
    glEnd();
    glBegin(GL_LINES);
    glVertex2d(nx[8],ny[8]);
    glVertex2d(nx[9],ny[9]);
    glVertex2d(nx[10],ny[10]);
    glVertex2d(nx[11],ny[11]);
    glEnd();
    glBegin(GL_POINTS);
    myCircle(nx[12],ny[12],25);
    myCircle(nx[13],ny[13],25);
    glEnd();
    glFlush();
    translate(nx,ny);
    glutTimerFunc(1000,aftertranslate,1);
}
예제 #2
0
//-----------------------------------------------------------------------------
//! 更新(プレイヤーの周りに常にいる)
//!	@param	[in]	player	プレイヤー座標
//-----------------------------------------------------------------------------
void AllyHealer::UpdateNormal(Vector3& playerPos)
{
	// プレイヤーへのベクトル
	Vector3	dir	   = playerPos - _position;
	// 長さ取得
	f32		length = dir.length();

	Circle	goalCircle(playerPos, 100.0f);
	Circle	myCircle(_position, _radius);

	// プレイヤーの近くにいるかどうか
	if( goalCircle.isHit(myCircle) ){
		// 近くにいる
		_speed = 0.0f;
		_keyUpdate = true;
	}else{
		// 近くにいない
		_speed = 3.0f;
		dir = dir.normalize();
		_rotation._y = atan2f(dir._x, dir._z);
		_keyUpdate = false;
	}



}
예제 #3
0
파일: MainCode.cpp 프로젝트: Carraca/LAIG1
void myCylinderTexture(double radius, double height, int slices, int bases, int texture)
{
	double d_angle = 2*pi/slices;
	double sin_d_angle=sin(d_angle);
	double cos_d_angle=cos(d_angle);
	double d_angle_degrees = d_angle*180/pi;
	double angle = 0;
	double px,py;
	px=radius*cos(d_angle); 
	py=radius*sin(d_angle);
	double t_texture_inc= 1.0/((double) slices);
	int i;

	glEnable(GL_TEXTURE_2D);
	for(i=0;i<slices;++i){

		glPushMatrix();
		glRotated(angle,0.0,0.0,1); 
		glBindTexture(GL_TEXTURE_2D, texture);
		glBegin(GL_POLYGON);
			glNormal3d(1,0.0,0.0);
			glTexCoord2f(1.0,-i*t_texture_inc);glVertex3d( radius,  0.0,  0.0);
			glNormal3d(cos_d_angle,sin_d_angle,0.0);
			glTexCoord2f(1.0,-(i+1)*t_texture_inc);glVertex3d( px,py  ,  0.0);
			glTexCoord2f(0.0,-(i+1)*t_texture_inc);glVertex3d( px,py ,  height);
			glNormal3d(1,0.0,0.0);
			glTexCoord2f(0.0,-i*t_texture_inc);glVertex3d( radius,0 ,  height);
		glEnd();
		glPopMatrix();

		angle+=d_angle_degrees;
	}
	glDisable(GL_TEXTURE_2D);

	if(bases){
		glPushMatrix();
		glTranslated(0,0,height);
		myCircle(radius,slices,1.0);
		glPopMatrix();

		myCircle(radius,slices,-1.0);
	}
}
예제 #4
0
//-----------------------------------------------------------------------------
//! リーダーの周りに常にいる
	//!	@param	[in]	leader	リーダー座標
//-----------------------------------------------------------------------------
void EnemyLeader::UpdateNormal(Vector3& leaderPos)
{
	Vector3 dir = leaderPos - _position;
	// 長さ取得
	f32		length = dir.length();
	Circle	goalCircle(leaderPos, 500.0f);
	Circle	myCircle(_position, _radius);

	if( goalCircle.isHit(myCircle) ){
		_goGoal = false;
		_speed = 0.0f;
	}else{
		Status::Param* myParam = _myStatus->getParam();
		_speed = myParam->_speedMAX;
		dir = dir.normalize();
		_rotation._y = atan2f(dir._x, dir._z);
		_goGoal = true;
	}
}
예제 #5
0
파일: Obj.cpp 프로젝트: almgwary/Graphic
void Obj::Draw(HDC hdc)
{
     if(shape == 1)              //  Line Algorithms 
     {
              l = myLine(p1,p2,algorithm);
              l.color = color;
              l.drawLine(hdc);
     }
     else if(shape == 2)       //  Circle Algorithms 
     {
          int dx = p1.x-p2.x;
          int dy = p1.y-p2.y;
          int r = (int)sqrt(dx*dx + dy*dy);
          c = myCircle(p1,r,algorithm);
          c.color = color;
          c.drawCircle(hdc);
     }
        else if(shape == 3)    //  Curve Algorithms 
     {
          curve.color = color;
          curve.Points[0] = p1;
          curve.Points[1] = p2;
          curve.Points[2] = myPoint(x3,y3);
          curve.Points[3] = myPoint(x4,y4);
          if(algorithm == 1)
                 curve.DrawHermiteCurve(hdc,p1.x,p1.y,p2.x,p2.y,x3,y3,x4,y4,100);
          if(algorithm == 2)
                 curve.DrawBezierCurve(hdc,curve.Points[0],curve.Points[1],curve.Points[2],curve.Points[3],100);
          if(algorithm == 3)
                 curve.DrawCardinalSpline(hdc,curve.Points,4,0.01,100);
     }
     else if(shape == 4)      //  Clipping Algorithms 
     {
          if(algorithm == 1)
                       clip.PointClipping(hdc,p1.x,p1.y,left,top,right,bottom,color);
          if(algorithm == 2)
                       clip.LineClipping(hdc,p1.x,p1.y,p2.x,p2.y,left,top,right,bottom);
          if(algorithm == 3)
                      {clip.PolygonClipping(hdc,Points,n,left,top,right,bottom);}
     }
}
예제 #6
0
파일: testing.cpp 프로젝트: zwyber/pie
void test_10(){
    ////Test most basic Texturing
    int universeWidth = 720;
    int universeHeight = 480;

    int AmountOfObjects = 3;

    double pixRatio = 50;

    glfwWindowHint(GLFW_SAMPLES, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);

    Universe universe(universeWidth/pixRatio, universeHeight/pixRatio);
    Window window = Window(&universe, pixRatio);

    addRandomObjects(universe,1,AmountOfObjects);
    glClearColor(0.2, 0.2, 0.3, 1.0);


    GLuint Texture = loadDDS("Asteroid.DDS");

    TextureShader myShader(Texture);
    GLuint programID = myShader.programID;
    // Get a handle for our "MVP" uniform
    glm::vec4 colour = {1.0f, 0.0f,0.0f,1.0f};
    CircleShader myCircle(colour);
    //myCircle.colour=colour;
    double size;
    double step = 0.001;
    double phi = 0.003;
    const GLfloat c = cos(phi);
    const GLfloat s = sin(phi);
    glm::mat3 rot = {
            c, -s, 0,
            s,  c, 0,
            0,  0, 1
    };
    do{
        size = cos(step+=0.01);
        myCircle.tMatrixReset();
        myCircle.tMatrixTranslate({size,0.0});
        myCircle.tMatrixScale({size,size});

        myShader.transformationMatrix *= rot;
        // Clear the screen
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        myShader.draw();
        myCircle.draw();
        // Swap buffers
        glfwSwapBuffers(window.GLFWpointer);
        glfwPollEvents();

    } // Check if the ESC key was pressed or the window was closed
    while( glfwGetKey(window.GLFWpointer, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
           glfwWindowShouldClose(window.GLFWpointer) == 0 );


    // Close OpenGL window and terminate GLFW
    glfwTerminate();
}
예제 #7
0
//-- This program is a simple demonstration of primitive shapes using the SFML library --//
//-- Software Created by MossFrog --//
int main()
{
	//-- We create the render window --//
	sf::RenderWindow window(sf::VideoMode(800, 600), "Shapes test", sf::Style::Close);
	window.setFramerateLimit(60);

	//-- Define our shapes and initialize their positions --//

	//-- The variable is defined with its diameter --//
	sf::CircleShape myCircle(35);
	myCircle.setFillColor(sf::Color::Blue);
	myCircle.setPosition(400,400);
	//-- We can give it an outline and set its color --//
	myCircle.setOutlineThickness(10);
	myCircle.setOutlineColor(sf::Color::Red);

	//-- Define and initialize the rectangle --//
	sf::RectangleShape myRect;
	myRect.setPosition(50,50);
	myRect.setSize(sf::Vector2f(100, 100));
	myRect.setFillColor(sf::Color::Cyan);

	//-- Circle shapes can have any number of "edges" --//
	sf::CircleShape myTriangle(45,3);
	myTriangle.setFillColor(sf::Color::White);
	myTriangle.setPosition(700,150);


	sf::CircleShape myOctagon(25,8);
	myOctagon.setFillColor(sf::Color::Magenta);
	myOctagon.setPosition(700,500);

	//-- Main game loop --//
    while (window.isOpen())
    {

		//-- The code below checks for user bound events such as keyboard, UI, mouse and joystick events --//
        sf::Event event;

        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

		sf::Vector2i mouse = sf::Mouse::getPosition(window);
		

		//-- This code hides the console window, MS-WINDOWS specific --//
		HWND hWnd = GetConsoleWindow();
		ShowWindow( hWnd, SW_HIDE ); 
		

		//-- Clear and draw methods --//

		window.clear(sf::Color::Black);
	
		//-- We do all the drawing after the clear event, if not any drawing we do will not be visible --//
		window.draw(myCircle);
		window.draw(myRect);
		window.draw(myOctagon);
		window.draw(myTriangle);

		window.display();
		
	}

    return 0;
}
예제 #8
0
TEST(CircleTests, RadiusTest) {
    Circle myCircle(3);
    EXPECT_EQ(3,myCircle.getRadius());
    myCircle.setRadius(4);
    EXPECT_EQ(4, myCircle.getRadius());
}
예제 #9
0
TEST(CircleTests, CircumferenceTest) {
    Circle myCircle(3);
    EXPECT_EQ(6*M_PI,myCircle.getCircumference());
}
예제 #10
0
TEST(CircleTests, AreaTest) {
    Circle myCircle(3);
    EXPECT_EQ(9*M_PI,myCircle.getArea());
}