예제 #1
0
 void SetString(int row, int column, const ZString& str)
 {
     if (m_vvstr.Get(row).Get(column) != str) {
         m_vvstr.Get(row).Set(column, str);
         Changed();
     }
 }
예제 #2
0
 void SetColor(int row, const Color& color)
 {
     if (m_vcolor.Get(row) != color) {
         m_vcolor.Set(row, color);
         Changed();
     }
 }
예제 #3
0
    void AddExplosion(
        const Vector&                 position,
        const Vector&                 forward,
        const Vector&                 right,
        const Vector&                 dposition,
		float                         radiusExplosion,
        float                         radiusShockWave,
        const Color&                  color,
        int                           countDecals,
        TVector<TRef<AnimatedImage> > vpimage,
        Image*                        pimageShockwave
    ) {
        //
        // Add the shockwave
        //

		if (pimageShockwave != NULL) {
			m_listShockwave.PushFront();
			ShockwaveData& sdata = m_listShockwave.GetFront();

			sdata.m_timeStart       = GetTime()->GetValue();
			sdata.m_pimageShockwave = pimageShockwave;
			sdata.m_color           = color;
			sdata.m_position        = position;
			sdata.m_dposition       = dposition;
			sdata.m_scale           = radiusShockWave;
			sdata.m_forward         = forward;
			sdata.m_right           = right;
		}

        //
        // Add the little explosions
        //

        int countImage = vpimage.GetCount();
        int indexImage = 0;

        for (int index = 0; index < countDecals; index++) {
            ExplosionDataList& list  = m_vlistExplosion.Get(index);
            list.PushFront();
            ExplosionData&     edata = list.GetFront();

            edata.m_timeStart = GetTime()->GetValue() + index * 0.25f;
            edata.m_pimage    = vpimage[indexImage];
            edata.m_position  = position + Vector::RandomPosition(radiusExplosion * 0.5f);
            edata.m_dposition = dposition;
            edata.m_angle     = random(0, 2 * pi);
            edata.m_scale     = radiusExplosion;

            indexImage++;
            if (indexImage >= countImage) {
                indexImage = 0;
            }
        }
    }
예제 #4
0
    void SetSize(int rows, int columns)
    {
        m_vvstr.SetCount(rows);
        m_vcolor.SetCount(rows);
        m_vColumn.SetCount(columns);

        for (int index = 0; index < rows; index++) {
            m_vvstr.Get(index).SetCount(columns);
        }

        Changed();
    }
예제 #5
0
    StringGridImageImpl(int columns, int rows, IEngineFont* pfont) :
        m_pfont(pfont),
        m_vvstr(rows),
        m_vcolor(rows),
        m_vColumn(columns)
    {
        for (int index = 0; index < rows; index++) {
            m_vvstr.Get(index).SetCount(columns);
        }

        m_ysizeRow = (float)(m_pfont->GetTextExtent("W").Y());
    }
예제 #6
0
    void Render(Context* pcontext)
    {
        float fill = 0;
        
        fill += RenderShockwaves(pcontext);

        int count = m_vlistExplosion.GetCount();

        for (int index = 0; index < count; index++) {
            fill += RenderExplosions(pcontext, m_vlistExplosion.Get(index));

            //
            // If we have passed the fill limit throw away the rest of the explosions
            //

            if (fill > 2.0f) {
                for (int index2 = index + 1; index2 < count; index2++) {
                    m_vlistExplosion.Get(index2).SetEmpty();
                }
                return;
            }
        }
    }
    void SetCount(unsigned int seed, short count)
    {
        count = count * 4;
        m_data.SetCount(count);

        srand(seed);

        for (int index = 0; index < count; index++) {
            //
            // Allocate star positions with a nice uniform density
            //

            StarData& data = m_data.Get(index);

            data.m_direction = Vector::RandomDirection();
            data.m_bFirstFrame = true;

            float bright = random(0.25f, 1);

            data.m_color = Color(bright, bright, bright);
        }
    }
    void Render(Context* pcontext)
    {
        int count = m_data.GetCount();

        if (count > 0) {
                  Camera* pcamera = GetCamera();
                  float   focus   = pcamera->GetFocus();
            const Rect&   rect    = GetViewRect()->GetValue();

            float scale = focus * rect.XSize() / 2;
            float xc    = rect.Center().X();
            float yc    = rect.Center().Y();

            const Orientation& orient = GetCamera()->GetOrientation();

            VertexScreen* pvertex = pcontext->GetVertexScreenBuffer(count * 2);
            WORD*         pindex  = pcontext->GetIndexBuffer(count * 2);

            int index      = 0;
            int indexPoint = count * 2;
            for(int indexSource = 0; indexSource < count; indexSource++) {
                StarData& data      = m_data.Get(indexSource);
                Color&    color     = data.m_color;
                Vector&   direction = data.m_direction;
                Point&    pointOld  = data.m_pointOld;

                //
                // orient the start based on the current camera
                //

                Vector vec = orient.TimesInverse(direction);

                //
                // fold up the stars for higher density
                //

                if (vec.z > 0) {
                    vec.SetX(-vec.X());
                    vec.SetY(-vec.Y());
                    vec.SetZ(-vec.Z());
                }

                //
                // project the star onto the screen
                //

                float x = (float)(int)(scale * vec.X() + xc);
                float y = (float)(int)(yc - scale * vec.Y());
                float xold;
                float yold;

                if (data.m_bFirstFrame) {
                    xold = x;
                    yold = y;
                    data.m_bFirstFrame = false;
                } else {
                    xold = pointOld.X();
                    yold = pointOld.Y();
                }

                if (rect.Inside(Point(x, y))) {
                    float dx     = abs(x - xold);
                    float dy     = abs(y - yold);
                    float length = dx + dy;

                    if (length <= 1.0f) {
                        //
                        // Draw a point
                        //

                        indexPoint--;
                        pvertex[indexPoint].x        = x;
                        pvertex[indexPoint].y        = y;
                        pvertex[indexPoint].z        = 0;
                        pvertex[indexPoint].qw       = (float)1.0f/10000.0f;
                        pvertex[indexPoint].color    = MakeD3DCOLOR(color);
                        pvertex[indexPoint].specular = 0;
                    } else {
                        //
                        // Draw a line
                        //

                        if (length > 16.0f) {
                            float scale = 16.0f / length;

                            xold = x + (xold - x) * scale;
                            yold = y + (yold - y) * scale;
                        }

                        if (rect.Inside(Point(xold, yold))) {
                            float alpha  = 1.0f - 0.1f * length;

                            if (alpha < 0.25f) {
                                alpha = 0.25f;
                            }

                            pvertex[index * 2].x        = x;
                            pvertex[index * 2].y        = y;
                            pvertex[index * 2].z        = 0;
                            pvertex[index * 2].qw       = (float)1.0f/10000.0f;
                            pvertex[index * 2].color    = MakeD3DCOLOR(color * alpha);
                            pvertex[index * 2].specular = 0;

                            pvertex[index * 2 + 1].x        = xold;
                            pvertex[index * 2 + 1].y        = yold;
                            pvertex[index * 2 + 1].z        = 0;
                            pvertex[index * 2 + 1].qw       =(float)1.0f/10000.0f;
                            pvertex[index * 2 + 1].color    = MakeD3DCOLOR(color * alpha);
                            pvertex[index * 2 + 1].specular = 0;

                            pindex[index * 2    ] = index * 2;
                            pindex[index * 2 + 1] = index * 2 + 1;

                            index += 1;
                        }
                    }
                }

                pointOld.SetX(x);
                pointOld.SetY(y);
            };

            //
            // Do the rendering
            //

            pcontext->SetShadeMode(ShadeModeFlat);
            pcontext->DrawPoints(pvertex + indexPoint, count * 2 - indexPoint);

            if (index != 0) 
			{
                pcontext->SetBlendMode(BlendModeAdd);
                pcontext->DrawLines(pvertex, index * 2, pindex, index * 2);
            }
        }
    }
예제 #9
0
	IDirect3DTextureX* GetTextureX(PixelFormat*	ppf, const WinPoint& size, int&	id)
	{
		id = m_data.m_id;

		// Return the fullsize surface if that's what's	wanted.
		if (size ==	m_size)	
		{
			if (ppf	== m_data.m_ppf) 
			{
				SetSurfaceMode(SurfaceModeDD);
				return m_data.m_pd3dtexture;
			}

			UpdateConvertedSurface(ppf,	m_size,	m_dataConverted, m_data);
			return m_dataConverted.m_pd3dtexture;
		}

		// Need	to return a	lower level	of detail
		int	index =	0;
		WinPoint sizeSource	= m_size;

		while (true) {
			sizeSource.SetX(sizeSource.X() / 2);
			sizeSource.SetY(sizeSource.Y() / 2);

			//
			// Do we need to allocate a	new	lower level	of detail?
			//

			if (index == m_datas.GetCount()) {
				m_datas.PushEnd();
				m_datasConverted.PushEnd();
				ConstructSurfaceData(m_datas.Get(index), m_data.m_ppf, sizeSource);
			}

			// Do we need to update	this level?
			if (m_datas[index].m_id	!= m_data.m_id)	
			{
				_ASSERT( false );
/*				DownSample(
					sizeSource,
					m_datas[index].m_pdds,
					index == 0 ?
						  m_data.m_pdds
						: m_datas[index	- 1].m_pdds
				);

				m_datas.Get(index).m_id	= m_data.m_id;*/
			}

			// Did we find the right size?
			if (sizeSource == size)	
			{
				// Does	the	format need	to be converted?
				if (ppf	== m_data.m_ppf) 
				{
					return m_datas[index].m_pd3dtexture;
				} 
				else 
				{
					UpdateConvertedSurface(ppf,	size, m_datasConverted.Get(index), m_datas[index]);
					return m_datasConverted[index].m_pd3dtexture;
				}
			}

			index++;
		}
	}