Ejemplo n.º 1
0
bool Intersects(const Shape1& a, const Shape2& b)
{
	for (const Vector3f& ax : Axes(a))
		if (!Intersects(Project(a, ax), Project(b, ax)))
			return false;
	for (const Vector3f& ax : Axes(b))
		if (!Intersects(Project(a, ax), Project(b, ax)))
			return false;
	return true;
}
Ejemplo n.º 2
0
Archivo: proj3.cpp Proyecto: guwu/cs553
void
InitLists( )
{
	PointList = glGenLists(1);
	glNewList(PointList, GL_COMPILE);
	glPointSize(PointSize);	// hardwire this, or set it with a spinner
	glBegin(GL_POINTS);
	for (int i = 0; i < NX; i++)
	{
		for (int j = 0; j < NY; j++)
		{
			for (int k = 0; k < NZ; k++)
			{
				glColor3f( Nodes[i][j][k].rgb[0],
						   Nodes[i][j][k].rgb[1], 
						   Nodes[i][j][k].rgb[2] );
				glVertex3f( Nodes[i][j][k].x,
							Nodes[i][j][k].y,
							Nodes[i][j][k].z );
			}
		}
	}
	glEnd();
	glEndList();


	// create the axes:

	AxesList = glGenLists( 1 );
	glNewList( AxesList, GL_COMPILE );
		glLineWidth( AXES_WIDTH );
			Axes( 1.5 );
		glLineWidth( 1. );
	glEndList( );
}
Ejemplo n.º 3
0
/// main draw method
void display() {
    hud_fps_display.start();
    if(draw_opts.cameralights) scene_cameralights_update(scene,draw_opts.cameralights_dir,draw_opts.cameralights_col);
    draw_scene(scene,draw_opts,true);
    draw_scene_decorations(scene,draw_opts,false);
    glFlush();
    hud_fps_display.stop();
    
    if(selected_frame) {
        auto axes = Axes();
        axes.frame = *selected_frame;
        draw_gizmo(&axes);
        if(selected_point) {
            auto dot = Dot();
            dot.pos = transform_point(*selected_frame, *selected_point);
            draw_gizmo(&dot);
        }
    }
    
    if(hud) display_hud();
    
    glutSwapBuffers();
    
    if(screenshotAndExit) {
        if(time_init_advance <= 0.0f or draw_opts.time >= time_init_advance ) {
            screenshot(filename_image.c_str());
            exit(0);
        }
    }
}
Ejemplo n.º 4
0
void
PutPsFile()
{
    Prologue();
    Variables();
    BorderOutlineBox();

    if (bflag) {
	BigTitleOutlineBox();
        BigTitleText();
    } else {
	TitleOutlineBox();
	TitleText();
    }

    CurvesInit();

    Axes();

    if (TWENTY) Key();

    Curves();

    if (!yflag) Marks();

    fprintf(psfp, "showpage\n");
}
Ejemplo n.º 5
0
void
PutPsFile(void)
{
    Prologue();
    Variables();

    CurvesInit();

    DoTitleAndBox();

    if (multipageflag) {
      Key(); // print multi-page key even if there are more than 20 bands 
      NextPage();
    }

    Axes();

    if (!multipageflag && (TWENTY != 0)) Key();

    Curves();

    if (!yflag) Marks();

    fprintf(psfp, "showpage\n");
}
Ejemplo n.º 6
0
void R3CoordSystem::
Draw(void) const
{
    // Draw three rays
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_X)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_Y)));
    R3EndLine();
    R3BeginLine();
    R3LoadPoint(Origin());
    R3LoadPoint((Origin() + Axes().Axis(RN_Z)));
    R3EndLine();
}
Ejemplo n.º 7
0
Axes axesFromAxisZ(const Vector& z)
{
    int i = maxDim(z);
    Vector u = (i == 0) ? UnitVectorY : (i == 1) ? UnitVectorZ : UnitVectorX;
	Vector x = unit(cross(u, z));
	Vector y = unit(cross(z, x));
    return Axes(x, y, z);
}
Ejemplo n.º 8
0
Matrix cast(const btTransform& t){
	return Matrix(
		Axes(
			cast(t.getBasis().getColumn(0)),
			cast(t.getBasis().getColumn(1)),
			cast(t.getBasis().getColumn(2))),
		cast(t.getOrigin()));
}
Ejemplo n.º 9
0
 void InitLists( void )
 {
     AxesList = glGenLists( 1 );
     glNewList( AxesList, GL_COMPILE );
     glColor3fv( AXES_COLOR );
     glLineWidth( AXES_WIDTH );
     Axes( 1.5 );
     glLineWidth( 1. );
     glEndList();
 }
Ejemplo n.º 10
0
void AxisCiterion::read(const QJsonObject &json)
{
    mName=Axes(qRound(json["name"].toDouble()));
    mx=json["x"].toDouble();
    my=json["y"].toDouble();
    mz=json["z"].toDouble();
    double norm=sqrt(mx*mx+my*my+mz*mz);
    mx=mx/norm;
    my=my/norm;
    mz=mz/norm;
}
Ejemplo n.º 11
0
Archivo: proj7.cpp Proyecto: guwu/cs553
void
InitLists( )
{


	// create the axes:

	AxesList = glGenLists( 1 );
	glNewList( AxesList, GL_COMPILE );
		glLineWidth( AXES_WIDTH );
			Axes( 1.5 );
		glLineWidth( 1. );
	glEndList( );
}
Ejemplo n.º 12
0
void RenderScene(void)
{


    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
	gluLookAt(viewer[0],viewer[1],viewer[2], 0.0, 0.0, 0.0, 0.0, p, 0.0);
    Axes();
	if(status == 1)                    // je?li lewy klawisz myszy wci?ni?ty
	{
	   thetax += delta_x * pix2angle / 30.0;
	   thetay += delta_y * pix2angle / 30.0;
	   
	}  else if(status ==2){
		theta_zoom += delta_zoom/10.0;
		
	}
	std::cout << thetax << " " << thetay << "\n";

	if(thetay > 3.1415) thetay -= 2*3.1415;
        else if(thetay <= -3.1415) thetay += 2*3.1415;


	if(thetay > 3.1415/2 || thetay < -3.1415/2){
		p = -1.0;
		
	} else{
		p = 1.0;
		
	}
	

	viewer[0] = theta_zoom*cos(thetax)*cos(thetay);
	viewer[1] = theta_zoom*sin(thetay);
	viewer[2] = theta_zoom*sin(thetax)*cos(thetay);

	

	if(model == 1)
		EggsPoints();
	else if(model == 2)
		EggsMesh();
	else
		EggsTriangles();
	
	glFlush();
    glutSwapBuffers();
}
Ejemplo n.º 13
0
void BipartiteBoxPruningTest::PerformTest()
{
	UpdateBoxes();

	// We pretend that half the boxes belong to first group, and the other half to the second group.
	udword Nb0 = mNbBoxes/2;
	udword Nb1 = mNbBoxes - Nb0;

	mPairs.ResetPairs();
	mProfiler.Start();
	BipartiteBoxPruning(Nb0, mBoxPtrs, Nb1, mBoxPtrs+Nb0, mPairs, Axes(AXES_XZY));
	mProfiler.End();
	mProfiler.Accum();

//	printf("%d pairs colliding\r     ", mPairs.GetNbPairs());

	bool* Flags = (bool*)_alloca(sizeof(bool)*mNbBoxes);
	ZeroMemory(Flags, sizeof(bool)*mNbBoxes);
	const Pair* P = mPairs.GetPairs();
	for(udword i=0;i<mPairs.GetNbPairs();i++)
	{
		// A colliding pair is (i,j) where 0 <= i < Nb0 and 0 <= j < Nb1
		Flags[P[i].id0] = true;
		Flags[P[i].id1+Nb0] = true;
	}

	// Render boxes
	OBB CurrentBox;
	CurrentBox.mRot.Identity();
	for(udword i=0;i<mNbBoxes;i++)
	{
		if(Flags[i])	glColor3f(1.0f, 0.0f, 0.0f);
		else
		{
			if(i<Nb0)
				glColor3f(0.0f, 1.0f, 0.0f);
			else
				glColor3f(0.0f, 0.0f, 1.0f);
		}
		mBoxes[i].GetCenter(CurrentBox.mCenter);
		mBoxes[i].GetExtents(CurrentBox.mExtents);
		DrawOBB(CurrentBox);
	}

	char Buffer[4096];
	sprintf(Buffer, "BipartiteBoxPruning - %5.1f us (%d cycles) - %d pairs\n", mProfiler.mMsTime, mProfiler.mCycles, mPairs.GetNbPairs());
	GLFontRenderer::print(10.0f, 10.0f, 0.02f, Buffer);
}
Ejemplo n.º 14
0
void CompleteBoxPruningTest::PerformTest()
{
    int numBoxes = (mNbBoxes*percentUpdate)/100;
    if (m_firstTime)
    {
        numBoxes = mNbBoxes;
        m_firstTime = false;
    }

    mProfiler.Start();
    UpdateBoxes(numBoxes);

    mPairs.ResetPairs();



    CompleteBoxPruning(mNbBoxes, mBoxPtrs, mPairs, Axes(AXES_XZY));
    mProfiler.End();
    mProfiler.Accum();

//	printf("%d pairs colliding\r     ", mPairs.GetNbPairs());

    bool* Flags = (bool*)_alloca(sizeof(bool)*mNbBoxes);
    ZeroMemory(Flags, sizeof(bool)*mNbBoxes);
    const Pair* P = mPairs.GetPairs();
    for(udword i=0; i<mPairs.GetNbPairs(); i++)
    {
        Flags[P[i].id0] = true;
        Flags[P[i].id1] = true;
    }

    // Render boxes
    OBB CurrentBox;
    CurrentBox.mRot.Identity();
    for(udword i=0; i<mNbBoxes; i++)
    {
        if(Flags[i])	glColor3f(1.0f, 0.0f, 0.0f);
        else			glColor3f(0.0f, 1.0f, 0.0f);
        mBoxes[i].GetCenter(CurrentBox.mCenter);
        mBoxes[i].GetExtents(CurrentBox.mExtents);
        DrawOBB(CurrentBox);
    }

    char Buffer[4096];
    sprintf(Buffer, "CompleteBoxPruning:  %5.1f us (%d cycles) : %d pairs\n", mProfiler.mMsTime, mProfiler.mCycles, mPairs.GetNbPairs());
    GLFontRenderer::print(10.0f, 10.0f, 0.02f, Buffer);
}
Ejemplo n.º 15
0
void RenderScene(void)
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    Axes();
	glRotatef(theta[0], 1.0, 0.0, 0.0);
	glRotatef(theta[1], 0.0, 1.0, 0.0);
	glRotatef(theta[2], 0.0, 0.0, 1.0);
	if(model == 1)
		EggsPoints();
	else if(model == 2)
		EggsMesh();
	else
		EggsTriangles();
	
	glFlush();
    glutSwapBuffers();
}
Ejemplo n.º 16
0
void
InitLists( )
{
	SphereList = glGenLists( 1 );
	glNewList( SphereList, GL_COMPILE );
		glColor3f( .9f, .9f, 0. );
		glPushMatrix( );
			glTranslatef( -100., -800., 0. );
			glutWireSphere( 600., 100., 100. );
		glPopMatrix( );
	glEndList( );

	AxesList = glGenLists( 1 );
	glNewList( AxesList, GL_COMPILE );
		glColor3fv( AXES_COLOR );
		glLineWidth( AXES_WIDTH );
			Axes( 150. );
		glLineWidth( 1. );
	glEndList( );
}
Ejemplo n.º 17
0
void DrawDebugCamera(const UWorld* InWorld, FVector const& Location, FRotator const& Rotation, float FOVDeg, float Scale, FColor const& Color, bool bPersistentLines, float LifeTime, uint8 DepthPriority)
{
	static float BaseScale = 4.f;
	static FVector BaseProportions(2.f, 1.f, 1.5f);

	// no debug line drawing on dedicated server
	if (GEngine->GetNetMode(InWorld) != NM_DedicatedServer)
	{
		DrawDebugCoordinateSystem(InWorld, Location, Rotation, BaseScale*Scale, bPersistentLines, DepthPriority);
		FVector Extents = BaseProportions * BaseScale * Scale;
		DrawDebugBox(InWorld, Location, Extents, Rotation.Quaternion(), Color, bPersistentLines, LifeTime, DepthPriority);		// lifetime

		// draw "lens" portion
		FRotationTranslationMatrix Axes(Rotation, Location);
		FVector XAxis = Axes.GetScaledAxis( EAxis::X );
		FVector YAxis = Axes.GetScaledAxis( EAxis::Y );
		FVector ZAxis = Axes.GetScaledAxis( EAxis::Z ); 

		FVector LensPoint = Location + XAxis * Extents.X;
		float LensSize = BaseProportions.Z * Scale * BaseScale;
		float HalfLensSize = LensSize * FMath::Tan(FMath::DegreesToRadians(FOVDeg*0.5f));
		FVector Corners[4] = 
		{
			LensPoint + XAxis * LensSize + (YAxis * HalfLensSize) + (ZAxis * HalfLensSize),
			LensPoint + XAxis * LensSize + (YAxis * HalfLensSize) - (ZAxis * HalfLensSize),
			LensPoint + XAxis * LensSize - (YAxis * HalfLensSize) - (ZAxis * HalfLensSize),
			LensPoint + XAxis * LensSize - (YAxis * HalfLensSize) + (ZAxis * HalfLensSize),
		};

		DrawDebugLine(InWorld, LensPoint, Corners[0], Color, bPersistentLines, LifeTime, DepthPriority);
		DrawDebugLine(InWorld, LensPoint, Corners[1], Color, bPersistentLines, LifeTime, DepthPriority);
		DrawDebugLine(InWorld, LensPoint, Corners[2], Color, bPersistentLines, LifeTime, DepthPriority);
		DrawDebugLine(InWorld, LensPoint, Corners[3], Color, bPersistentLines, LifeTime, DepthPriority);

		DrawDebugLine(InWorld, Corners[0], Corners[1], Color, bPersistentLines, LifeTime, DepthPriority);
		DrawDebugLine(InWorld, Corners[1], Corners[2], Color, bPersistentLines, LifeTime, DepthPriority);
		DrawDebugLine(InWorld, Corners[2], Corners[3], Color, bPersistentLines, LifeTime, DepthPriority);
		DrawDebugLine(InWorld, Corners[3], Corners[0], Color, bPersistentLines, LifeTime, DepthPriority);
	}
}
Ejemplo n.º 18
0
void PutFile()
{

  MakeIdentTable();
  SortIdentTable(); /* Sort identifiers by size. */
  TopBands();       /* Keep only noOfBands bands and put rest in an other group. */
  Dimensions(); 
  Scale();

  #if PRINT_IDENT_TABLE
    printIdentTable();
  #endif  

  /* Start printing graph. */
  Prologue();
  output->Fonts();
  BorderOutlineBox();

  TitleOutlineBox();
  TitleText();
  
  CurvesInit();
  
  Key();
  
  Curves();

  Axes();

  if (showMax)
    drawMaxValue(maxValue, maxValueStr);
  if (mflag) Marks();
  if (cflag) Comments();
  output->Prologue();

  return;
}
Ejemplo n.º 19
0
void RenderScene(void)
{


    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glutReshapeFunc(ChangeSize);
    glLoadIdentity();
	gluLookAt(viewer[0],viewer[1],viewer[2], 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
    Axes();
	//glRotatef(theta[0], 1.0, 0.0, 0.0);
	//glRotatef(theta[1], 0.0, 1.0, 0.0);
	//glRotatef(theta[2], 0.0, 0.0, 1.0);
	//glColor3f(1.0f, 1.0f, 1.0f); // Ustawienie koloru rysowania na bia³y 
	//glRotated(60.0, 1.0, 1.0,1.0);
	if(status == 1)                    // je?li lewy klawisz myszy wci?ni?ty
	{
	   thetax += delta_x * pix2angle;
	   thetay += delta_y * pix2angle;
	   
	}  else if(status ==2){
		theta_zoom += delta_zoom*pix2angle;
		
	}// do ró?nicy po?o?e? kursora myszy

	glRotatef(thetax, 0.0, 1.0, 0.0);
	glRotatef(thetay, 1.0, 0.0, 0.0);
	glRotatef(theta_zoom, 0.0, 0.0, 0.0);
	glColor3f(1.0f, 1.0f, 1.0f);
// Ustawienie koloru rysowania na bia?y

	glutSolidTeapot(3.0);
// Narysowanie czajnika 
	
	glFlush();
    glutSwapBuffers();
}
Ejemplo n.º 20
0
Axes3D::Axes
Axes3D::GetAxesType() const
{
    return Axes(axesType);
}
Ejemplo n.º 21
0
void
InitLists( )
{
    glutSetWindow( MainWindow );

    // Create the helicopter:

    HeliList = glGenLists( 1 );
    glNewList( HeliList, GL_COMPILE );
        if(!HELI_SOLID){
            int i;
            struct edge *ep;
            struct point *p0, *p1;

            glPushMatrix( );
            glTranslatef( 0., -1., 0. );
            glRotatef(  97.,   0., 1., 0. );
            glRotatef( -15.,   0., 0., 1. );
            glBegin( GL_LINES );
                for( i=0, ep = Heliedges; i < Helinedges; i++, ep++ )
                {
                    p0 = &Helipoints[ ep->p0 ];
                    p1 = &Helipoints[ ep->p1 ];
                    glVertex3f( p0->x, p0->y, p0->z );
                    glVertex3f( p1->x, p1->y, p1->z );
                }
            glEnd( );
            glPopMatrix( );
        }else{
            int i;
            struct point *p0, *p1, *p2;
            struct tri *tp;
            float p01[3], p02[3], n[3];

            glPushMatrix( );
            glTranslatef( 0., -1., 0. );
            glRotatef(  97.,   0., 1., 0. );
            glRotatef( -15.,   0., 0., 1. );
            glBegin( GL_TRIANGLES );
                for( i=0, tp = Helitris; i < Helintris; i++, tp++ )
                {
                    p0 = &Helipoints[ tp->p0 ];
                    p1 = &Helipoints[ tp->p1 ];
                    p2 = &Helipoints[ tp->p2 ];

                    /* fake "lighting" from above:                  */

                    p01[0] = p1->x - p0->x;
                    p01[1] = p1->y - p0->y;
                    p01[2] = p1->z - p0->z;
                    p02[0] = p2->x - p0->x;
                    p02[1] = p2->y - p0->y;
                    p02[2] = p2->z - p0->z;
                    Cross( p01, p02, n );
                    Unit( n, n );
                    n[1] = fabs( n[1] );
                    n[1] += .25;
                    if( n[1] > 1. )
                        n[1] = 1.;
                    glColor3f( 0., n[1], 0. );

                    glVertex3f( p0->x, p0->y, p0->z );
                    glVertex3f( p1->x, p1->y, p1->z );
                    glVertex3f( p2->x, p2->y, p2->z );
                }
            glEnd( );
            glPopMatrix( );
        }
    glEndList( );

    // draw the helicopter blade with radius BLADE_RADIUS and
    //      width BLADE_WIDTH centered at (0.,0.,0.) in the XY plane

    BladeList = glGenLists( 1 );
    glNewList( BladeList, GL_COMPILE );
        glPushMatrix( );
        glBegin( GL_TRIANGLES );
            glVertex2f(  BLADE_RADIUS,  BLADE_WIDTH/2. );
            glVertex2f(  0., 0. );
            glVertex2f(  BLADE_RADIUS, -BLADE_WIDTH/2. );

            glVertex2f( -BLADE_RADIUS, -BLADE_WIDTH/2. );
            glVertex2f(  0., 0. );
            glVertex2f( -BLADE_RADIUS,  BLADE_WIDTH/2. );
        glEnd( );
        glPopMatrix( );
    glEndList( );

    // Draw the world
    WorldList = glGenLists( 1 );
    glNewList( WorldList, GL_COMPILE );
        glPushMatrix( );
        glColor3f( 0.2, 0.2, 1. );
        glBegin( GL_QUADS );
            glVertex3f(WORLD_APOTHEM, WORLD_HEIGHT, WORLD_APOTHEM);
            glVertex3f(WORLD_APOTHEM, WORLD_HEIGHT, -WORLD_APOTHEM);
            glVertex3f(-WORLD_APOTHEM, WORLD_HEIGHT, -WORLD_APOTHEM);
            glVertex3f(-WORLD_APOTHEM, WORLD_HEIGHT, WORLD_APOTHEM);
        glEnd( );
        glPopMatrix( );
    glEndList( );

    // Draw the object
    ObjectList = glGenLists( 1 );
    glNewList( ObjectList, GL_COMPILE );
        int rotations = 6; 
        float length = PI*2*rotations;
        int steps = 200; 
        float start_r = 0.25, start_g = 0., start_b = 0.25;
        float end_r = 0., end_g = 1., end_b = 0.75;

        // Draw the helix
        glPushMatrix( );
        glBegin( GL_TRIANGLE_STRIP );
            // Rotate in a circle
            for(float s; s < steps; s++){
                float p = s / steps;
                float r = (start_r * (1-p)) + (end_r * p);
                float g = (start_g * (1-p)) + (end_g * p);
                float b = (start_b * (1-p)) + (end_b * p);
                glColor3f(r, g, b);

                float a = (s - steps/2) * (length / steps);
                glVertex3f(cos(a), a/10 + WORLD_HEIGHT+2, sin(a) - OBJECT_DISTANCE);
                glVertex3f(cos(a), a/10 + WORLD_HEIGHT+2+0.2, sin(a) - OBJECT_DISTANCE);
            }
        glEnd( );
        glPopMatrix( );
    glEndList( );

    // create the axes:

    AxesList = glGenLists( 1 );
    glNewList( AxesList, GL_COMPILE );
        glLineWidth( AXES_WIDTH );
            Axes( 3. );
        glLineWidth( 1. );
    glEndList( );
}
Ejemplo n.º 22
0
void display(void) {
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    Axes();
    glColor3f (1.0, 0.0, 0.0);                // Set the color to RED
    Draw(initial);
    glFlush();

    matrixSetIdentity(theMatrix);

    //change begins


    switch(choice) {
    case 1:
        printf("Enter Translation along X, Y & Z\n=>");
        scanf("%f%f%f",&TransDistX , &TransDistY , &TransDistZ);
        break;
    case 2:
        printf("Enter Scaling ratios along X, Y & Z\n=>");
        scanf("%f%f%f",&ScaleX , &ScaleY , &ScaleZ);
        break;
    case 3:
        printf("Enter your choice for Rotation about axis:\n");
        printf("1.parallel to X-axis.(y=B & z=C)\n2.parallel to Y-axis.(x=A & z=C)\n");
        printf("3.parallel to Z-axis.(x=A & y=B)\n");
        printf("4.Arbitrary line passing through (x1,y1,z1) & (x2,y2,z2)\n =>");
//Realign above line while execution
        scanf("%d",&choiceRot);
        switch(choiceRot) {
        case 1:
            printf("Enter B & C: ");
            scanf("%f %f",&B,&C);
            printf("Enter Rot. Angle Alpha: ");
            scanf("%f",&Alpha);
            break;
        case 2:
            printf("Enter A & C: ");
            scanf("%f %f",&A,&C);
            printf("Enter Rot. Angle Beta: ");
            scanf("%f",&Beta);
            break;
        case 3:
            printf("Enter A & B: ");
            scanf("%f %f",&A,&B);
            printf("Enter Rot. Angle degrees: ");
            scanf("%f",&Gamma);
            break;
        case 4:
            printf("Enter values of x1 ,y1 & z1:\n");
            scanf("%f %f %f",&x1,&y11,&z1);
            printf("Enter values of x2 ,y2 & z2:\n");
            scanf("%f %f %f",&x2,&y2,&z2);
            printf("Enter Rot. Angle Theta: ");
            scanf("%f",&Theta);
            break;
        }
        break;
    case 4:
        printf("Enter your choice for reflection about plane:\n1.X-Y\n2.Y-Z\n3.X-Z\n=>");
        scanf("%d",&choiceRef);
        break;
    default:
        printf("Please enter a valid choice!!!\n");
        //return 0;
    }

    //chenge ends

    switch(choice) {
    case 1:
        Translate(TransDistX , TransDistY ,TransDistZ);
        break;
    case 2:
        Scale(ScaleX, ScaleY, ScaleZ);
        break;
    case 3:
        switch(choiceRot) {
        case 1:
            DrawRotLine();
            Translate(0,-B,-C);
            RotateX(Alpha);
            Translate(0,B,C);
            break;
        case 2:
            DrawRotLine();
            Translate(-A,0,-C);
            RotateY(Beta);
            Translate(A,0,C);
            break;
        case 3:
            DrawRotLine();
            Translate(-A,-B,0);
            RotateZ(Gamma);
            Translate(A,B,0);
            break;
        case 4:
            DrawRotLine();
            float MOD =sqrt((x2-x1)*(x2-x1) + (y2-y11)*(y2-y11) + (z2-z1)*(z2-z1));
            aa = (x2-x1)/MOD;
            bb = (y2-y11)/MOD;
            cc = (z2-z1)/MOD;
            Translate(-x1,-y11,-z1);
            float ThetaDash;
            ThetaDash = 1260*atan(bb/cc)/22;
            RotateX(ThetaDash);
            RotateY(1260*asin(-aa)/22);
            RotateZ(Theta);
            RotateY(1260*asin(aa)/22);
            RotateX(-ThetaDash);
            Translate(x1,y11,z1);
            break;
        }
        break;
    case 4:
        Reflect();
        break;
    }
    //glFlush();
    TransformPoints();
    Draw(ptsFin);
    memcpy(initial, ptsFin, sizeof(ptsFin));
    glFlush();
    scanf("%d",&choice);
    glutPostRedisplay();

}
Ejemplo n.º 23
0
Axes rotateY(const Axes& a, float f)
{
    return Axes(rotateY(a.x, f), rotateY(a.y, f), rotateY(a.z, f));
}
Ejemplo n.º 24
0
Joint::Joint(){
    position = Position();
    FWDbasic = Axes();
    BWDbasic = Axes();
}
Ejemplo n.º 25
0
void
InitLists( )
{
	float dx = BOXSIZE / 2.f;
	float dy = BOXSIZE / 2.f;
	float dz = BOXSIZE / 2.f;
	glutSetWindow( MainWindow );

	// create the object:

	BoxList = glGenLists( 1 );
	glNewList( BoxList, GL_COMPILE );

		glBegin( GL_QUADS );

			glColor3f( 0., 0., 1. );
			glNormal3f( 0., 0.,  1. );
				glVertex3f( -dx, -dy,  dz );
				glVertex3f(  dx, -dy,  dz );
				glVertex3f(  dx,  dy,  dz );
				glVertex3f( -dx,  dy,  dz );

			glNormal3f( 0., 0., -1. );
				glTexCoord2f( 0., 0. );
				glVertex3f( -dx, -dy, -dz );
				glTexCoord2f( 0., 1. );
				glVertex3f( -dx,  dy, -dz );
				glTexCoord2f( 1., 1. );
				glVertex3f(  dx,  dy, -dz );
				glTexCoord2f( 1., 0. );
				glVertex3f(  dx, -dy, -dz );

			glColor3f( 1., 0., 0. );
			glNormal3f(  1., 0., 0. );
				glVertex3f(  dx, -dy,  dz );
				glVertex3f(  dx, -dy, -dz );
				glVertex3f(  dx,  dy, -dz );
				glVertex3f(  dx,  dy,  dz );

			glNormal3f( -1., 0., 0. );
				glVertex3f( -dx, -dy,  dz );
				glVertex3f( -dx,  dy,  dz );
				glVertex3f( -dx,  dy, -dz );
				glVertex3f( -dx, -dy, -dz );

			glColor3f( 0., 1., 0. );
			glNormal3f( 0.,  1., 0. );
				glVertex3f( -dx,  dy,  dz );
				glVertex3f(  dx,  dy,  dz );
				glVertex3f(  dx,  dy, -dz );
				glVertex3f( -dx,  dy, -dz );

			glNormal3f( 0., -1., 0. );
				glVertex3f( -dx, -dy,  dz );
				glVertex3f( -dx, -dy, -dz );
				glVertex3f(  dx, -dy, -dz );
				glVertex3f(  dx, -dy,  dz );

		glEnd( );

	glEndList( );


	// create the axes:

	AxesList = glGenLists( 1 );
	glNewList( AxesList, GL_COMPILE );
		glLineWidth( AXES_WIDTH );
			Axes( 1.5 );
		glLineWidth( 1. );
	glEndList( );
}
Ejemplo n.º 26
0
void
InitLists( )
{
	float dx;
	float dy = -1 * BOXSIZE / 2.f;
	float dz;
	float rad = 0.5f;
	float 
	glutSetWindow( MainWindow );

	// create the object:

	BoxList = glGenLists( 1 );
	glNewList( BoxList, GL_COMPILE );

	glPushMatrix();
	glTranslatef(-5., 0., -20.);
	glScalef(3.,3.,3.);
	glRotatef(210., 1., 0., 0.);
		glBegin( GL_TRIANGLE_FAN );

			glColor3f( 0., 1., 0. );
			glVertex3f(0, -1, 0);
			glColor3f(0., 0., 1.);
			for (int i = 0; i <= MAX_VERTICES; i ++){
				
				dx = rad * cos(2 * M_PI / MAX_VERTICES * i);
				dz = rad * sin(2 * M_PI / MAX_VERTICES * i);
				glVertex3f(dx, 0.5f, dz);
			}

		glEnd( );


		glBegin(GL_TRIANGLE_FAN);
		glColor3f(.9, .8, 0.);
		glVertex3f(0., 0.5, 0.);
		for (int i = 0; i <= MAX_VERTICES; i++){
			dx = rad * cos(2 * M_PI / MAX_VERTICES * i);
			dz = rad * sin(2 * M_PI / MAX_VERTICES * i);

			glVertex3f(dx, 0.5, dz);
		}
		glEnd();


		int i, j;
		int halfLats = MAX_VERTICES;

		//glColor3f(1., 1., .2);
		for (i = 0; i <= halfLats; i++)
		{
			double lat0 = M_PI * (-0.5 + (double)(i - 1) / MAX_VERTICES);

			double z0 = sin(lat0);
			double zr0 = cos(lat0);

			double lat1 = M_PI * (-0.5 + (double)i / MAX_VERTICES);
			double z1 = sin(lat1);
			double zr1 = cos(lat1);

			glBegin(GL_QUAD_STRIP);
			for (j = 0; j <= MAX_VERTICES; j++)
			{
				glColor3f(1., (double)i / MAX_VERTICES, (double)j / MAX_VERTICES);
				double lng = 2 * M_PI * (double)(j - 1) / MAX_VERTICES;
				double x = cos(lng);
				double y = sin(lng);


				glVertex3f(x * zr1, y * zr1, z1);
			}
			glEnd();
		}
	
	glPopMatrix();
	glEndList( );


	// create the axes:

	AxesList = glGenLists( 1 );
	glNewList( AxesList, GL_COMPILE );
		glLineWidth( AXES_WIDTH );
			Axes( 1.5 );
		glLineWidth( 1. );
	glEndList( );
}
Ejemplo n.º 27
0
void
InitLists( void )
{
	float dx = BOXSIZE / 2.;
	float dy = BOXSIZE / 2.;
	float dz = BOXSIZE / 2.;

	// create the object:
	PointList = glGenLists (1);
	glNewList(PointList, GL_COMPILE);
		glPointSize(POINTSIZE);
		glBegin(GL_POINTS);
			//static for now
			glColor3f(1.,1.,0);
			for( int i = 0; i < TOTAL_NODES; i++){
				glVertex3f(Nodes[i].x, Nodes[i].y, Nodes[i].z);
			}
		glEnd();
	glEndList();
	
	BoxList = glGenLists( 1 );
	glNewList( BoxList, GL_COMPILE );

		glBegin( GL_QUADS );

			glColor3f( 0., 0., 1. );
			glNormal3f( 0., 0.,  1. );
				glVertex3f( -dx, -dy,  dz );
				glVertex3f(  dx, -dy,  dz );
				glVertex3f(  dx,  dy,  dz );
				glVertex3f( -dx,  dy,  dz );

			glNormal3f( 0., 0., -1. );
				glTexCoord2f( 0., 0. );
				glVertex3f( -dx, -dy, -dz );
				glTexCoord2f( 0., 1. );
				glVertex3f( -dx,  dy, -dz );
				glTexCoord2f( 1., 1. );
				glVertex3f(  dx,  dy, -dz );
				glTexCoord2f( 1., 0. );
				glVertex3f(  dx, -dy, -dz );

			glColor3f( 1., 0., 0. );
			glNormal3f(  1., 0., 0. );
				glVertex3f(  dx, -dy,  dz );
				glVertex3f(  dx, -dy, -dz );
				glVertex3f(  dx,  dy, -dz );
				glVertex3f(  dx,  dy,  dz );

			glNormal3f( -1., 0., 0. );
				glVertex3f( -dx, -dy,  dz );
				glVertex3f( -dx,  dy,  dz );
				glVertex3f( -dx,  dy, -dz );
				glVertex3f( -dx, -dy, -dz );

			glColor3f( 0., 1., 0. );
			glNormal3f( 0.,  1., 0. );
				glVertex3f( -dx,  dy,  dz );
				glVertex3f(  dx,  dy,  dz );
				glVertex3f(  dx,  dy, -dz );
				glVertex3f( -dx,  dy, -dz );

			glNormal3f( 0., -1., 0. );
				glVertex3f( -dx, -dy,  dz );
				glVertex3f( -dx, -dy, -dz );
				glVertex3f(  dx, -dy, -dz );
				glVertex3f(  dx, -dy,  dz );

		glEnd( );

	glEndList( );


	// create the axes:

	AxesList = glGenLists( 1 );
	glNewList( AxesList, GL_COMPILE );
		glLineWidth( AXES_WIDTH );
			Axes( 1.5 );
		glLineWidth( 1. );
	glEndList( );
}
Ejemplo n.º 28
0
void
Axes3D::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("Axes3D");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("visible")) != 0)
        SetVisible(node->AsBool());
    if((node = searchNode->GetNode("autoSetTicks")) != 0)
        SetAutoSetTicks(node->AsBool());
    if((node = searchNode->GetNode("autoSetScaling")) != 0)
        SetAutoSetScaling(node->AsBool());
    if((node = searchNode->GetNode("lineWidth")) != 0)
        SetLineWidth(node->AsInt());
    if((node = searchNode->GetNode("tickLocation")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetTickLocation(Location(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Location value;
            if(Location_FromString(node->AsString(), value))
                SetTickLocation(value);
        }
    }
    if((node = searchNode->GetNode("axesType")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 5)
                SetAxesType(Axes(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            Axes value;
            if(Axes_FromString(node->AsString(), value))
                SetAxesType(value);
        }
    }
    if((node = searchNode->GetNode("triadFlag")) != 0)
        SetTriadFlag(node->AsBool());
    if((node = searchNode->GetNode("bboxFlag")) != 0)
        SetBboxFlag(node->AsBool());
    if((node = searchNode->GetNode("xAxis")) != 0)
        xAxis.SetFromNode(node);
    if((node = searchNode->GetNode("yAxis")) != 0)
        yAxis.SetFromNode(node);
    if((node = searchNode->GetNode("zAxis")) != 0)
        zAxis.SetFromNode(node);
    if((node = searchNode->GetNode("setBBoxLocation")) != 0)
        SetSetBBoxLocation(node->AsBool());
    if((node = searchNode->GetNode("bboxLocation")) != 0)
        SetBboxLocation(node->AsDoubleArray());
}