Example #1
0
void               P3DMaterialDef::Load
                                      (P3DInputStringFmtStream
                                                          *SourceStream,
                                       const P3DFileVersion
                                                          *Version)
 {
  float                                R1,G1,B1;
  char                                 StrValue[255 + 1];
  unsigned int                         Layer;

  SourceStream->ReadFmtStringTagged("BaseColor","fff",&R1,&G1,&B1);

  SetColor(R1,G1,B1);

  for (Layer = 0; Layer < P3D_MAX_TEX_LAYERS; Layer++)
   {
    if (TexNames[Layer] != NULL)
     {
      free(TexNames[Layer]);
     }
   }

  if ((Version->Major == 0) && (Version->Minor < 4))
   {
    SourceStream->ReadFmtStringTagged("BaseTexture","s",StrValue,sizeof(StrValue));

    if (strcmp(StrValue,"__None__") == 0)
     {
     }
    else
     {
      SetTexName(P3D_TEX_DIFFUSE,StrValue);
     }
   }
  else
   {
    for (Layer = 0; Layer < P3D_MAX_TEX_LAYERS; Layer++)
     {
      SourceStream->ReadFmtStringTagged(TexLayersNames[Layer],"s",StrValue,sizeof(StrValue));

      if (strcmp(StrValue,"__None__") == 0)
       {
       }
      else
       {
        SetTexName(Layer,StrValue);
       }
     }
   }

  SourceStream->ReadFmtStringTagged("DoubleSided","b",&DoubleSided);
  SourceStream->ReadFmtStringTagged("Transparent","b",&Transparent);

  if ((Version->Major == 0) && (Version->Minor < 3))
   {
    bool           Billboard;

    SourceStream->ReadFmtStringTagged("Billboard","b",&Billboard);

    if (Billboard)
     {
      BillboardMode = P3D_BILLBOARD_MODE_SPHERICAL;
     }
    else
     {
      BillboardMode = P3D_BILLBOARD_MODE_NONE;
     }
   }
  else
   {
    SourceStream->ReadFmtStringTagged("BillboardMode","s",StrValue,sizeof(StrValue));

    if      (strcmp(StrValue,"spherical") == 0)
     {
      BillboardMode = P3D_BILLBOARD_MODE_SPHERICAL;
     }
    else if (strcmp(StrValue,"cylindrical") == 0)
     {
      BillboardMode = P3D_BILLBOARD_MODE_CYLINDRICAL;
     }
    else
     {
      BillboardMode = P3D_BILLBOARD_MODE_NONE;
     }
   }

  if ((Version->Major == 0) && (Version->Minor > 2))
   {
    SourceStream->ReadFmtStringTagged("AlphaCtrlEnabled","b",&AlphaCtrlEnabled);
    SourceStream->ReadFmtStringTagged("AlphaFadeIn","f",&AlphaFadeIn);
    SourceStream->ReadFmtStringTagged("AlphaFadeOut","f",&AlphaFadeOut);

    AlphaFadeIn  = P3DMath::Clampf(0.0f,1.0f,AlphaFadeIn);
    AlphaFadeOut = P3DMath::Clampf(0.0f,1.0f,AlphaFadeOut);
   }
 }
Example #2
0
	//--------------------------------------------------------------------
	CRenderState::~CRenderState()
	{
		SetClipRect( NO_CLIPPING, NO_CLIPPING, NO_CLIPPING, NO_CLIPPING );
		SetTexName( NO_TEXTURE );
		glPopMatrix();
	}