Esempio n. 1
0
void DrawObjects(Shader &s) {
	// 平面描画
	s.SetUniformMatrix4x4("uModel", Matrix().m);
	glColor4f(0.7f, 0.7f, 0.7f, 1.0f);
	DrawPlane(20.0f);

	// 立方体
	// ModelMatrix
	s.SetUniformMatrix4x4("uModel", Matrix().m);
	glColor4f(1, 0.4f, 0.5f, 1.0f);
	DrawCube(1.0f, 1.0f, 1.0f);
	
	// ModelMatrix
	s.SetUniformMatrix4x4("uModel", Matrix::TranslateMatrix(0.85f, 0.7f, 0.3f).m);
	glColor4f(0.98f, 0.98f, 0.98f, 1.0f);
	DrawCube(1.0f, 1.0f, 1.0f);
	
	// ModelMatrix
	s.SetUniformMatrix4x4("uModel", Matrix::TranslateMatrix(-0.3f, -0.5f, 2.5f).m);
	glColor4f(0.2f, 0.3f, 1, 1.0f);
	DrawCube(1.0f, 1.0f, 1.0f);
	
	// ModelMatrix
	s.SetUniformMatrix4x4("uModel", Matrix::TranslateMatrix(2.0f, 0.6f, 1.5f).m);
	glColor4f(0.2f, 1.0f, 0.3f, 1.0f);
	DrawCube(1.0f, 1.0f, 1.0f);
	
	// ModelMatrix
	s.SetUniformMatrix4x4("uModel", Matrix::TranslateMatrix(-1.85f, -0.5f, -1.3f).m);
	glColor4f(0.98f, 0.98f, 0.98f, 1.0f);
	DrawCube(1.0f, 1.0f, 1.0f);
}
Esempio n. 2
0
int main (void)
{
  int move=FALSE;
  Init();
  DrawCube();
  unsigned char r;
  while ( (r=scr.Read(&w)) != kEND )
    {
      switch (r)
	{
	//case kUP : cout << (s.focal += step) << kCR; s = w; break;
	//case kDN : cout << (s.focal -= step) << kCR; s = w; break;
	//case kLE : cout << (s.eyedist += step) << kCR; s = w; break;
	//case kRI : cout << (s.eyedist -= step) << kCR; s = w; break;
	case kSP : move = TRUE; break;
        case kLO : move = FALSE; break;
	}
      DrawCube();
      if (move==TRUE) 
	{
	  //cout << "bouge de la" << kCR;
	  p-=5;   
	  w.Clear(0,150);
	  w.Box(PointZ(350,p,2,80), 100, 100);
	  w.Box(PointZ(200,150,1,100), 200, 200);
	  //s.AleaSource();
	  //s = w;
	}
    }
  return 0;
}
Esempio n. 3
0
    void DrawScene() {
        //The Desk
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, texture[1]);
        glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

        DrawCube(0, 0, 5.5, 5, 4, 1);
        DrawCube(1.5, 1, 2.5, 1, 1, 5);
        DrawCube(-1.5, 1, 2.5, 1, 1, 5);
        DrawCube(1.5, -1, 2.5, 1, 1, 5);
        DrawCube(-1.5, -1, 2.5, 1, 1, 5);

        glDisable(GL_TEXTURE_2D);

        //The Door
        door1.draw(texture[1]);
        door1.approach_notice(eye[0], eye[1], texture[2]);
        door2.draw(texture[1]);
        door2.approach_notice(eye[0], eye[1], texture[2]);
        door3.draw(texture[1]);
        door3.approach_notice(eye[0], eye[1], texture[2]);
        door4.draw(texture[1]);
        door4.approach_notice(eye[0], eye[1], texture[2]);

    }
Esempio n. 4
0
static void Display(void)
{
  glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

  glLoadIdentity();

  /* Drehung um y-Achse, Neigung und Platzierung auf dem Tisch */
  glTranslatef (0.0, -1.0 ,-4.4);
  glRotatef (spinAngle, 0.0, 1.0, 0.0);
  glRotatef (baseAngle, 1.0, 0.0, 0.0);

  /* Ausgabe des Oberarms */
  glPushMatrix();
    /* Wuerfel aus Bsp. 1 durch asymetrische Skalierung zu einem */
    /* Quader deformieren */
    glScalef (0.2, 1.0, 0.2);
    glTranslatef (-0.5, 0.0 , -0.5);
    DrawCube ();
  glPopMatrix();

  /* Lampenkopf + Unterarm an Spitze Oberarm verschieben */
  glTranslatef (0.0, 1.0 , 0.0);

  /* Kippen des Kopfes + Unterarms um Ellenbogenwinkel */
  glRotatef (elbowAngle, 1.0, 0.0, 0.0);

  /* Ausgabe des Unterarms */
  glPushMatrix();
    glScalef (0.2, 1.0, 0.2);
    glTranslatef (-0.5, 0.0 , -0.5);
    DrawCube ();
  glPopMatrix();

  glColor3f(0.5, 0.0, 1.0);
  /* Lampenkopf an Spitze Unterarm verschieben */
  glTranslatef (0.0, 1.0 , 0.0);
  /* Lampenkopf kippen: */
  glRotatef (headAngle, 1.0, 0.0, 0.0);

  /* Ausgabe des Lampenkopfes */
  glPushMatrix();
    gluCylinder (cone, 0.2, 0.2, 0.2, 20, 4);
  glPopMatrix();

  glTranslatef (0.0, 0.0 , 0.2);
  gluCylinder (cone, 0.2, 0.4, 0.2, 20, 4);

  glutSwapBuffers();
}
Esempio n. 5
0
File: draw.c Progetto: docwhat/cwimp
void DrawState()
{
    Short x;
    Char msg[MaxName+4];

    DrawCurrScore();

    // Fill the fields
    x = 0;
    if ( stor.currplayer > -1 ) {
        // If there is a game on, fill in the names and scores
        for ( ; x < stor.numplayers ; x++ ) {
            StrPrintF( msg, "%d. %s", x+1, stor.player[x].name, NULL );
            SetFieldTextFromStr( fieldNamePlayer[x], msg );
            DrawPlayerScore( x );
        }
    }
    // Clears the rest if the fields
    for ( ; x < MaxPlayers ; x++ ) {
        ClearFieldText( fieldNamePlayer[x] );
        ClearFieldText( fieldScorePlayer[x] );
        ClearFieldText( fieldMarkPlayer[x] );
    }

    for ( x = 0 ; x < NumCubes ; x++ ) {
        DrawCube(x);
        DrawKeepBit(x);
    }

    DrawStayButton();
    DrawRollButton();
    DrawStatus();
    DrawTopStatusButton();
}
Esempio n. 6
0
void Render(float timeDelta)
{
	if (!g_bActive)
	{
		Sleep(50) ;
	}

	//SetupMatrix() ;

	// Clear the back-buffer to a RED color
	g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0 );

	// Begin the scene
	if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
	{
		// Draw teapot 
		DrawCube();

		// End the scene
		g_pd3dDevice->EndScene();
	}

	// Present the back-buffer contents to the display
	g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
Esempio n. 7
0
void DrawRow(int x1, int y, int x2)
{
	glPushMatrix();
	for(int x = x1; x <= x2; x++)
	{
		Uint8 Data;
		
		if(Data = Map[x][y])
		{
			Uint8 LeftData = (x > 0) ? Map[x-1][y] : 0;
			Uint8 RightData = (x < 127) ? Map[x+1][y] : 0;
			Uint8 TopData = (y > 0) ? Map[x][y-1] : 0;
			Uint8 BottomData = (y < 127) ? Map[x][y+1] : 0;

			Data = (Data << 1) | 1;
			
			glPushMatrix();
			while(Data&~1)
			{
				if(Data&2)
					DrawCube(LeftData, RightData, TopData, BottomData, Data);

				Data >>= 1;
				LeftData >>= 1;
				RightData >>= 1;
				TopData >>= 1;
				BottomData >>= 1;
				glTranslatef(0, 0, -1);
			}
			glPopMatrix();
		}
		glTranslatef(1, 0, 0);
	}
Esempio n. 8
0
void RenderObjects(void)
{
  float colorBronzeDiff[4] = { 0.8, 0.6, 0.0, 1.0 };
  float colorBronzeSpec[4] = { 1.0, 1.0, 0.4, 1.0 };
  float colorBlue[4]       = { 0.0, 0.2, 1.0, 1.0 };
  float colorNone[4]       = { 0.0, 0.0, 0.0, 0.0 };

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();

  // Main object (cube) ... transform to its coordinates, and render
  glRotatef(15, 1, 0, 0);
  glRotatef(45, 0, 1, 0);
  glRotatef(g_fTeapotAngle, 0, 0, 1);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBlue);
  glMaterialfv(GL_FRONT, GL_SPECULAR, colorNone);
  glColor4fv(colorBlue);
  DrawCube(1.0);

  // Child object (teapot) ... relative transform, and render
  glPushMatrix();
  glTranslatef(2, 0, 0);
  glRotatef(g_fTeapotAngle2, 1, 1, 0);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, colorBronzeDiff);
  glMaterialfv(GL_FRONT, GL_SPECULAR, colorBronzeSpec);
  glMaterialf(GL_FRONT, GL_SHININESS, 50.0);
  glColor4fv(colorBronzeDiff);
  glutSolidTeapot(0.3);
//  glutSolidSphere(1,20,20);
  glPopMatrix(); 

  glPopMatrix();
}
void animation(void)
{
 
    yRotated += 0.01;
    xRotated += 0.02;
    DrawCube();
}
Esempio n. 10
0
/* 
 * Function: LabelCube
 * -------------------
 * Exported function used to draw letters on cubes.  Set the 2-d array
 * at this position to hold the letter and then draw the cube in the un-highlighted
 * version with the letter added.
 */ 
void LabelCube(int row, int col, char letter)
{
    if (row < 0 || row >= gState.numRows || col < 0 || col >= gState.numCols)
	Error("LabelCube called with invalid row, col arguments.");
    gState.letters[row][col] = letter;
    DrawCube(row, col, letter, false);
}
Esempio n. 11
0
void SimpleDraw::DrawArrow( Vec3d  from, Vec3d  to, bool isForward /*= true*/ , bool isFilledBase, float width /*= 1.0f */)
{
	if(!isForward){
		Vec3d  temp = from;
		from = to;
		to = temp;
	}

	if(isFilledBase) 
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
	else
		glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

	float length = (from-to).norm();
	float radius = length * 0.05f;
	if (radius < 0.0) radius = 0.05 * length;

	// draw cube base
	DrawCube(from, radius * 3);

	glPushMatrix();
	glTranslatef(from[0],from[1],from[2]);
	glMultMatrixd(qglviewer::Quaternion(qglviewer::Vec(0,0,1), qglviewer::Vec(to-from)).matrix());

	static GLUquadric* quadric = gluNewQuadric();

	const float head = 2.5*(radius / length) + 0.1;
	const float coneRadiusCoef = 4.0 - 5.0 * head;

	gluCylinder(quadric, radius, radius, length * (1.0 - head/coneRadiusCoef), 16, 1);
	glTranslatef(0.0, 0.0, length * (1.0 - head));
	gluCylinder(quadric, coneRadiusCoef * radius, 0.0, head * length, 16, 1);

	glPopMatrix();
}
Esempio n. 12
0
//------------------------------------------------------------------------------
// void DrawSpacecraft(float radius, GlColorType *color1, GlColorType *color2,
//                     bool drawSphere = true)
//------------------------------------------------------------------------------
void DrawSpacecraft(float radius, GlColorType *color1, GlColorType *color2,
                    bool drawSphere)
{
   if (drawSphere)
   {
      glColor3ub(color1->red, color1->green, color1->blue);
      DrawSphere(radius, 50, 50, GLU_FILL);
   }
   else
   {
      glColor3ub(color1->red, color1->green, color1->blue);
      DrawCube(radius, radius, radius*2);
      glColor3ub(color2->red, color2->green, color2->blue);
      DrawCube(radius/4, radius*4, radius*1.5);
   }
}
Esempio n. 13
0
//
// This function is called when the window needs redrawing.
//
static void Display(void)
{
    int i;
    
	// Select correct buffer for this context.
	glDrawBuffer(GL_BACK);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.
    
    arglPixelBufferDataUpload(gArglSettings, gARTImage);
	arglDispImage(gArglSettings);
	gARTImage = NULL; // Invalidate image data.
				
    // Set up 3D mode.
	glMatrixMode(GL_PROJECTION);
#ifdef ARDOUBLE_IS_FLOAT
	glLoadMatrixf(cameraLens);
#else
	glLoadMatrixd(cameraLens);
#endif
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
    glEnable(GL_DEPTH_TEST);

    // Set any initial per-frame GL state you require here.
    // --->
    
    // Lighting and geometry that moves with the camera should be added here.
    // (I.e. should be specified before marker pose transform.)
    // --->
    
    for (i = 0; i < markersNFTCount; i++) {
        
        if (markersNFT[i].valid) {
        
#ifdef ARDOUBLE_IS_FLOAT
            glLoadMatrixf(markersNFT[i].pose.T);
#else
            glLoadMatrixd(markersNFT[i].pose.T);
#endif
            // All lighting and geometry to be drawn relative to the marker goes here.
            // --->
            DrawCube();
        }
    }
    
    // Set up 2D mode.
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, (GLdouble)gWindowW, 0, (GLdouble)gWindowH, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);

    // Add your own 2D overlays here.
    // --->
    
	glutSwapBuffers();
}
Esempio n. 14
0
int main()
{
    // Initialization
    //--------------------------------------------------------------------------------------
    int screenWidth = 800;
    int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d mode");

    // Define the camera to look into our 3d world
    Camera camera;
    camera.position = (Vector3){ 0.0f, 10.0f, 10.0f };  // Camera position
    camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };      // Camera looking at point
    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };          // Camera up vector (rotation towards target)
    camera.fovy = 45.0f;                                // Camera field-of-view Y

    Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };

    SetTargetFPS(60);   // Set our game to run at 60 frames-per-second
    //--------------------------------------------------------------------------------------

    // Main game loop
    while (!WindowShouldClose())    // Detect window close button or ESC key
    {
        // Update
        //----------------------------------------------------------------------------------
        // TODO: Update your variables here
        //----------------------------------------------------------------------------------

        // Draw
        //----------------------------------------------------------------------------------
        BeginDrawing();

            ClearBackground(RAYWHITE);

            Begin3dMode(camera);

                DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
                DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, MAROON);

                DrawGrid(10, 1.0f);

            End3dMode();

            DrawText("Welcome to the third dimension!", 10, 40, 20, DARKGRAY);

            DrawFPS(10, 10);

        EndDrawing();
        //----------------------------------------------------------------------------------
    }

    // De-Initialization
    //--------------------------------------------------------------------------------------
    CloseWindow();        // Close window and OpenGL context
    //--------------------------------------------------------------------------------------

    return 0;
}
Esempio n. 15
0
void BatchRenderer::DrawAABB( const rxAABB& box, const FColor& color )
{
	XMMATRIX matWorld = XMMatrixScaling( box.Extents.x, box.Extents.y, box.Extents.z );
	XMVECTOR position = XMLoadFloat3( &box.Center );
	matWorld.r[3] = XMVectorSelect( matWorld.r[3], position, XMVectorSelectControl( 1, 1, 1, 0 ) );

	DrawCube( matWorld, color );
}
Esempio n. 16
0
void RenderFunction (void)
{
  ++FrameCount;
  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  DrawCube ();
  glutSwapBuffers ();
  glutPostRedisplay ();
}
Esempio n. 17
0
static void BuildCube(void)
{
    GLint i;

    glNewList(lists[CUBE], GL_COMPILE);
    DrawCube();
    glEndList();
}
Esempio n. 18
0
static void
draw(void)
{
   float ar;

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
   glTranslatef(0.0, 0.0, -40.0);

   glDisable(GL_SCISSOR_TEST);
   glClear(GL_DEPTH_BUFFER_BIT);
   glEnable(GL_SCISSOR_TEST);

   /* draw gears */
   glViewport(0, 0, TexWidth, TexHeight);
   glScissor(0, 0, TexWidth, TexHeight);
   glClearColor(0.5, 0.5, 0.8, 0.0);
   glClearColor(1, 1, 1, 0);
   glClear(GL_COLOR_BUFFER_BIT);

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 60.0);
   glMatrixMode(GL_MODELVIEW);

   DrawGears();

   glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, TexWidth, TexHeight);
   
   /* draw textured cube */
   glViewport(TexWidth, 0, WinWidth - TexWidth, WinHeight);
   glScissor(TexWidth, 0, WinWidth - TexWidth, WinHeight);
   glClearColor(0.5, 0.5, 0.8, 0.0);
   glClear(GL_COLOR_BUFFER_BIT);

   ar = (float) (WinWidth - TexWidth) / WinHeight;
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   glFrustum(-ar, ar, -1.0, 1.0, 5.0, 60.0);
   glMatrixMode(GL_MODELVIEW);

   DrawCube();

   /* finish up */
   glutSwapBuffers();

   Frames++;
   {
      GLint t = glutGet(GLUT_ELAPSED_TIME);
      if (t - T0 >= 5000) {
         GLfloat seconds = (t - T0) / 1000.0;
         GLfloat fps = Frames / seconds;
         printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
         T0 = t;
         Frames = 0;
      }
   }
}
Esempio n. 19
0
void Robot::DrawHead(float xPos, float yPos, float zPos)
{
	glPushMatrix();
		glColor3f(1.0f, 1.0f, 1.0f);	// white
		glTranslatef(xPos, yPos, zPos);
		glScalef(2.0f, 2.0f, 2.0f);		// head is a 2x2x2 cube
		DrawCube(0.0f, 0.0f, 0.0f);
	glPopMatrix();
}
Esempio n. 20
0
void Robot::DrawArm(float xPos, float yPos, float zPos)
{
	glPushMatrix();
		glColor3f(1.0f, 0.0f, 0.0f);	// red
		glTranslatef(xPos, yPos, zPos);
		glScalef(1.0f, 4.0f, 1.0f);		// arm is a 1x4x1 cube
		DrawCube(0.0f, 0.0f, 0.0f);
	glPopMatrix();
}
Esempio n. 21
0
void Robot::DrawFoot(float xPos, float yPos, float zPos)
{
	glPushMatrix();
		glColor3f(1.0f, 1.0f, 1.0f);
		glTranslatef(xPos, yPos, zPos);
		glScalef(1.0f, 0.5f, 3.0f);
		DrawCube(0.0f, 0.0f, 0.0f);
	glPopMatrix();
}
Esempio n. 22
0
void Robot::DrawTorso(float xPos, float yPos, float zPos)
{
	glPushMatrix();
		glColor3f(0.0f, 0.0f, 1.0f);	// blue
		glTranslatef(xPos, yPos, zPos);
		glScalef(3.0f, 5.0f, 2.0f);		// torso is a 3x5x2 cube
		DrawCube(0.0f, 0.0f, 0.0f);
	glPopMatrix();
}
void DrawCenterCube(float size)
{
	glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	DrawCube(size * 0.2f);
	
	glDisable(GL_BLEND);
}
Esempio n. 24
0
void BatchRenderer::DrawOBB( const rxOOBB& box, const FColor& color )
{
	XMMATRIX matWorld = XMMatrixRotationQuaternion( XMLoadFloat4( &box.Orientation ) );
	XMMATRIX matScale = XMMatrixScaling( box.Extents.x, box.Extents.y, box.Extents.z );
	matWorld = XMMatrixMultiply( matScale, matWorld );
	XMVECTOR position = XMLoadFloat3( &box.Center );
	matWorld.r[3] = XMVectorSelect( matWorld.r[3], position, XMVectorSelectControl( 1, 1, 1, 0 ) );

	DrawCube( matWorld, color );
}
Esempio n. 25
0
//
// This function is called when the window needs redrawing.
//
static void Display(void)
{
    ARdouble p[16];
	ARdouble m[16];
	
	// Select correct buffer for this context.
	glDrawBuffer(GL_BACK);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear the buffers for new frame.
	
    arglPixelBufferDataUpload(gArglSettings, gARTImage);
	arglDispImage(gArglSettings);
	gARTImage = NULL; // Invalidate image data.
				
	// Projection transformation.
	arglCameraFrustumRH(&(gCparamLT->param), VIEW_DISTANCE_MIN, VIEW_DISTANCE_MAX, p);
	glMatrixMode(GL_PROJECTION);
#ifdef ARDOUBLE_IS_FLOAT
	glLoadMatrixf(p);
#else
	glLoadMatrixd(p);
#endif
	glMatrixMode(GL_MODELVIEW);
		
	// Viewing transformation.
	glLoadIdentity();
	// Lighting and geometry that moves with the camera should go here.
	// (I.e. must be specified before viewing transformations.)
	//none
	
	if (gPatt_found) {
	
		// Calculate the camera position relative to the marker.
		// Replace VIEW_SCALEFACTOR with 1.0 to make one drawing unit equal to 1.0 ARToolKit units (usually millimeters).
		arglCameraViewRH(gPatt_trans, m, VIEW_SCALEFACTOR);
#ifdef ARDOUBLE_IS_FLOAT
        glLoadMatrixf(m);
#else
        glLoadMatrixd(m);
#endif

        // Before drawing any geometry, mask out the area occupied by the cube marker itself.
        // This makes for a nicer visual presentation, but obviously only applies for this particular
        // shape of marker.
        DrawCubeMarkerMask();
        
		// All lighting and geometry to be drawn relative to the marker goes here.
		DrawCube();
	
	} // gPatt_found
	
	// Any 2D overlays go here.
	//none
	
	glutSwapBuffers();
}
void z_perspective(int dist)
{
	int i;
	for(i=0;i<8;i++)
	{
		vertex[i][2]=vertex[i][2]/(vertex[i][2]/dist+1);
		vertex[i][0]=vertex[i][0]/(vertex[i][2]/dist+1);
		vertex[i][1]=vertex[i][1]/(vertex[i][2]/dist+1);
	}
	DrawCube();
}
Esempio n. 27
0
void DrawManager::DrawCollisionCube(CollisionDetection* collision, const GLint pTexture, 
				const float pTexCoordX, const float pTexCoordY, const Vector3D& pPosition, const Vector3D& pSize) const
{
	glPushMatrix();
		DrawCube(pTexture, pTexCoordX, pTexCoordY, pPosition, pSize.x, pSize.y, pSize.z);
		Vector3D position = pPosition;
		position.z -= pSize.z;
		Vector3D size(pPosition.x+pSize.x, pPosition.y+pSize.y, pPosition.z);
		collision->AddCollisionBox(position, size);
	glPopAttrib();
}
Esempio n. 28
0
void CD3DRenderer::ProcessPlay()
{
    HRESULT hr;
    hr = m_pD3DDevice9->Clear(0,nullptr,D3DCLEAR_TARGET,0x0,0,0);
    if(SUCCEEDED(m_pD3DDevice9->BeginScene()))
    {
        DrawCube();
        m_pD3DDevice9->EndScene();
    }
    hr = m_pD3DDevice9->Present(nullptr, nullptr, nullptr, nullptr);
}
Esempio n. 29
0
void GlPreviewer::Render(int width, int height, Geometry* geo, Material3D mat, float zoom, float rotation)
{
	// USE OLD OPENGL 1 code
	glClearColor(0.0,0.0,0.0,1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LESS);
	
	glViewport(0, 0, width, height);
	
	// Isometric
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-10.0f + zoom, 10.0f - zoom, -10.0f + zoom, 10.0f - zoom, -10.0f, 10.0f);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
	glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
	
	glRotatef(rotation,0.0f,1.0f,0.0f);
	
	// Draw AXIS
	glColor3f(1.0,0.0,0.0);
	
	glBegin(GL_LINES);
		glVertex3f(0.0,0.0,0.0);
		glVertex3f(100.0,0.0,0.0);
	glEnd();
	
	glColor3f(0.0,1.0,0.0);
	
	glBegin(GL_LINES);
		glVertex3f(0.0,0.0,0.0);
		glVertex3f(0.0,100.0,0.0);
	glEnd();
	
	glColor3f(0.0,0.0,1.0);
	
	glBegin(GL_LINES);
		glVertex3f(0.0,0.0,0.0);
		glVertex3f(0.0,0.0,100.0);
	glEnd();
	
	for(short i=0;i<geo->g;i++){
		for(short j=0;j<geo->g;j++){
			for(short k=0;k<geo->g;k++){
				if(geo->GetGrid(i,j,k)==1){
					DrawCube(i,j,k,mat[i][j][k]);
				}
			}
		}
	}
}
Esempio n. 30
0
int C_TestTraceline::DrawModel( int flags )
{
	trace_t tr;
	Vector forward, right, up, endpos, hitpos;
	AngleVectors (GetAbsAngles(), &forward, &right, &up);
	endpos = GetAbsOrigin() + forward * MAX_TRACE_LENGTH;

	UTIL_TraceLine( GetAbsOrigin(), endpos, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr );

	CMatRenderContextPtr pRenderContext( materials );
	IMesh* pMesh = pRenderContext->GetDynamicMesh( true, NULL, NULL, m_pWireframe );

	CMeshBuilder meshBuilder;
	meshBuilder.Begin( pMesh, MATERIAL_LINES, 1 );

	meshBuilder.Position3fv( GetAbsOrigin().Base() );
	meshBuilder.Color3ub( 255, 255, 255 );
	meshBuilder.AdvanceVertex();

	meshBuilder.Position3fv( tr.endpos.Base() );
	meshBuilder.Color3ub( 255, 255, 255 );
	meshBuilder.AdvanceVertex();

	meshBuilder.End();
	pMesh->Draw();

	// Didn't hit anything
	if ( tr.fraction != 1.0 )
	{
		unsigned char color[] = { 0, 255, 0 };
		DrawCube( tr.endpos, color );
	}

	if ( (!tr.allsolid) && (tr.fractionleftsolid != 0.0) )
	{
		unsigned char color[] = { 255, 0, 0 };
		DrawCube( tr.startpos, color );
	}

	return 1;
}