コード例 #1
0
void AColorDialogForm::OnSLPaint(AObject* pSender,AEvent* pEvent)
{
	AColorHSL hsl;
	hsl = m_HSLColor;
	ACanvas* cs = m_pUICore->GetCanvas();
	ARect rx = GetSLSelector()->GetAbsPosition();
	for(int i=0;i<rx.GetHeight();i++)
	{
		for(int j=0;j<rx.GetWidth();j++)
		{
			AColorHSL tmpHSL;
			tmpHSL.h = hsl.h;
			tmpHSL.s = 100 * (float)j / (float)rx.GetWidth();
			tmpHSL.l = 100 * ( 1.0 - (float)i / (float)rx.GetHeight() );

			cs->DrawPoint(APoint(rx.left+j,rx.top+i),tmpHSL.ToRGB());
		}
	}
	int x = hsl.s * rx.GetWidth() / 100.0;
	int y = rx.GetHeight() - hsl.l * rx.GetHeight() / 100.0;

	APoint pt(rx.left+x,rx.top+y);
	ARect rs(pt.x-5,pt.y-5,pt.x+5,pt.y+5);

	APen pen;
	pen.SetWidth(1);
	rs.Inflate(2,2);
	pen.SetColor( AColor(255,0,0,0) );
	cs->Use(&pen)->DrawEllipse(rs);
	rs.Deflate(2,2);
	pen.SetColor( AColor(255,255,255,255) );
	pen.SetWidth(1.5);

	cs->Use(&pen)->DrawEllipse(rs);
}
コード例 #2
0
ファイル: BerconGradient.cpp プロジェクト: GeorgeR/BerconMaps
void BerconGradient::resetKeys() {	
	if (!pblock) return;

	//pblock->SetCount(pb_submaps, 2);
	//pblock->SetCount(pb_colors, 2);
	//pblock->SetCount(pb_positions, 2);
	/*
	pblock->SetValue(pb_submaps, t, NULL, 0);
	pblock->SetValue(pb_submaps, t, NULL, 1);
	pblock->SetValue(pb_colors, t, AColor(0.f,0.f,0.f,1.f), 0);
	pblock->SetValue(pb_colors, t, AColor(1.f,1.f,1.f,1.f), 1);
	pblock->SetValue(pb_positions, t, 0.f, 0);
	pblock->SetValue(pb_positions, t, 1.f, 1);
*/
	Texmap* nullMaps[2] = {NULL, NULL};
	pblock->Append(pb_submaps, 2, nullMaps);
	AColor col1 = AColor(0.f,0.f,0.f,1.f); AColor col2 = AColor(1.f,1.f,1.f,1.f);
	AColor* colors[2] = {&col1, &col2};
	pblock->Append(pb_colors, 2, colors);
	float floats[2] = {0.f, 1.f};
	pblock->Append(pb_positions, 2, floats);

	ivalid.SetEmpty();
	//Update(GetCOREInterface()->GetTime(),Interval());
}
コード例 #3
0
ファイル: plLayerTex.cpp プロジェクト: MareinK/Plasma
AColor plLayerTex::EvalColor(ShadeContext& sc)
{
    if (!sc.doMaps)
        return AColor(0.0f, 0.0f, 0.0f, 1.0f);

    AColor color;
    if (sc.GetCache(this, color))
        return color;

    if (gbufID)
        sc.SetGBufferID(gbufID);

    //
    // Evaluate the Bitmap
    //
    if (fBitmapPB->GetInt(kBmpUseBitmap) && fBM)
    {
        plBMSampler mysamp(this, fBM);
        color = fUVGen->EvalUVMap(sc, &mysamp, FALSE);
        // We'd like to pass TRUE and actually filter the image, but that seems to be
        // tripping an odd crash in Max internals. *shrug*
    }
    else
        color.White();

    // Invert color if specified
    if (fBitmapPB->GetInt(kBmpInvertColor))
    {
        color.r = 1.0f - color.r;
        color.g = 1.0f - color.g;
        color.b = 1.0f - color.b;
    }
    // Discard color if specified
    if (fBitmapPB->GetInt(kBmpDiscardColor))
        color.r = color.g = color.b = 1.0f;

    // Invert alpha if specified
    if (fBitmapPB->GetInt(kBmpInvertAlpha))
        color.a = 1.0f - color.a;
    // Discard alpha if specified
    if (fBitmapPB->GetInt(kBmpDiscardAlpha))
        color.a = 1.0f;

    // If RGB output is set to alpha, show RGB as grayscale of the alpha
    if (fBitmapPB->GetInt(kBmpRGBOutput) == 1)
        color = AColor(color.a, color.a, color.a, 1.0f);

    sc.PutCache(this, color);
    return color;
}
コード例 #4
0
AColor mrTwoSidedShader::EvalColor(ShadeContext& sc) {

	// Provide a good default for this (for the material editor peview)... 
	// Use the front color for the top half of the screen the the back color 
	// for the bottom half.
	if(m_mainPB != NULL) {
		Point2 screenUV;
		Point2 screenDUV;
		sc.ScreenUV(screenUV, screenDUV);

		// Front map is used for top part of the image
		bool useFront = (screenUV.y > 0.5f);

		TimeValue t = sc.CurTime();
		BOOL mapOn = m_mainPB->GetInt(useFront ? kMainPID_FrontMapOn : kMainPID_BackMapOn, t);
		if(mapOn) {
			Texmap* map = m_mainPB->GetTexmap(useFront ? kMainPID_FrontMap : kMainPID_BackMap, t);
			if(map != NULL) {
				return map->EvalColor(sc);
			}
		}

		// Return the color only
		AColor col = m_mainPB->GetAColor(useFront ? kMainPID_FrontColor : kMainPID_BackColor, t);
		return col;
	}
	
	return AColor(0,0,0);
}
コード例 #5
0
ファイル: BerconNoise.cpp プロジェクト: GeorgeR/BerconMaps
AColor BerconNoise::EvalColor(ShadeContext& sc) {
	if (!sc.doMaps) return black;
	
	AColor c;
	if (sc.GetCache(this,c)) 
		return c; 	
	if (gbufID) sc.SetGBufferID(gbufID);

	// UVW and Distortion
	Point3 p, dpdx, dpdy, dp;	
	if(!berconXYZ.get(sc, p, dpdx, dpdy)) return AColor(0,0,0,0);

	if (useDistortion)
		applyDistortion(sc,p);	
	float nSize = (mapOn[4] && subtex[4]) ? subtex[4]->EvalMono(sc)*size : size;
	p /= nSize; dpdx /= nSize; dpdy /= nSize;
	
	Noise::alterUVW(p, uvwDist);
	NoiseParams np = EvalParameters(&sc);
		
	// Caluclate noise function
	float d = sc.filterMaps ? Noise::limitedNoise(p, dpdx, dpdy, np) : Noise::limitedNoise(p, np);	
	if (useCurve)
		d = curve->GetControlCurve(0)->GetValue(sc.CurTime(), d);

	// Get colors
	RGBA c0 = mapOn[0]&&subtex[0] ? subtex[0]->EvalColor(sc): col[0];
	RGBA c1 = mapOn[1]&&subtex[1] ? subtex[1]->EvalColor(sc): col[1];				
	c = texout->Filter((1.f-d)*c0 + d*c1);

	// Cache
	sc.PutCache(this,c); 
	return c;	
}
コード例 #6
0
ファイル: ai.cpp プロジェクト: Anehta/AGE-lua
void Ai::aciton()
{
    fire_cd->step (ASystem::TimeStep () * 2);
    AScene * game_scene=Game::single ()->getGame_scene();
    ParticleLauncher(game_scene->layer(2),Game::single()->getBullet_texture(),5,AVector2D(this->getX(),this->getY()),
                     AVector2D(100,100),AVector2D(0,0),AColor(1,1,1),
                     AColor(0,1,1),0,300,1,0,4,AVector2D(0,-2),10);
    if(fire_cd->isTouched ())
    {
        fire_cd->rewind ();
        if(is_firing)
        {
            game_scene->layer (2)->addChild (new Bullet(AVector2D(this->middleX()-15,this->middleY()-15),1,0.5,true));
        }
     }
}
コード例 #7
0
ファイル: AFont.cpp プロジェクト: emuikernel/BaijieCppUILib
AFont::AFont():AObject()
{
	m_sName = _T("���ו");
	m_eStyle = FontStyleRegular;
	m_nSize = 12;
	m_Unit = UnitPoint;
	m_Color = AColor(255,0,0,0);
}
コード例 #8
0
mrTwoSidedShader::mrShaderTwoSidedShader_ClassDesc::mrShaderTwoSidedShader_ClassDesc() 
: m_mainPBDesc(
	
	// The internal name of the parameter block must be "Parameters" since we want it to be translated automatically
	kMainPBID, _T("Parameters"), IDS_PARAMETERS, NULL, (P_AUTO_CONSTRUCT | P_AUTO_UI), kRef_MainPB,

	// Rollup
	IDD_TWOSIDEDSHADER, IDS_TWOSIDEDSHADER_PARAMETERS, 0, 0, NULL,

	// Parameters
	// The internal name of this parameter must match that of the .mi declaration, because we want it to be translated automatically
	kMainPID_FrontColor, _T("Front"), TYPE_FRGBA, P_ANIMATABLE, IDS_FRONTCOLOR,	
		p_default, AColor(0.5f, 0.5f, 0.5f),
		p_ui, TYPE_COLORSWATCH, IDC_COLOR_FRONT,
		p_end,
	// The internal name of this parameter must match that of the .mi declaration, because we want it to be translated automatically
	kMainPID_BackColor, _T("Back"), TYPE_FRGBA, P_ANIMATABLE, IDS_BACKCOLOR,	
		p_default, AColor(0.5f, 0.5f, 0.5f),
		p_ui, TYPE_COLORSWATCH, IDC_COLOR_BACK,
		p_end,
	kMainPID_FrontMapOn, _T("FrontMapOn"), TYPE_BOOL, P_ANIMATABLE, IDS_FRONTMAPON,
		p_default, TRUE,
		p_ui, TYPE_SINGLECHEKBOX, IDC_CHECK_FRONTMAPON,
		p_end,
	kMainPID_BackMapOn, _T("BackMapOn"), TYPE_BOOL, P_ANIMATABLE, IDS_BACKMAPON,
		p_default, TRUE,
		p_ui, TYPE_SINGLECHEKBOX, IDC_CHECK_BACKMAPON,
		p_end,
	kMainPID_FrontMap, _T("FrontMap"), TYPE_TEXMAP, 0, IDS_FRONTMAP,
		p_ui, TYPE_TEXMAPBUTTON, IDC_BUTTON_FRONTMAP,
		p_end,
	kMainPID_BackMap, _T("BackMap"), TYPE_TEXMAP, 0, IDS_BACKMAP,
		p_ui, TYPE_TEXMAPBUTTON, IDC_BUTTON_BACKMAP,
		p_end,
	p_end
  )
{
	m_mainPBDesc.SetClassDesc(this);
	imrShaderTranslation_ClassInfo::Init(*this);
	IMtlRender_Compatibility_MtlBase::Init(*this);
}
コード例 #9
0
ファイル: plBMSampler.cpp プロジェクト: Asteral/Plasma
AColor plBMSampler::Sample(ShadeContext& sc, float u,float v) 
{
    AColor none(0.0f, 0.0f, 0.0f, 0.0f);

    if (!fInitialized)
        return none;

    BMM_Color_64 c;
    int x,y;
    float fu,fv;
    fu = frac(u);
    fv = 1.0f-frac(v);
    if (fData.fEnableCrop)
    {
        if (fData.fCropPlacement)
        {
            if (!PlaceUV(sc,fu, fv, int(u), int(v)))
                return AColor(0,0,0,0);
            x = (int)(fu*fbmw+0.5f);
            y = (int)(fv*fbmh+0.5f);
        }
        else
        {
            x = mod(clipx + (int)(fu*fclipw+0.5f),bmw);
            y = mod(clipy + (int)(fv*fcliph+0.5f),bmh);
        }
    }
    else
    {
        x = (int)(fu*fbmw+0.5f);
        y = (int)(fv*fbmh+0.5f);
    }
    fBM->GetLinearPixels(x,y,1,&c);
    switch(fData.fAlphaSource)
    {
    case plBMSamplerData::kDiscard:
        c.a = 0xffff; 
        break;
    case plBMSamplerData::kFromRGB:
        c.a = (c.r+c.g+c.b)/3; 
        break;
        //  TBD
        // XPCOL needs to be handled in bitmap for filtering. 
        // Need to open a bitmap with this property.
        //  case ALPHA_XPCOL:  break; 
    }
    return c;
}
コード例 #10
0
ファイル: plMAXCameraLayer.cpp プロジェクト: Asteral/Plasma
AColor plMAXCameraLayer::EvalColor(ShadeContext& sc)
{
    return AColor(0.0f, 0.0f, 0.0f, 1.0f);
}
コード例 #11
0
ファイル: vdm.cpp プロジェクト: innovatelogic/ilogic-vm
AColor VDM::EvalColor( ShadeContext& sc ) {
	return AColor(0.0f,0.0f,0.0f,1.0f);
}
コード例 #12
0
int SrvrLoadWorldFromFile( uint32_t client_id, FILE *file, INDEX iWorld )
{
	FILE *pFile;
	PWORLD world = GetSetMember( WORLD, &g.worlds, iWorld );
	int sz = 0, cnt, version, size;
	char tag[4]; // read in make sure we're still aligned in the file...
	int linesize;
	int nlines;
	PFLATLAND_MYLINESEG *linearray;
	int wallsize;
	int nwalls;
	PWALL *wallarray;
	int sectorsize;
	int nsectors;
	PSECTOR *sectorarray;
	int namesize;
	int nnames;
	PNAME *namearray;
	int texturesize;
	int ntextures;
	PFLATLAND_TEXTURE *texturearray;

	INDEX texture;

	if( !world )
		return 0;
	{
		char buffer[256];
      GetNameText( iWorld, world->name, buffer, sizeof( buffer ) );
		Fopen( pFile, buffer, "rb" );
	}
	if( !pFile )
      return 0;
	ResetWorld( iWorld ); // make sure this thing is empty );

	sz += fread( tag, 1, 4, pFile );
	if( strncmp( tag, "FLAT", 4 ) ) 
	{
		Log( "Alignment error in file load... totally invalid file." );
		return 0;
	}
	sz += fread( &size, 1, sizeof( size ), pFile );
	if( size < 10 ) // can assume that it was a version ID
		version = size;
	else
		sz = fread( &version, 1, sizeof( version ), pFile );

	if( version < 8 )
	{
		texture = SrvrMakeTexture( client_id, iWorld, SrvrMakeName( client_id, iWorld, WIDE( "Default" ) ) );
		SrvrSetSolidColor( client_id, iWorld, texture, AColor( 43, 76, 180, 0x80 ) );
	}
	Log1( "Loading version: %d", version );

	sz += fread( tag, 1, 4, pFile );
	if( strncmp( tag, "LINE", 4 ) )
	{
		// was not LINE or FLAT tag...
		Log( "Alignment error in file line load." );
		return 0;
	}

	if( version > 9 )
		sz += fread( &linesize, 1, sizeof( linesize ), pFile );

	sz += fread( &nlines, 1, sizeof(nlines), pFile );
	linearray = (PFLATLAND_MYLINESEG*)Allocate( sizeof( PFLATLAND_MYLINESEG ) * nlines );
	for( cnt = 0; cnt < nlines; cnt++ )
	{
		PFLATLAND_MYLINESEG pls;
		LINESEGFILE lsf;
		sz += fread( &lsf, 1, sizeof(LINESEGFILE), pFile );
		pls = GetFromSet( FLATLAND_MYLINESEG, &world->lines );
#ifdef OUTPUT_TO_VIRTUALITY
		pls->pfl = CreateFacetLine( world->object, lsf.r.o, lsf.r.n, lsf.start, lsf.end );
#endif
		linearray[cnt] = pls;
		/* some sort of update line... */
		SetRay( &pls->r, &lsf.r );
		if( version < 9 )
		{
			pls->r.o[1] = -pls->r.o[1];
			pls->r.n[1] = -pls->r.n[1];
		}
		pls->dFrom = lsf.start;
		pls->dTo = lsf.end;

	}

	sz += fread( tag, 1, 4, pFile );
	if( strncmp( tag, "WALL", 4 ) )
	{
		Log( "Alignment error in file wall load." );
		return 0;
	}
	if( version > 9 )
		sz += fread( &wallsize, 1, sizeof( wallsize ), pFile );

	sz += fread( &nwalls, 1, sizeof(nwalls), pFile );
	wallarray = (PWALL*)Allocate( sizeof( PWALL ) * nwalls );
	for( cnt = 0; cnt < nwalls; cnt++ )
	{
		wallarray[cnt] = GetFromSet( WALL, &world->walls );
	}
	for( cnt = 0; cnt < nwalls; cnt++ )
	{
		FILEWALLV1 ReadWall1;
		FILEWALLV2 ReadWall2;
		PWALL pwall;
		pwall = wallarray[cnt];
		if( version < 2 )
		{
			sz += fread( &ReadWall1, 1, sizeof( FILEWALLV1 ), pFile );
			pwall->flags = ReadWall1.flags;
			pwall->iSector = ReadWall1.nSector;

			SetLineWorld( world, pwall->iLine, linearray[ReadWall1.nLine] );

			if( ReadWall1.nWallInto == -1 )
				pwall->iWallInto = INVALID_INDEX;
			else
				pwall->iWallInto = GetMemberIndex( WALL, &world->walls, wallarray[ReadWall1.nWallInto] );
			pwall->iWallStart = GetMemberIndex( WALL, &world->walls, wallarray[ReadWall1.nWallStart] );
			pwall->iWallEnd = GetMemberIndex( WALL, &world->walls, wallarray[ReadWall1.nWallEnd] );
		}
		else 
		{
			sz += fread( &ReadWall2, 1, sizeof( FILEWALLV2 ), pFile );
			pwall->flags = ReadWall2.flags;
			pwall->iSector = ReadWall2.nSector;
			if( ReadWall2.nLine != -1 )
			{
				pwall->iLine = GetMemberIndex( FLATLAND_MYLINESEG, &world->lines, linearray[ReadWall2.nLine] );
				//SetLine( pwall->line, linearray[ReadWall2.nLine] );
			}
			else
			{
				Log( "Wall without line? cant be!" );
				DebugBreak();
				pwall->iLine = INVALID_INDEX;
			}
			if( ReadWall2.nWallInto == -1 )
				pwall->iWallInto = INVALID_INDEX;
			else
				pwall->iWallInto = GetMemberIndex( WALL, &world->walls, wallarray[ReadWall2.nWallInto] );
			pwall->iWallStart = GetMemberIndex( WALL, &world->walls, wallarray[ReadWall2.nWallStart] );
			pwall->iWallEnd = GetMemberIndex( WALL, &world->walls, wallarray[ReadWall2.nWallEnd] );
		}
	}	

	sz += fread( tag, 1, 4, pFile );
	if( strncmp( tag, "SECT", 4 ) )
	{
		Log2( "Alignment error in file sector load. %s(%d)", __FILE__, __LINE__ );
		return 0;
	}
	if( version > 9 )
		sz += fread( &sectorsize, 1, sizeof( sectorsize ), pFile );
	sz += fread( &nsectors, 1, sizeof(nsectors), pFile );
	sectorarray = (PSECTOR*)Allocate( sizeof( PSECTOR ) * nsectors );
	for( cnt = 0; cnt < nsectors; cnt++ )
	{
		FILESECTORV3 ReadSector3;
		FILESECTORV4 ReadSector4;
		FILESECTORV5 ReadSector5;
		FILESECTORV8 ReadSector8;
		INDEX sector;
		sectorarray[cnt] = GetFromSet( SECTOR, &world->sectors );
#ifdef OUTPUT_TO_VIRTUALITY
		sectorarray[cnt]->facet = AddNormalPlane( world->object, VectorConst_0, VectorConst_Z, 0 );
#endif
		sector =  GetMemberIndex( SECTOR, &world->sectors, sectorarray[cnt] );
		if( version < 8 )
		{
			// one texture is sufficient...
			// in fact textures should be highly sharable.
			sectorarray[cnt]->iTexture = texture;
		}
		if( version < 4 )
		{	
			/*
			{
			char name[20];
			sprintf( name, "%d", SectorIDs++ );
			sectorarray[cnt]->name = GetName( &world->names, name );
			}
			*/
			sectorarray[cnt]->iName = INVALID_INDEX;
			sz += fread( &ReadSector3, 1, sizeof( FILESECTORV3 ), pFile );
			sectorarray[cnt]->flags = ReadSector3.flags;
			sectorarray[cnt]->iWorld = iWorld;
			SetRay( &sectorarray[cnt]->r, &ReadSector3.r );
			sectorarray[cnt]->iWall = GetMemberIndex( WALL, &world->walls, wallarray[ReadSector3.nwall] );

			if( version < 3 )
			{
				ComputeSectorOrigin( iWorld, sector);
			}
		}
		else if( version < 5 )
		{
			sz += fread( &ReadSector4, 1, sizeof( FILESECTORV4 ), pFile );
			/*
			{
			char name[20];
			sprintf( name, "%d", ReadSector4.nID );
			sectorarray[cnt]->name = GetName( &world->names, name );
			if( atoi( name ) > SectorIDs )
			SectorIDs = atoi( name );
			}
			*/
			sectorarray[cnt]->iName = INVALID_INDEX;
			sectorarray[cnt]->flags = ReadSector4.flags;
			sectorarray[cnt]->iWorld = iWorld;
			SetRay( &sectorarray[cnt]->r, &ReadSector4.r );
			sectorarray[cnt]->iWall = GetMemberIndex( WALL, &world->walls, wallarray[ReadSector4.nwall] );
		}
		else if( version < 8 )
		{
			sz += fread( &ReadSector5, 1, sizeof( FILESECTORV5 ), pFile );
			sectorarray[cnt]->iName = ReadSector5.nName;
			sectorarray[cnt]->flags = ReadSector5.flags;
			sectorarray[cnt]->iWorld = iWorld;
			SetRay( &sectorarray[cnt]->r, &ReadSector5.r );
			sectorarray[cnt]->iWall = GetMemberIndex( WALL, &world->walls, wallarray[ReadSector5.nwall] );
		}
		else
		{
			sz += fread( &ReadSector8, 1, sizeof( FILESECTORV8 ), pFile );
			sectorarray[cnt]->iName = ReadSector8.nName;
			sectorarray[cnt]->flags = ReadSector8.flags;
			sectorarray[cnt]->iWorld = iWorld;
			SetRay( &sectorarray[cnt]->r, &ReadSector8.r );
			sectorarray[cnt]->iWall = ReadSector8.nwall;
			sectorarray[cnt]->iTexture = ReadSector8.nTexture;
		}
		// walls should all be valid at this point...
		// have valid lines, and valid linkings...
		ComputeSectorPointList( iWorld, sector, NULL );
		ComputeSectorOrigin( iWorld, sector );
#ifdef OUTPUT_TO_VIRTUALITY
		OrderObjectLines( world->object );
#endif
	}

	// fix sector references in walls.
	//for( cnt = 0; cnt < nwalls; cnt++ )
	//{
	//	wallarray[cnt]->iSector = wallarray[cnt]->iSector;
	//}

	for( cnt = 0; cnt < nwalls; cnt++ )
	{
		if( wallarray[cnt]->iLine == INVALID_INDEX )
		{
			SrvrDestroySector( client_id, iWorld, wallarray[cnt]->iSector );
			Log( "attempting to fix broken walls" );
			break;
		}
	}

	if( version >= 5 )
	{
		sz += fread( tag, 1, 4, pFile );
		if( strncmp( tag, "NAME", 4 ) )
		{
			Log2( "Alignment error in name section load. %s(%d)", __FILE__, __LINE__ );
			return 0;
		}
		if( version > 9 )
			sz += fread( &namesize, 1, sizeof( namesize ), pFile );
		sz += fread( &nnames, 1, sizeof(nnames), pFile );
		namearray = (PNAME*)Allocate( sizeof( PNAME ) * nnames );
		for( cnt = 0; cnt < nnames; cnt++ )
		{  	
			namearray[cnt] = GetFromSet( NAME, &world->names );
			if( version < 6 )
			{
				uint32_t length;
 				namearray[cnt]->name = (struct name_data*)Allocate( sizeof( *namearray[cnt]->name ) );
				sz += fread( &length, 1, sizeof( length ), pFile );
            namearray[cnt]->name[0].length = length;
				namearray[cnt]->name[0].name = (TEXTSTR)Allocate( namearray[cnt]->name[0].length + 1 );
 				sz += fread( namearray[cnt]->name[0].name, 1, namearray[cnt]->name[0].length, pFile );
		      namearray[cnt]->name[0].name[namearray[cnt]->name[0].length] = 0;
		      namearray[cnt]->lines = 1;
			}
			else if( version < 7 )
			{
				int l;
				sz += fread( &namearray[cnt]->lines, 1, sizeof( namearray[cnt]->lines ), pFile );
				if( namearray[cnt]->lines )
				{
					namearray[cnt]->name = (struct name_data*)Allocate( sizeof( *namearray[cnt]->name ) * namearray[cnt]->lines );
					for( l = 0; l < namearray[cnt]->lines; l++ )
					{
						sz += fread( &namearray[cnt]->name[l].length, 1, sizeof( namearray[cnt]->name[l].length ), pFile );
						namearray[cnt]->name[l].name = (TEXTSTR)Allocate( namearray[cnt]->name[l].length + 1 );
						sz += fread( namearray[cnt]->name[l].name, 1, namearray[cnt]->name[l].length, pFile );
						namearray[cnt]->name[l].name[namearray[cnt]->name[l].length] = 0;
					}	
				}
				else
					namearray[cnt]->name = NULL;
			}
			else
			{
				int l;
				sz += fread( &namearray[cnt]->flags, 1, sizeof( namearray[cnt]->flags ), pFile );
				sz += fread( &namearray[cnt]->lines, 1, sizeof( namearray[cnt]->lines ), pFile );
				if( namearray[cnt]->lines )
				{
					namearray[cnt]->name = (struct name_data*)Allocate( sizeof( *namearray[cnt]->name ) * namearray[cnt]->lines );
					for( l = 0; l < namearray[cnt]->lines; l++ )
					{
						sz += fread( &namearray[cnt]->name[l].length, 1, sizeof( namearray[cnt]->name[l].length ), pFile );
						namearray[cnt]->name[l].name = (TEXTSTR)Allocate( namearray[cnt]->name[l].length + 1 );
						sz += fread( namearray[cnt]->name[l].name, 1, namearray[cnt]->name[l].length, pFile );
						namearray[cnt]->name[l].name[namearray[cnt]->name[l].length] = 0;
					}	
				}
				else
					namearray[cnt]->name = NULL;
			}
		}
       /*
		for( cnt = 0; cnt < nsectors; cnt++ )
		{
			if( (int)sectorarray[cnt]->iName == -1 )
				sectorarray[cnt]->iName = INVALID_INDEX;
			else
			{
				int n;
				PNAME pName = namearray[(int)sectorarray[cnt]->name];
				if( pName->name && pName->name[0].name )
					if( ( n = atoi( pName->name[0].name ) ) > SectorIDs )
						SectorIDs = n;
				sectorarray[cnt]->name = pName;
			}
	   }
      */
		if( version >= 8 )
		{
			sz += fread( tag, 1, 4, pFile );
			if( strncmp( tag, "TEXT", 4 ) )
			{
				Log2( "Alignment error in texture section load. %s(%d)", __FILE__, __LINE__ );
				return 0;
			}
			if( version > 9 )
				sz += fread( &texturesize, 1, sizeof( texturesize ), pFile );
			sz += fread( &ntextures, 1, sizeof(ntextures), pFile );
			texturearray = (PFLATLAND_TEXTURE*)Allocate( sizeof( PFLATLAND_TEXTURE ) * ntextures );
			for( cnt = 0; cnt < ntextures; cnt++ )
			{
				char flag;
				int nName;
				sz += fread( &nName, 1, sizeof( nName ), pFile );
				texturearray[cnt] = GetFromSet( FLATLAND_TEXTURE, &world->textures );
				texturearray[cnt]->iName = GetMemberIndex( NAME, &world->names, namearray[nName] );
				sz += fread( &flag, 1, sizeof( flag ), pFile );
				texturearray[cnt]->flags.bColor = flag;
				if( flag )
				{
					sz += fread( &texturearray[cnt]->data.color, 1, sizeof(CDATA), pFile );
				}
			}
		   
			//for( cnt = 0; cnt < nsectors; cnt++ )
			//{
			//	int ntexture = (int)sectorarray[cnt]->iTexture;
         //   sectorarray[cnt]->texture = NULL;
			//	SetTexture( sectorarray[cnt]->texture, texturearray[ntexture] );
			//}
			Release( texturearray );
		}

		Release( namearray );
	}

	if( version > 9 )
	{
		if( sz != size )
		{
			Log2( "Total load size %d is not %d", sz, size );
		}
	}

	//for( cnt = 0; cnt < nsectors; cnt++ )
	{
		//PSECTOR pSector = sectorarray[cnt];
		// again with the min/max fetch with
		// spacetree add
		//pSector->spacenode = AddSpaceNode( &world->spacetree, pSector, min, max );
	}

	Release( linearray );
	Release( wallarray );
	Release( sectorarray );
	ValidateWorldLinks(iWorld);
	return version;
}
コード例 #13
0
INDEX SrvrCreateSquareSector( uint32_t client_id, INDEX iWorld, PC_POINT pOrigin, RCOORD size )
{
	PWORLD world = GetSetMember( WORLD, &g.worlds, iWorld );
	PSECTOR pSector;
	INDEX iSector;
	_POINT o, n;
	pSector = GetFromSet( SECTOR, &world->sectors );
#ifdef OUTPUT_TO_VIRTUALITY
	pSector->facet = AddNormalPlane( world->object, VectorConst_0, VectorConst_Z, 0 );
#endif
	iSector = GetMemberIndex( SECTOR, &world->sectors, pSector );
	/*
	{
		char name[20];
		sprintf( name, "%d", SectorIDs++ );
		pSector->name = GetName( &world->names, name );
	}
	*/
	pSector->iName = INVALID_INDEX;
	pSector->iWorld = iWorld;
	/* east */
	addscaled( o, pOrigin, VectorConst_X, size/2 );
	scale( n, VectorConst_Y, 20 );
	// creates an open line....
	pSector->iWall = SrvrCreateWall( client_id, iWorld, iSector, INVALID_INDEX, FALSE, INVALID_INDEX, FALSE, o, n );
	/* south */
	addscaled( o, pOrigin, VectorConst_Y, size/2 );
	scale( n, VectorConst_X, -20 );
	// creates a wall whos start is at the start of the wall...
	SrvrCreateWall( client_id, iWorld, iSector, pSector->iWall, TRUE, INVALID_INDEX, FALSE, o, n );
	/* west */
	addscaled( o, pOrigin, VectorConst_Y, -size/2 );
	scale( n, VectorConst_X, -20 );
	SrvrCreateWall( client_id, iWorld, iSector, pSector->iWall, FALSE, INVALID_INDEX, FALSE, o, n );
	/* north */
	addscaled( o, pOrigin, VectorConst_X, -size/2 );
	scale( n, VectorConst_Y, 20 );
	{
		PWALL pWall = GetSetMember( WALL, &world->walls, pSector->iWall );
		SrvrCreateWall( client_id, iWorld, iSector
					 , pWall->iWallStart, TRUE
					 , pWall->iWallEnd, TRUE, o, n );
	}
	//ComputeSectorPointList( iWorld, iSector, NULL );
	//ComputeSectorOrigin( iWorld, iSector );
#ifdef OUTPUT_TO_VIRTUALITY
	OrderObjectLines( world->object );
#endif
	SetPoint( pSector->r.n, VectorConst_Y );
	//DumpWall( pSector->wall );
	//DumpWall( pSector->wall->wall_at_start );
	//DumpWall( pSector->wall->wall_at_end );
	//DumpWall( pSector->wall->wall_at_start->wall_at_end );
	{
		INDEX texture = SrvrMakeTexture( client_id, iWorld, SrvrMakeName( client_id, iWorld, WIDE( "Default" ) ) );
		PFLATLAND_TEXTURE pTexture = GetSetMember( FLATLAND_TEXTURE, &world->textures, texture );
		if( !pTexture->flags.bColor )
			SrvrSetSolidColor( client_id, iWorld, texture, AColor( 170, 170, 170, 0x80 ) );
		SrvrSetTexture( client_id, iWorld, iSector, texture );
	}
#ifdef WORLDSCAPE_SERVER
	/* this doesn't exist in direct library */
	MarkSectorUpdated( client_id, iWorld, iSector );
#endif
	return iSector;
}
コード例 #14
0
void AColorDialogForm::OnColorSelectorPaint(AObject* pSender,AEvent* pEvent)
{
	AVertSlide* pColorSelector = GetColorSelector();
	ARect rx = pColorSelector->GetAbsPosition();
	ACanvas* cs = GetUICore()->GetCanvas();

	rx.Deflate(7,5,7,5);

	
	cs->SetSmoothingMode(SmoothingModeNone);
	float delta = 255.0/60.0;
	for(int i=0;i<360;)
	{
		BYTE r,g,b;
		if( i < 60 )//ºì -> ÂÌ
		{
			r = 255; g = 0; b = 0;
			g += delta * (i-0);
		}
		else if( i < 120 )//ºì -> ÂÌ
		{
			r = 255; g = 255; b = 0;
			r -= delta * (i-60);
		}
		else if( i < 180 )//ÂÌ -> À¶
		{
			r = 0; g = 255; b=0;
			b += delta * (i-120);
		}
		else if( i < 240 )//ÂÌ -> À¶
		{
			r = 0; g = 255; b = 255;
			g -= delta * (i-180);
		}
		else if( i < 300 )//À¶ -> ºì
		{
			r = 0; g = 0; b = 255;
			r += delta * (i - 240);
		}
		else//À¶ -> ºì
		{
			r = 255; g = 0; b = 255;
			b -= delta * (i-300);
		}

		APen pen;
		pen.SetWidth(1);
		pen.SetColor(AColor(255,r,g,b));

		i += 2;

		cs->Use(&pen)->DrawLine( APoint(rx.left,rx.bottom-i/2),APoint(rx.right,rx.bottom-i/2) );
	}
	int iPosition = pColorSelector->GetPosition();
	int y = rx.top + rx.GetHeight() * iPosition / pColorSelector->GetRange();
	APoint pt1,pt2,pt3;
	ASolidBrush br;
	br.SetColor(AApplication::Get()->GetCurSkin()->m_BorderColor );

	pt1 = APoint(rx.left-5,y-5);
	pt2 = APoint(rx.left-5,y+5);
	pt3 = APoint(rx.left,y);
	cs->Use(&br)->FillTrigle(pt1,pt2,pt3);

	pt1 = APoint(rx.right-1,y);
	pt2 = APoint(rx.right-1+6,y-5);
	pt3 = APoint(rx.right-1+6,y+5);
	
	cs->Use(&br)->FillTrigle(pt1,pt2,pt3);

	cs->SetSmoothingMode(SmoothingModeAntiAlias);
}
コード例 #15
0
ファイル: PainterTextureSample.cpp プロジェクト: 2asoft/xray
AColor PainterTextureSample::EvalColor(ShadeContext& sc)
{
	//TODO: Evaluate the color of texture map for the context.
	return AColor (0.0f,0.0f,0.0f,0.0f);
}
コード例 #16
0
ファイル: plStaticEnvLayer.cpp プロジェクト: Asteral/Plasma
AColor plStaticEnvLayer::EvalColor(ShadeContext& sc)
{
    if (!sc.doMaps) 
        return AColor(0.0f, 0.0f, 0.0f, 1.0f);

    AColor color;
    if (sc.GetCache(this, color)) 
        return color;

    if (gbufID) 
        sc.SetGBufferID(gbufID);

    // Evaluate the Bitmap

//  Point3  v = sc.VectorTo( sc.V(), REF_OBJECT );//WORLD );
    Point3  v = sc.VectorTo( sc.Normal(), REF_OBJECT );
    float   wx,wy,wz;
    Color   rcol;
    Bitmap  *refmap = NULL;
    Point3  rv;
    Point2  uv;
    int     size;

    wx = (float)fabs( v.x );  
    wy = (float)fabs( v.y );
    wz = (float)fabs( v.z ); 
    if( wx >= wy && wx >= wz )
    {
        if( v.x < 0 )
        {
            refmap = fBitmaps[ kLeftFace ];
            uv = CompUV( -v.y, -v.z,  v.x );
        }
        else
        {
            refmap = fBitmaps[ kRightFace ];
            uv = CompUV( v.y, -v.z, -v.x );
        }
    }
    else if( wy >= wx && wy >= wz ) 
    {
        if( v.y > 0 )
        {
            refmap = fBitmaps[ kBackFace ];
            uv = CompUV( -v.x, -v.z, -v.y );
        }
        else
        {
            refmap = fBitmaps[ kFrontFace ];
            uv = CompUV(  v.x, -v.z,  v.y );
        }
    }
    else if( wz >= wx && wz >= wy ) 
    {
        if( v.z < 0 )
        {   
            refmap = fBitmaps[ kBottomFace ];
            uv = CompUV( -v.x, -v.y,  v.z );
        }
        else     
        {   
            refmap = fBitmaps[ kTopFace ];
            uv = CompUV( -v.x,  v.y, -v.z );
        }
    }

    if( refmap == NULL )
        color.White();
    else
    {
        if( uv.x < 0.0f )
            uv.x = 0.0f; 
        else if( uv.x > 1.0f )
            uv.x = 1.0f;
        if( uv.y < 0.0f )
            uv.y = 0.0f; 
        else if( uv.y > 1.0f )
            uv.y = 1.0f;
        size = refmap->Width();
        int x = (int)( uv.x * (float)( size - 1 ) );
        int y = (int)( ( 1.0f - uv.y ) * (float)( size - 1 ) );

        BMM_Color_64 c;
        refmap->GetLinearPixels( x, y, 1, &c );
        color = AColor( c.r / 65535.f, c.g / 65535.f, c.b / 65535.f, c.a / 65535.f );
    }

    // Invert color if specified
    if( fBitmapPB->GetInt( kBmpInvertColor ) )
    {
        color.r = 1.0f - color.r;
        color.g = 1.0f - color.g;
        color.b = 1.0f - color.b;
    }
    // Discard color if specified
    if( fBitmapPB->GetInt( kBmpDiscardColor ) )
        color.r = color.g = color.b = 1.0f;

    // Invert alpha if specified
    if( fBitmapPB->GetInt( kBmpInvertAlpha ) )
        color.a = 1.0f - color.a;
    // Discard alpha if specified
    if( fBitmapPB->GetInt( kBmpDiscardAlpha ) )
        color.a = 1.0f;

    // If RGB output is set to alpha, show RGB as grayscale of the alpha
    if( fBitmapPB->GetInt( kBmpRGBOutput ) == 1 )
        color = AColor( color.a, color.a, color.a, 1.0f );

    sc.PutCache(this, color); 
    return color;
}
コード例 #17
0
				L"<c type=@Label@ tx=@%@ l=@354@ t=@20@ w=@12@ h=@12@ />"
				L"<c type=@Label@ tx=@%@ l=@354@ t=@40@ w=@12@ h=@12@ />"
			L"</children>"
		L"</c>"
	L"</children>"
	L"</c>"
	;

//---------- »ù±¾ÑÕÉ«±í
typedef struct _ColorEntry
{
	ACHAR* szName;
	AColor cr;
}TColorEntry;
TColorEntry g_ColorEntrys[]={
	{ _T("ºÚÉ«"),AColor(255,0,0,0)},		{ _T("×ØÉ«"),AColor(255,0x99,0x33,0)},
	{ _T("éÏé­ÂÌ"),AColor(255,0x33,0x33,0)},	{ _T("ÉîÂÌ"),AColor(255,0,0x33,0)},
	{ _T("ÉîºþÉ«"),AColor(255,0,0x33,0x66)},	{ _T("ÉîÀ¶"),AColor(255,0,0,0x80)},
	{ _T("µåÇà"),AColor(255,0x33,0x33,0x99)},	{ _T("80%»Ò"),AColor(255,0x33,0x33,0x33)},

	{ _T("Éîºì"),AColor(255,0x80,0,0)},		{ _T("³ÈÉ«"),AColor(255,0xFF,0x66,0)},
	{ _T("Éî»Æ"),AColor(255,0x80,0x80,0)},		{ _T("ÂÌÉ«"),AColor(255,0,0x80,0)},
	{ _T("ºþÉ«"),AColor(255,0,0x80,0x80)},		{ _T("À¶É«"),AColor(255,0,0,0xFF)},
	{ _T("»ÒÀ¶"),AColor(255,0x66,0x66,0x99)},	{ _T("50%»Ò"),AColor(255,0x80,0x80,0x80)},

	{ _T("ºìÉ«"),AColor(255,0xFF,0,0)},		{ _T("dz³È"),AColor(255,0xFF,0x99,0)},
	{ _T("ʯ»Ò"),AColor(255,0x99,0xcc,0)},		{ _T("º£ÂÌ"),AColor(255,0x33,0x99,0x66)},
	{ _T("Ë®ÂÌ"),AColor(255,0x33,0xcc,0xcc)},	{ _T("dzÀ¶"),AColor(255,0x33,0x66,0xff)},
	{ _T("×ÏÂÞÀ¼"),AColor(255,0x80,0,0x80)},	{ _T("40%»Ò"),AColor(255,0x96,0x96,0x96)},

	{ _T("·Ûºì"),AColor(255,0xff,0,0xff)},		{ _T("½ðÉ«"),AColor(255,0xff,0xcc,0)},
コード例 #18
0
ファイル: anglectrl.cpp プロジェクト: artemeliy/inf4715
// ============================================================================
Value* AngleControl::get_property(Value** arg_list, int count)
{
   Value* prop = arg_list[0];

   if(prop == n_diameter ||
      prop == n_width ||
      prop == n_height)
   {
      if(parent_rollout && parent_rollout->page)
         return Integer::intern(GetDiameter());
      else
         return &undefined;
   }
   else if(prop == n_degrees)
   {
      if(parent_rollout && parent_rollout->page)
         return Float::intern(GetDegrees());
      else
         return &undefined;
   }
   else if(prop == n_radians)
   {
      if(parent_rollout && parent_rollout->page)
         return Float::intern(GetRadians());
      else
         return &undefined;
   }
   else if (prop == n_range)
   {
      if(parent_rollout && parent_rollout->page)
         return new Point3Value (m_min, m_max, GetDegrees());
   }
   else if(prop == n_startDegrees)
   {
      if(parent_rollout && parent_rollout->page)
         return Float::intern(GetStartDegrees());
      else
         return &undefined;
   }
   else if(prop == n_startRadians)
   {
      if(parent_rollout && parent_rollout->page)
         return Float::intern(GetStartRadians());
      else
         return &undefined;
   }
   else if(prop == n_dir)
   {
      if(parent_rollout && parent_rollout->page)
         return m_dirCCW ? n_CCW : n_CW;
      else
         return &undefined;
   }
   else if(prop == n_color)
   {
      if(parent_rollout && parent_rollout->page)
         return ColorValue::intern(AColor(m_color));
      else
         return &undefined;
   }
   else if(prop == n_bitmap)
      return m_maxBitMap ? (Value*)m_maxBitMap : &undefined;

   return RolloutControl::get_property(arg_list, count);
}
コード例 #19
0
ファイル: value.cpp プロジェクト: Ehnonymoose/MSE
	virtual AColor toColor()  const { return AColor(0,0,0,0); }
コード例 #20
0
ファイル: SampleShaderPlugin.cpp プロジェクト: 2asoft/xray
AColor SampleShaderPlugin::EvalColor(ShadeContext& sc)
{
	//TODO: Evaluate the color of texture map for the context.
	return AColor (0.0f,0.0f,0.0f,0.0f);
}
コード例 #21
0
ファイル: CrackVisualizer.cpp プロジェクト: skydave/thesis
AColor CrackVisualizer::EvalColor(ShadeContext& sc)
{
	if (gbufID) sc.SetGBufferID(gbufID);

	float dist = pblock->GetFloat( pb_spin, sc.CurTime() )*0.1f;
	float distSquared = dist*dist;
	float minDist = 9999999999999999999.0f;

	// we must be sure that minDist is a value greater than dist
	// ...

	//AColor edgeColor = AColor (1.0f,0.0f,0.0f,1.0f);
	AColor edgeColor = pblock->GetAColor( pb_color, sc.CurTime() );
	edgeColor.a = 1.0f;
	


	int nodeID = sc.NodeID();

	if( !sc.globContext )
		return AColor (0.0f,0.0f,0.0f,0.0f);

	RenderInstance* inst = sc.globContext->GetRenderInstance(nodeID);
	if( (inst==NULL) || (inst->mesh==NULL) || NULL == inst->mesh->faces || inst->mesh->getNumFaces() <= sc.FaceNumber() )
	{
		return AColor (0.0f,0.0f,0.0f,0.0f);
	} 

	// if an entry for the current nodeID doesnt exist 
	if( adjBoundaryEdges.find( nodeID ) == adjBoundaryEdges.end() )
		// build the table
		findAdjBoundaryEdges( nodeID, inst );

	int faceIndex = sc.FaceNumber();
	Face& f = inst->mesh->faces[faceIndex];

	// compute Position of p
	Point3 bary = sc.BarycentricCoords();
	Point3 p = bary[0]*inst->mesh->getVert(f.getVert(0)) + bary[1]*inst->mesh->getVert(f.getVert(1)) + bary[2]*inst->mesh->getVert(f.getVert(2));


	// p is not close to any boundary edge
	// check if p close to any vertex which neighbours a boundaryedge from another triangle
	for( int i=0; i<3; ++i )
	{
		// if wireframe
		if(0)
		{
			DWORD edgeIdx = f.GetEdgeIndex( f.getVert(i), f.getVert((i+1)%3) );

			// get vertex positions
			Point3 v0 = inst->mesh->getVert(f.getVert(i));
			Point3 v1 = inst->mesh->getVert(f.getVert(i+1)%3);

			// compute distance p <-> edge v0, v1
			//float edgeDistance = distancePointLine( p, v0, v1 );
			float edgeDistance = Dist3DPtToLine( &p, &v0, &v1 );
			edgeDistance = edgeDistance*edgeDistance;

			// if distance of p is closer then 1/10 of the distance of v2 to that edge
			if( edgeDistance < minDist )
				minDist = edgeDistance;
		}

		// if there is any incident boundary edge to the current vertex, than we know that it is a
		// boundary vertex
		if( !adjBoundaryEdges[nodeID][f.getVert(i)].empty() )
		{
			// current vertex is a boundary vertex
			// comute distance of p to that vertex
			float vertexDistance = (inst->mesh->getVert( f.getVert(i) ) - p).LengthSquared();

			if( vertexDistance < minDist )
				minDist = vertexDistance;

			// check all boundary edges which are adjacent to the vertex and may
			// come from other faces
			for( int j = 0; j<adjBoundaryEdges[nodeID][f.getVert(i)].size(); ++j  )
			{
				// compute distance to that edge
				Point3 v0 = inst->mesh->getVert( adjBoundaryEdges[nodeID][f.getVert(i)][j].first );
				Point3 v1 = inst->mesh->getVert( adjBoundaryEdges[nodeID][f.getVert(i)][j].second );

				// compute dotproduct
				Point3 vec = p - v0;
				Point3 direction = Normalize( v1 - v0 );
				float maxLength = Length( v1 - v0 );

				float dp = DotProd( vec, direction  );

				if( (dp<0.0f)||(dp>maxLength) )
					continue;

				float edgeDistance = LengthSquared( vec - dp*direction );

				if( edgeDistance < minDist )
					minDist = edgeDistance;
			}
		}
	}

	if( minDist < distSquared )
		return edgeColor;


	return AColor (0.0f,0.0f,0.0f,0.0f);}