void glArchivItem_Bitmap::DrawPercent(const DrawPoint& dstPos, unsigned percent, unsigned color /*= COLOR_WHITE*/)
{
    RTTR_Assert(percent <= 100);
    if(percent == 0u)
        return;
    unsigned drawnHeight = getHeight() * std::min(100u, percent) / 100;
    DrawPoint offset(0, getHeight() - drawnHeight);
    DrawPart(Rect(dstPos + offset, getWidth(), drawnHeight), offset, color);
}
예제 #2
0
파일: L3View.c 프로젝트: deeice/ldglite
void DrawModel(void)
{
	if (!nParts) return;
#ifdef USE_OPENGL
	InitViewMatrix();

	if (ldraw_commandline_opts.output > 0) {
	  if ((output_file = fopen(output_file_name,"w+"))==NULL) {
	    ldraw_commandline_opts.output = 0;
	  }
	}

	Init1LineCounter();

	include_stack_ptr = 0; // Start nesting level pointer at 0.
#ifdef USE_OPENGL
	if (1) 
	{
	  struct L3PartS *RCPartPtr = LoadRC();
	  
	  if (RCPartPtr)
	    DrawPart(1,RCPartPtr, ldraw_commandline_opts.C, m_m);
	}
#endif
	DrawPart(1,&Parts[0], ldraw_commandline_opts.C, m_m);

	//if (ldraw_commandline_opts.output != 1) zStep(INT_MAX, 0);
	// if (include_stack_ptr <= ldraw_commandline_opts.output_depth )
	include_stack_ptr = 0;
	zStep(stepcount,0);

	if (output_file != NULL) {
	  fclose(output_file);
	  output_file = NULL;
	}
	if (ldraw_commandline_opts.debug_level == 1)
	  printf("Done\n");
#else
	SetViewMatrix("1 0 1  .5 1 -.5  -1 0 1");
	DrawPart(1,&Parts[0], 7, m_m);
#endif

}
예제 #3
0
파일: WWindow.cpp 프로젝트: beanhome/dev
void WWindow::Draw() const
{
	uint16 w = GetWidth();
	uint16 h = GetHeight();
	uint16 lm = m_pImageResource[WinPart::TL]->GetWidth();
	uint16 tm = m_pImageResource[WinPart::TL]->GetHeight();
	uint16 rm = m_pImageResource[WinPart::BR]->GetWidth();
	uint16 bm = m_pImageResource[WinPart::BR]->GetHeight();

	DrawPart(m_pImageResource[WinPart::TL], 0,		0,		lm,			tm);
	DrawPart(m_pImageResource[WinPart::TC], lm,		0,		w-lm-rm,	tm);
	DrawPart(m_pImageResource[WinPart::TR], w-rm,	0,		rm,			tm);
	DrawPart(m_pImageResource[WinPart::CL], 0,		tm,		lm,			h-tm-bm);
	DrawPart(m_pImageResource[WinPart::CC], lm,		tm,		w-lm-rm,	h-tm-bm);
	DrawPart(m_pImageResource[WinPart::CR], w-rm,	tm,		rm,			h-tm-bm);
	DrawPart(m_pImageResource[WinPart::BL], 0,		h-bm,	lm,			bm);
	DrawPart(m_pImageResource[WinPart::BC], lm,		h-bm,	w-lm-rm,	bm);
	DrawPart(m_pImageResource[WinPart::BR], w-rm,	h-bm,	rm,			bm);

	Widget::Draw();
}
예제 #4
0
파일: UnitDrawer.cpp 프로젝트: arlukin/dev
void CUnitDrawer::DrawPart(S3DO* part)
{
	if(!part->isEmpty){
		glPushMatrix();
		SubPart* cp=&curUnit->parts[curPart];
		glTranslatef(cp->offset.x*scaleFactor+part->offset.x, cp->offset.z*scaleFactor+part->offset.y, -cp->offset.y*scaleFactor+part->offset.z);
		if(cp->turn.z!=0)
			glRotatef(cp->turn.z*(360.0f*(1/65536.0f)),0,1,0);
		if(cp->turn.x!=0)
			glRotatef(cp->turn.x*(360.0f*(1/65536.0f)),-1,0,0);
		if(cp->turn.y!=0)
			glRotatef(cp->turn.y*(360.0f*(1/65536.0f)),0,0,1);

		if(cp->visible)
			glCallList(part->displist);
	}
	curPart++;
	std::vector<S3DO>::iterator ci;
	for(ci=part->childs.begin();ci!=part->childs.end();++ci)
		DrawPart(ci);

	if(!part->isEmpty)
		glPopMatrix();
}
예제 #5
0
파일: Bitmap.cpp 프로젝트: xeonv3/lion
void Bitmap::Draw(HDC hDC, int x, int y, BOOL bTrans, COLORREF crTransColor)
{
  DrawPart(hDC, x, y, 0, 0, GetWidth(), GetHeight(), bTrans, crTransColor);
}
예제 #6
0
void CCheck::Draw()
{
    Math::Point     iDim, pos;
    float       zoomExt, zoomInt;
    int         icon;

    if ( (m_state & STATE_VISIBLE) == 0 )  return;

    iDim = m_dim;
    m_dim.x = m_dim.y * 0.75f;  // square

    if ( m_state & STATE_SHADOW )
    {
        DrawShadow(m_pos, m_dim);
    }

    m_engine->SetTexture("button1.png");
    m_engine->SetState(Gfx::ENG_RSTATE_NORMAL);

    zoomExt = 1.00f;
    zoomInt = 0.95f;

    icon = 2;
    if ( m_state & STATE_DEFAULT )
    {
        DrawPart(23, 1.3f, 0.0f);

        zoomExt *= 1.15f;
        zoomInt *= 1.15f;
    }
    if ( m_state & STATE_HILIGHT )
    {
        icon = 1;
    }
    if ( m_state & STATE_PRESS )
    {
        icon = 3;
        zoomInt *= 0.9f;
    }
    if ( (m_state & STATE_ENABLE) == 0 )
    {
        icon = 7;
    }
    if ( m_state & STATE_DEAD )
    {
        icon = 17;
    }
    DrawPart(icon, zoomExt, 0.0f);  // draws the button

    if ( (m_state & STATE_DEAD) == 0 )
    {
        m_engine->SetState(Gfx::ENG_RSTATE_TTEXTURE_WHITE);

        if ( m_state & STATE_CHECK )
        {
            icon = 16;  // seen
            DrawPart(icon, zoomInt, 0.0f);  // draw the icon
        }
    }

    m_dim = iDim;

    if ( m_state & STATE_DEAD )  return;

    // Draw the name.
    pos.x = m_pos.x + m_dim.y / 0.9f;
    pos.y = m_pos.y + m_dim.y * 0.50f;
    pos.y -= m_engine->GetText()->GetHeight(m_fontType, m_fontSize)/2.0f;
    m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
}
예제 #7
0
파일: key.cpp 프로젝트: Insolita/colobot
void CKey::Draw()
{
    if ((m_state & STATE_VISIBLE) == 0)
        return;

    Math::Point iDim = m_dim;
    m_dim.x = 200.0f/640.0f;

    if (m_state & STATE_SHADOW)
        DrawShadow(m_pos, m_dim);


    m_engine->SetTexture("button1.png");
    m_engine->SetState(Gfx::ENG_RSTATE_NORMAL); // was D3DSTATENORMAL

    float zoomExt = 1.00f;
    float zoomInt = 0.95f;

    int icon = 2;
    if (m_binding.primary == KEY_INVALID && m_binding.secondary == KEY_INVALID)  // no shortcut?
        icon = 3;

    if (m_state & STATE_DEFAULT)
    {
        DrawPart(23, 1.3f, 0.0f);

        zoomExt *= 1.15f;
        zoomInt *= 1.15f;
    }

    if (m_state & STATE_HILIGHT)
        icon = 1;

    if (m_state & STATE_CHECK)
        icon = 0;

    if (m_state & STATE_PRESS)
    {
        icon = 3;
        zoomInt *= 0.9f;
    }

    if ((m_state & STATE_ENABLE) == 0)
        icon = 7;

    if (m_state & STATE_DEAD)
        icon = 17;

    if (m_catch)
        icon = 23;

    DrawPart(icon, zoomExt, 8.0f / 256.0f);  // draws the button

    float h = m_engine->GetText()->GetHeight(m_fontType, m_fontSize) / 2.0f;

    std::string keyName;
    GetKeyName(keyName, m_binding.primary);
    if (m_binding.secondary != KEY_INVALID)
    {
        std::string orText;
        GetResource(RES_TEXT, RT_KEY_OR, orText);
        keyName.append(orText);

        std::string secondaryKeyName;
        GetKeyName(secondaryKeyName, m_binding.secondary);
        keyName.append(secondaryKeyName);
    }

    Math::Point pos;
    pos.x = m_pos.x + m_dim.x * 0.5f;
    pos.y = m_pos.y + m_dim.y * 0.5f;
    pos.y -= h;
    m_engine->GetText()->DrawText(keyName, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_CENTER, 0);

    m_dim = iDim;

    if (m_state & STATE_DEAD)
        return;

    // Draws the name.
    pos.x = m_pos.x + (214.0f / 640.0f);
    pos.y = m_pos.y + m_dim.y * 0.5f;
    pos.y -= h;
    m_engine->GetText()->DrawText(m_name, m_fontType, m_fontSize, pos, m_dim.x, Gfx::TEXT_ALIGN_LEFT, 0);
}
예제 #8
0
파일: UnitDrawer.cpp 프로젝트: arlukin/dev
void CUnitDrawer::Draw()
{
#ifdef PROFILE_TIME
	LARGE_INTEGER start;
	QueryPerformanceCounter(&start);
#endif
	scaleFactor=1/(65536.0);
	glDisable(GL_CULL_FACE);
	glDisable(GL_BLEND);
	texturehandler->SetTexture();
	glDisable(GL_ALPHA_TEST);
	glEnable(GL_TEXTURE_2D);
//	(*info) << g.shared->numPlayers << " " << g.shared->maxUnits << " " << g.shared->players[0].maxUsedUnit << "\n";
//	(*info) << g.shared->units[0].active << " " << g.shared->units[0].name << "\n";
//	(*info) << g.shared->units[0].pos.x*scaleFactor << " " << g.shared->units[0].pos.y*scaleFactor << " " << g.shared->units[0].pos.z*scaleFactor << "\n";
	for(int p=0;p<g.shared->numPlayers;++p){
		int maxUsed=p * g.shared->maxUnits + g.shared->players[p].maxUsedUnit;
		for(int u=p*g.shared->maxUnits;u<maxUsed;++u){
			if(g.shared->units[u].active && g.shared->units[u].name[0]!=0){
				curUnit=&g.shared->units[u];

				float3 pos(curUnit->pos.x*scaleFactor,curUnit->pos.z*scaleFactor,curUnit->pos.y*scaleFactor);

				if(camera.InView(pos,80)){
					if(curUnit->beingBuilt){
/*						float complete=(1065353216-curUnit->beingBuilt)/1000.0;

						GLfloat gld[]=	{ 0.7f*complete, 1.4f*(1-complete)+0.7f*complete, 0.7f*complete, 1.0f };
						GLfloat gla[]=	{ 0.3f*complete, 0.6f*(1-complete)+0.3f*complete, 0.3f*complete, 1.0f };
*/						glLightfv(GL_LIGHT1, GL_AMBIENT, GreenLightAmbient);
						glLightfv(GL_LIGHT1, GL_DIFFUSE, GreenLightDiffuse);
						glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
						greenLight=true;
					} else {
						if(greenLight){
							greenLight=false;
							glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbientLand);		// Setup The Ambient Light
							glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuseLand);		// Setup The Diffuse Light
							glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
						}
					}
					glPushMatrix();
					glTranslatef3(pos);
					if(curUnit->turn.x!=0)
						glRotatef(curUnit->turn.x*(360.0f*(1/65536.0f)),0,1,0);
					if(curUnit->turn.y!=0)
						glRotatef(curUnit->turn.y*(360.0f*(1/65536.0f)),-1,0,0);
					if(curUnit->turn.z!=0)
						glRotatef(curUnit->turn.z*(360.0f*(1/65536.0f)),0,0,1);
					S3DO* model;
					if(strcmp(prevUnits[u].name,curUnit->name)==0){
						model=prevUnits[u].model;
					} else {
						model=unitparser->Load3DO((string("objects3d\\")+curUnit->name+".3do").c_str(),1,g.shared->players[p].color);
						prevUnits[u].model=model;
						strcpy(prevUnits[u].name,curUnit->name);
					}
					curPart=0;
					DrawPart(model);
					glPopMatrix();
					if(drawHealth){
						glTexCoord2f(PlasmaMidX,PlasmaMidY);
						glNormal3f(0,0.7f,0.7f);
						float h=curUnit->health/100.0;
						glColor3f(0.3f+(1-h),0.3+h*0.7,0.3f);
						float3 up(0,1,0);
						glBegin(GL_QUADS);
							glVertexf3(pos+camera.right*-9+up*(model->size+2)+camera.up*2);
							glVertexf3(pos+camera.right*(h*18-9)+up*(model->size+2)+camera.up*2);
							glVertexf3(pos+camera.right*(h*18-9)+up*(model->size+2));
							glVertexf3(pos+camera.right*-9+up*(model->size+2));
							glColor3f(0,0,0);
							glVertexf3(pos+camera.right*9+up*(model->size+2)+camera.up*2);
							glVertexf3(pos+camera.right*(h*18-9)+up*(model->size+2)+camera.up*2);
							glVertexf3(pos+camera.right*(h*18-9)+up*(model->size+2));
							glVertexf3(pos+camera.right*9+up*(model->size+2));
						glEnd();
					}
					if(drawKills && curUnit->kills){
						if(curUnit->kills>4)
							glColor3f(2,2.0,2.0);
						else
							glColor3f(2,0.5,0.5);
						glPushMatrix();
						glEnable(GL_ALPHA_TEST);
						glEnable(GL_BLEND);
						float3 up(0,1,0);
						glTranslatef3(pos+up*(model->size+4)-camera.right*2);
						glScalef(8,8,8);
						font->glWorldPrint("%d",curUnit->kills);						
						glDisable(GL_BLEND);
						glDisable(GL_ALPHA_TEST);
						glPopMatrix();
						texturehandler->SetTexture();
					}
					if(drawName && model->writeName){
						glColor3f(2,2.0,2.0);
						glPushMatrix();
						glEnable(GL_ALPHA_TEST);
						glEnable(GL_BLEND);
						float3 up(0,1,0);
						glTranslatef3(pos+up*(model->size+10)-camera.right*2);
						glScalef(8,8,8);
						font->glWorldPrint("%s",g.shared->players[p].name);						
						glDisable(GL_BLEND);
						glDisable(GL_ALPHA_TEST);
						glPopMatrix();
						texturehandler->SetTexture();						
					}
				}
			}
		}
	}
	glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbientLand);		// Setup The Ambient Light
	glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuseLand);		// Setup The Diffuse Light
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
#ifdef PROFILE_TIME
	LARGE_INTEGER stop;
	QueryPerformanceCounter(&stop);
	profiler.AddTime("Drawing units",stop.QuadPart - start.QuadPart);
#endif
}
예제 #9
0
파일: L3View.c 프로젝트: deeice/ldglite
int Draw1PartPtr(struct L3LineS *LinePtr, int Color)
{
	float          m1[4][4];
	int CurColor = ldraw_commandline_opts.C;
	int SaveColor;

	int            i;
	float          r[4];
	vector3d       v3d[4];

	if (!LinePtr)
	  return 0;

	InitViewMatrix();
	include_stack_ptr = 1; // Start nesting level pointer at 1.

	SaveColor = LinePtr->Color;
	if (Color < 0) 
	    Color = LinePtr->Color;
	else
	    LinePtr->Color = Color;
	switch (Color)
	{
	case 16:
	    Color = CurColor;
	    break;
	case 24:
#ifdef SIXTEEN_EDGE_COLORS
	    if (0 <= CurColor  &&  CurColor <= 15)
		Color = edge_color(CurColor);
	    else
		Color = 0;
#else
	    Color = edge_color(CurColor);
#endif
	    break;
	default:
	    break;
	}
	
	switch (LinePtr->LineType)
	{
	case 0:
	    break;
	case 1:
	    M4M4Mul(m1,m_m,LinePtr->v);
	    if ((ldraw_commandline_opts.F & TYPE_F_XOR_MODE) && (LinePtr->PartPtr->FromP))
	    {
		// This is a primitive and may render invisibly in TYPE_F_XOR_MODE
		// if it contains no edges.
		ldraw_commandline_opts.F |= TYPE_F_XOR_PRIMITIVE;
		DrawPart(0,LinePtr->PartPtr,Color,m1);
		ldraw_commandline_opts.F &= ~(TYPE_F_XOR_PRIMITIVE);
		break;
	    }
	    DrawPart(0,LinePtr->PartPtr,Color,m1);
	    break;
	case 2:
	    for (i=0; i<LinePtr->LineType; i++)
	    {
		M4V3Mul(r,m_m,LinePtr->v[i]);
		v3d[i].x=r[0];
		v3d[i].y=r[1];
		v3d[i].z=r[2];
	    }
	    render_line(&v3d[0],&v3d[1],Color);
	    break;
	case 3:
	    for (i=0; i<LinePtr->LineType; i++)
	    {
		M4V3Mul(r,m_m,LinePtr->v[i]);
		v3d[i].x=r[0];
		v3d[i].y=r[1];
		v3d[i].z=r[2];
	    }
	    //if (zWire)
	    if ((ldraw_commandline_opts.F & TYPE_F_NO_POLYGONS) ||
		(ldraw_commandline_opts.F & TYPE_F_XOR_MODE))
	    {
		// This would render invisibly in TYPE_F_XOR_MODE 
		// since it contains no edges.
		render_line(&v3d[0],&v3d[1],Color);
		render_line(&v3d[1],&v3d[2],Color);
		render_line(&v3d[2],&v3d[0],Color);
		break;
	    }
	    render_triangle(&v3d[0],&v3d[1],&v3d[2],Color);
	    break;
	case 4:
	    for (i=0; i<LinePtr->LineType; i++)
	    {
		M4V3Mul(r,m_m,LinePtr->v[i]);
		v3d[i].x=r[0];
		v3d[i].y=r[1];
		v3d[i].z=r[2];
	    }
	    //if (zWire)
	    if ((ldraw_commandline_opts.F & TYPE_F_NO_POLYGONS) ||
		(ldraw_commandline_opts.F & TYPE_F_XOR_MODE))
	    {
		// This would render invisibly in TYPE_F_XOR_MODE
		// since it contains no edges.
		render_line(&v3d[0],&v3d[1],Color);
		render_line(&v3d[1],&v3d[2],Color);
		render_line(&v3d[2],&v3d[3],Color);
		render_line(&v3d[3],&v3d[0],Color);
		break;
	    }
	    render_quad(&v3d[0],&v3d[1],&v3d[2],&v3d[3],Color);
	    break;
	case 5:
	    for (i=0; i<4; i++)
	    {
		M4V3Mul(r,m_m,LinePtr->v[i]);
		v3d[i].x=r[0];
		v3d[i].y=r[1];
		v3d[i].z=r[2];
	    }
	    if (ldraw_commandline_opts.F & TYPE_F_XOR_MODE)
	    {
		render_line(&v3d[0],&v3d[1],Color);
		render_line(&v3d[0],&v3d[2],Color);
		render_line(&v3d[1],&v3d[3],Color);
		break;
	    }
	    render_five(&v3d[0],&v3d[1],&v3d[2],&v3d[3],Color);
	    break;
	default:
	    break;
	}
	
	LinePtr->Color = SaveColor;
	return 1;
}
예제 #10
0
파일: L3View.c 프로젝트: deeice/ldglite
static void DrawPart(int IsModel, struct L3PartS *PartPtr, int CurColor, float m[4][4])
{
	float          r[4], m1[4][4];
	int            i, Color;
	struct L3LineS *LinePtr;
	vector3d       v3d[4];

#ifdef USE_OPENGL
	float mm[4][4];
	float det = 0;

	if ((ldraw_commandline_opts.F & TYPE_F_STUDLINE_MODE) != 0)
	  if (PartPtr->IsStud)
	  {
	    DrawPartLine(PartPtr, CurColor, m);
	    //DrawPartBox(PartPtr, CurColor, m, 1);
	    return;
	  }

	// Draw only bounding boxes of top level parts if in fast spin mode.
	if (ldraw_commandline_opts.F & TYPE_F_BBOX_MODE) 
	  if (PartPtr->FromPARTS) // (!IsModel)
	  {
	    if (ldraw_commandline_opts.F & TYPE_F_NO_POLYGONS) 
	      DrawPartBox(PartPtr, CurColor, m, 1);
	    else
	      DrawPartBox(PartPtr, CurColor, m, 0);
	    return;
	  }	

	  if (PartPtr->IsStud)
	    det = M3Det(m); // Check the determinant of m to fix mirrored studs.
#endif

	for (LinePtr = PartPtr->FirstLine; LinePtr; LinePtr = LinePtr->NextLine)
	{
#ifdef USE_OPENGL
                char *s;

	        if (Skip1Line(IsModel,LinePtr))
		  continue;
#endif
		hardcolor = 0; // Assume color 16 or 24.
		switch (LinePtr->Color)
		{
		case 16:
			Color = CurColor;
			break;
		case 24:
#ifdef SIXTEEN_EDGE_COLORS
			if (0 <= CurColor  &&  CurColor <= 15)
				Color = edge_color(CurColor);
			else
				Color = 0;
#else
			Color = edge_color(CurColor);
#endif
			break;
		default:
			Color = LinePtr->Color;
#if 0
			if ((LinePtr->LineType == 3) || 
			    (LinePtr->LineType == 4))
			  // Hardcoded color = printed.  Blend me!
			  hardcolor = 1; 
#else
			if (LinePtr->LineType != 1)
			  // Hardcoded color = printed.  Blend me!
			  hardcolor = 1; 
#endif
			break;
		}
		switch (LinePtr->LineType)
		{
		case 0:
#ifdef USE_OPENGL
		        // Skip whitespace
		        for (s = LinePtr->Comment; *s != 0; s++)
		        {
			  if ((*s != ' ') && (*s != '\t'))
			    break;
			}
			if (strnicmp(s,"STEP",4) == 0)
			{
			  // if (include_stack_ptr <= ldraw_commandline_opts.output_depth )
			  {
			    zStep(stepcount,1);
			    stepcount++;
			  }
			}
			else if (strncmp(s,"CLEAR",5) == 0)
			{
			  // if (include_stack_ptr <= ldraw_commandline_opts.output_depth )
			  {
			    zClear();
			  }
			}
			// Experiment with MLCAD extensions
			// Based on info provided on lugnet.
			else if (strncmp(s,"BUFEXCHG A STORE",16) == 0)
			{
			  int k;

			  if (IsModel)
			  {
			    k = BufA1Store(IsModel,LinePtr);
			    printf("BUFEXCHG A STORE %d\n", k);
			  }
			}
			else if (strncmp(s,"BUFEXCHG A RETRIEVE",19) == 0)
			{
			  int j,n, opts, dcp, cp;
			  extern int curpiece;
			  extern int DrawToCurPiece;
			  void DrawModel(void);
			   
			  if (IsModel)
			  {
			    n = BufA1Retrieve(IsModel,LinePtr);
			    printf("BUFEXCHG A RETRIEVE %d\n", n);
			    // clear and redraw model up to saved point.
#if 0		    
			    opts = ldraw_commandline_opts.M;
			    ldraw_commandline_opts.M = 'C';
			    dcp = DrawToCurPiece;
			    DrawToCurPiece = 1;
			    cp = curpiece;
			    zClear();
			    curpiece = n;
			    Init1LineCounter();
			    BufA1Store(IsModel,LinePtr);
			    DrawModel();
			    //for(j = 0; j < n; j++)
			    //  Draw1Part(j, -1);
			    DrawToCurPiece = dcp;
			    curpiece = cp;
			    ldraw_commandline_opts.M = opts;
#endif
			  }
			}
			else if (strncmp(s,"GHOST",5) == 0)
			{
			  if (IsModel)
			  {
			    // Parse the rest of the line as a .DAT line.
			  }
			}
			if (ldraw_commandline_opts.M != 'C')
			{
			  // Non-continuous output stop after each step.
			}

			// Parse global color change meta-commands
			// Should?? be done by ReadMetaLine() in L3Input.cpp			
			// Should SAVE old colors, restore after the for loop.
			// To save space, build a linked list of saved colors.
			// Do NOT resave a color if its already saved.
			if ((strncmp(s,"COLOR",5) == 0) ||
			    (strncmp(s,"COLOUR",6) == 0))
			{
			  if (ldraw_commandline_opts.debug_level == 1)
			    printf("%s\n", s);
			  //0 COLOR 4 red 0 196 0 38 255 196 0 38 255
			  char colorstr[256];
			  char name[256];
			  int n, inverse_index;

			  n = sscanf(s, "%s %d %s %d %f %f %f %f %f %f %f %f",
				     colorstr, &i, name, &inverse_index,
				     &m1[0][0], &m1[0][1], &m1[0][2], &m1[0][3],
				     &m1[1][0], &m1[1][1], &m1[1][2], &m1[1][3]);
			  if (n != 12)
			  {
			    if (ldraw_commandline_opts.debug_level == 1)
			      printf("Illegal COLOR syntax %d\n",n);
			    break;
			  }
			  zcolor_modify(i,name,inverse_index,
					(int)m1[0][0], (int)m1[0][1], (int)m1[0][2], (int)m1[0][3],
					(int)m1[1][0], (int)m1[1][1], (int)m1[1][2], (int)m1[1][3]);
			}

			// Intercept the ldconfig.ldr !COLOUR meta command.
			if (ldlite_parse_colour_meta(s))
			  break;
#else
			if (strncmp(LinePtr->Comment,"STEP",4) == 0)
			{
				// STEP encountered, you may set some flags to enable/disable e.g. drawing
				// (Note that I have not tested this, but this is the way it is supposed to work :-)
			}
#endif
			break;
		case 1:
#ifdef USE_OPENGL
    // NOTE:  I could achieve L3Lab speeds if I delay rendering studs till last
    // then do occlusion tests on the bounding boxes before rendering.
    // Unfortunately GL_OCCLUSION_TEST_HP is an extension (SUN, HP, ???)
    // 
    // Other ideas include substituting GLU cylinder primitives for studs.  
		        if (LinePtr->PartPtr->IsStud)
			{
                          if ((ldraw_commandline_opts.F & TYPE_F_STUDLESS_MODE) != 0)
                            break;
#ifdef USE_OPENGL_OCCLUSION
                          if ((ldraw_commandline_opts.F & TYPE_F_STUDONLY_MODE) != 0)
			  {
			    M4M4Mul(m1,m,LinePtr->v);
			    if (Occluded(LinePtr->PartPtr, Color, m1))
			      break;
			  }
#endif
			}	    
#endif
			M4M4Mul(m1,m,LinePtr->v);
#ifdef USE_OPENGL
			// Negative determinant means its a mirrored stud.
			if (det < 0)
			{
			  // For now, we only support Paul Easters logo.dat texture.
			  // For display speed, we really should precalculate an IsLogo flag
			  // and use that here rather than IsStud.
			  if  (LinePtr->PartPtr && LinePtr->PartPtr->DatName &&
			       !stricmp(LinePtr->PartPtr->DatName, "logo.dat"))
			  {
			    float mirror[4][4] = {
			      {1.0,0.0,0.0,0.0},
			      {0.0,1.0,0.0,0.0},
			      {0.0,0.0,-1.0,0.0},
			      {0.0,0.0,0.0,1.0}
			    };
			    M4M4Mul(mm,m1,mirror);
			    memcpy(m1,mm,sizeof(m1));
			  }
			}
			  
			// implement nesting level counter.
			include_stack_ptr++;
			DrawPart(0,LinePtr->PartPtr,Color,m1);
			include_stack_ptr--;	
			// Do zStep() after the model, not toplevel parts.
#else
			DrawPart(0,LinePtr->PartPtr,Color,m1);
			if (IsModel) zStep(0,0);
#endif
			break;
		case 2:
#ifdef USE_OPENGL_OCCLUSION
		        if ((ldraw_commandline_opts.F & TYPE_F_STUDONLY_MODE) &&
			    !(PartPtr->IsStud))
                            break;
#endif
			for (i=0; i<LinePtr->LineType; i++)
			{
				M4V3Mul(r,m,LinePtr->v[i]);
				v3d[i].x=r[0];
				v3d[i].y=r[1];
				v3d[i].z=r[2];
			}
			render_line(&v3d[0],&v3d[1],Color);
			break;
		case 3:
#ifdef USE_OPENGL_OCCLUSION
		        if ((ldraw_commandline_opts.F & TYPE_F_STUDONLY_MODE) &&
			    !(PartPtr->IsStud))
                            break;
#endif
			for (i=0; i<LinePtr->LineType; i++)
			{
				M4V3Mul(r,m,LinePtr->v[i]);
				v3d[i].x=r[0];
				v3d[i].y=r[1];
				v3d[i].z=r[2];
			}
#ifdef USE_OPENGL
			// Try to render solid Primitives visibly when in XOR wire mode.
			if (ldraw_commandline_opts.F & TYPE_F_XOR_PRIMITIVE)
			{
			    render_line(&v3d[0],&v3d[1],Color);
			    render_line(&v3d[1],&v3d[2],Color);
			    render_line(&v3d[2],&v3d[0],Color);
			    break;
			}
#endif
			render_triangle(&v3d[0],&v3d[1],&v3d[2],Color);
			break;
		case 4:
#ifdef USE_OPENGL_OCCLUSION
		        if ((ldraw_commandline_opts.F & TYPE_F_STUDONLY_MODE) &&
			    !(PartPtr->IsStud))
                            break;
#endif
			for (i=0; i<LinePtr->LineType; i++)
			{
				M4V3Mul(r,m,LinePtr->v[i]);
				v3d[i].x=r[0];
				v3d[i].y=r[1];
				v3d[i].z=r[2];
			}
#ifdef USE_OPENGL
			// Try to render solid Primitives visibly when in XOR wire mode.
			if (ldraw_commandline_opts.F & TYPE_F_XOR_PRIMITIVE)
			{
			    render_line(&v3d[0],&v3d[1],Color);
			    render_line(&v3d[1],&v3d[2],Color);
			    render_line(&v3d[2],&v3d[3],Color);
			    render_line(&v3d[3],&v3d[0],Color);
			    break;
			}
#endif
			render_quad(&v3d[0],&v3d[1],&v3d[2],&v3d[3],Color);
			break;
		case 5:
#ifdef USE_OPENGL_OCCLUSION
		        if ((ldraw_commandline_opts.F & TYPE_F_STUDONLY_MODE) &&
			    !(PartPtr->IsStud))
                            break;
#endif
			for (i=0; i<4; i++)
			{
				M4V3Mul(r,m,LinePtr->v[i]);
				v3d[i].x=r[0];
				v3d[i].y=r[1];
				v3d[i].z=r[2];
			}
			render_five(&v3d[0],&v3d[1],&v3d[2],&v3d[3],Color);
			break;
		}
	}
	if (((zDetailLevel == TYPE_PART) && (PartPtr->FromPARTS)) ||
	    ((zDetailLevel == TYPE_P) && (PartPtr->FromP)))
	  zStep(-1, 0);
}
예제 #11
0
void BackgroundLayer::Draw(HDC hDC,int x,int y, BOOL bTrans,COLORREF crTransColor){
	//只绘制通过视口看到的那一部分图层
	if (m_rcViewport.top < 0 && m_rcViewport.left < 0){
		// 绘制拆开的视口,从顶部到底部,从左侧环绕到右侧
		DrawPart(hDC, x, y,
			m_iWidth + m_rcViewport.left, m_iHeight + m_rcViewport.top,
			-m_rcViewport.left, -m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x - m_rcViewport.left, y,
			0, m_iHeight + m_rcViewport.top,
			m_rcViewport.right, -m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x, y - m_rcViewport.top,
			m_iWidth + m_rcViewport.left, 0,
			-m_rcViewport.left, m_rcViewport.bottom,
			bTrans, crTransColor);
		DrawPart(hDC, x - m_rcViewport.left, y - m_rcViewport.top,
			0, 0,
			m_rcViewport.right, m_rcViewport.bottom,
			bTrans, crTransColor);
	}
	else if(m_rcViewport.top < 0 && m_rcViewport.right > m_iWidth){
		//绘制拆开的视口,从顶部环绕到底部,从右侧环绕到左侧
		DrawPart(hDC, x, y,
			m_rcViewport.left, m_iHeight + m_rcViewport.top,
			m_iWidth - m_rcViewport.left, -m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x + (m_iWidth - m_rcViewport.left), y,
			0, m_iHeight + m_rcViewport.top,
			m_rcViewport.right - m_iWidth, -m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x, y - m_rcViewport.top,
			m_rcViewport.left, 0,
			m_iWidth - m_rcViewport.left, m_rcViewport.bottom,
			bTrans, crTransColor);
		DrawPart(hDC, x + (m_iWidth - m_rcViewport.left), y - m_rcViewport.top,
			0, 0,
			m_rcViewport.right - m_iWidth, m_rcViewport.bottom,
			bTrans, crTransColor);
	} 
	else if (m_rcViewport.bottom > m_iHeight && m_rcViewport.left < 0){
		// Draw the split viewport wrapping bottom to top AND left to right
		DrawPart(hDC, x, y,
			m_iWidth + m_rcViewport.left, m_rcViewport.top,
			-m_rcViewport.left, m_iHeight - m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x - m_rcViewport.left, y,
			0, m_rcViewport.top,
			m_rcViewport.right, m_iHeight - m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x, y + (m_iHeight - m_rcViewport.top),
			m_iWidth + m_rcViewport.left, 0,
			-m_rcViewport.left, m_rcViewport.bottom - m_iHeight,
			bTrans, crTransColor);
		DrawPart(hDC, x - m_rcViewport.left, y + (m_iHeight - m_rcViewport.top),
			0, 0,
			m_rcViewport.right, m_rcViewport.bottom - m_iHeight,
			bTrans, crTransColor);
	}
	else if (m_rcViewport.bottom > m_iHeight && m_rcViewport.right > m_iWidth){
		// Draw the split viewport wrapping bottom to top AND right to left
		DrawPart(hDC, x, y,
			m_rcViewport.left, m_rcViewport.top,
			m_iWidth - m_rcViewport.left, m_iHeight - m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x + (m_iWidth - m_rcViewport.left), y,
			0, m_rcViewport.top,
			m_rcViewport.right - m_iWidth, m_iHeight - m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x, y + (m_iHeight - m_rcViewport.top),
			m_rcViewport.left, 0,
			m_iWidth - m_rcViewport.left, m_rcViewport.bottom - m_iHeight,
			bTrans, crTransColor);
		DrawPart(hDC, x + (m_iWidth - m_rcViewport.left), y + (m_iHeight - m_rcViewport.top),
			0, 0,
			m_rcViewport.right - m_iWidth, m_rcViewport.bottom - m_iHeight,
			bTrans, crTransColor);
	}
	else if (m_rcViewport.top < 0){
		// Draw the split viewport wrapping from top to bottom
		DrawPart(hDC, x, y,
			m_rcViewport.left, m_iHeight + m_rcViewport.top,
			m_rcViewport.right - m_rcViewport.left, -m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x, y - m_rcViewport.top,
			m_rcViewport.left, 0,
			m_rcViewport.right - m_rcViewport.left, m_rcViewport.bottom,
			bTrans, crTransColor);
	}
	else if (m_rcViewport.right > m_iWidth){
		// Draw the split viewport wrapping from right to left
		DrawPart(hDC, x, y,
			m_rcViewport.left, m_rcViewport.top,
			m_iWidth - m_rcViewport.left, m_rcViewport.bottom - m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x + (m_iWidth - m_rcViewport.left), y,
			0, m_rcViewport.top,
			m_rcViewport.right - m_iWidth, m_rcViewport.bottom - m_rcViewport.top,
			bTrans, crTransColor);
	}
	else if (m_rcViewport.bottom > m_iHeight){
		// Draw the split viewport wrapping from bottom to top
		DrawPart(hDC, x, y,
			m_rcViewport.left, m_rcViewport.top,
			m_rcViewport.right - m_rcViewport.left, m_iHeight - m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x, y + (m_iHeight - m_rcViewport.top),
			m_rcViewport.left, 0,
			m_rcViewport.right - m_rcViewport.left, m_rcViewport.bottom - m_iHeight,
			bTrans, crTransColor);
	}
	else if (m_rcViewport.left < 0){
		// Draw the split viewport wrapping from left to right
		DrawPart(hDC, x, y,
			m_iWidth + m_rcViewport.left, m_rcViewport.top,
			-m_rcViewport.left, m_rcViewport.bottom - m_rcViewport.top,
			bTrans, crTransColor);
		DrawPart(hDC, x - m_rcViewport.left, y,
			0, m_rcViewport.top,
			m_rcViewport.right, m_rcViewport.bottom - m_rcViewport.top,
			bTrans, crTransColor);
	}
	else{
		// Draw the entire viewport at once
		DrawPart(hDC, x, y,
			m_rcViewport.left, m_rcViewport.top,
			m_rcViewport.right - m_rcViewport.left, m_rcViewport.bottom - m_rcViewport.top,
			bTrans, crTransColor);
	}
}
void glArchivItem_Bitmap::DrawPart(const Rect& destArea, unsigned color /*= COLOR_WHITE*/)
{
    DrawPart(destArea, DrawPoint::all(0), color);
}