You last visited: Today at 06:12
Advertisement
Textur rund rendern
Discussion on Textur rund rendern within the Flyff Private Server forum part of the Flyff category.
10/15/2012, 22:55
#1
elite*gold: 4
Join Date: Mar 2010
Posts: 3,148
Received Thanks: 1,535
Textur rund rendern
Hi,
ich versuche eine Textur rund zu rendern(sie ist ein großes viereck und ich rendere immer einen bestimmten teil(Ist eine MiniMap))
Ich möchte das aber gerne Rund haben
habe bereits mehreres versucht aber leider kein erfolg.
Hier meine test's
Rundes Rendern
Code:
BOOL C2DRender::RenderTextureCircle( int iVertices, float iRadius, CTexture* pTexture, DWORD dwBlendFactorAlhpa, FLOAT fScaleX , FLOAT fScaleY)
{
if(!pTexture) return FALSE;
int nVertex = iVertices + 1;
TEXTUREVERTEX * pVertices;
pVertices = new TEXTUREVERTEX [nVertex];
FLOAT fComplete;
FLOAT x;
FLOAT y;
FLOAT u;
FLOAT v;
for ( int iVertex = 0; iVertex < nVertex; iVertex ++)
{
fComplete = (float)iVertex / nVertex;
x = (float)((fScaleX) + (float)iRadius * cos(6.2831f*fComplete));
y = (float)((fScaleY) + (float)iRadius * sin(6.2831f*fComplete));
u = x / (sqrt((double) ((int)x^(int)2 + (int)y^(int)2 )));
v = y / (sqrt((double) ((int)x^(int)2 + (int)y^(int)2 )));
SetTextureVertex( pVertices, x, y, u, v);
pVertices++;
}
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB( dwBlendFactorAlhpa, 0, 155, 0 ) );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
//m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_DIFFUSE);
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
m_pd3dDevice->SetVertexShader( NULL );
m_pd3dDevice->SetTexture( 0, pTexture->m_pTexture );
m_pd3dDevice->SetFVF( D3DFVF_TEXTUREVERTEX );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof( TEXTUREVERTEX ) );
m_pd3dDevice->SetTexture( 0, NULL );
return TRUE;
};
Alpha Maske Nr1.
Code:
struct tDXVertexTextureMask
{
float fRHW;
D3DXVECTOR3 vec;
FLOAT x, y, z;
D3DCOLOR color;
FLOAT u1, v1;
FLOAT u2, v2;
};
inline void SettDXVertexTextureMask( tDXVertexTextureMask* pVertices, FLOAT x, FLOAT y, FLOAT u, FLOAT v )
{
pVertices->x = (FLOAT)x - 0.5f;
pVertices->y = (FLOAT)y - 0.5f;
pVertices->z = 0.0f;
pVertices->vec = D3DXVECTOR3( x - 0.5f, y - 0.5f, 0 );
pVertices->fRHW = 1.0f;
pVertices->u1 = u;
pVertices->v1 = v;
pVertices->u2 = u;
pVertices->v2 = v;
pVertices->color = (DWORD)0xffffff;
}
BOOL C2DRender::RenderTextureAlphaMask( CPoint pt, CTexture* pTexture, CTexture* pTexture2, DWORD dwBlendFactorAlhpa, FLOAT fScaleX , FLOAT fScaleY )
{
if( !pTexture ) //gmpbigsun
return FALSE;
if( !pTexture2 )
return FALSE;
pt += m_ptOrigin;
CPoint ptCenter = pTexture->m_ptCenter;
ptCenter.x = (LONG)( ptCenter.x * fScaleX );
ptCenter.y = (LONG)( ptCenter.y * fScaleY );
pt -= ptCenter;
FLOAT left = (FLOAT)( pt.x );
FLOAT top = (FLOAT)( pt.y );
FLOAT right = pt.x + ( fScaleX * pTexture->m_size.cx );
FLOAT bottom = pt.y + ( fScaleY * pTexture->m_size.cy );
tDXVertexTextureMask vertex[ 4 ];
tDXVertexTextureMask* pVertices = vertex;
SettDXVertexTextureMask( pVertices, left, top, pTexture->m_fuLT, pTexture->m_fvLT );
pVertices++;
SettDXVertexTextureMask( pVertices, right, top, pTexture->m_fuRT, pTexture->m_fvRT);
pVertices++;
SettDXVertexTextureMask( pVertices, left, bottom, pTexture->m_fuLB, pTexture->m_fvLB);
pVertices++;
SettDXVertexTextureMask( pVertices, right, bottom, pTexture->m_fuRB, pTexture->m_fvRB);
pVertices++;
////
#define D3DFVF_TEXTURE_MASK (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX2)
m_pd3dDevice->SetFVF(D3DFVF_TEXTURE_MASK);
m_pd3dDevice->SetTexture( 0, pTexture->m_pTexture );
m_pd3dDevice->SetTexture( 1, pTexture2->m_pTexture );
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
m_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
// Use the color from the previous texture, and blend the alpha from the mask.
m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_CURRENT);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
m_pd3dDevice->SetTextureStageState(1, D3DTSS_ALPHAARG2, D3DTA_CURRENT);
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, vertex, sizeof( tDXVertexTextureMask ) );
m_pd3dDevice->SetTexture( 0, NULL );
m_pd3dDevice->SetTexture( 1, NULL );
return TRUE;
}
Alpha Maske Nr2.
Code:
BOOL C2DRender::RenderTextureAlphaMask( CPoint pt, CTexture* pTexture, CTexture* pTexture2, DWORD dwBlendFactorAlhpa, FLOAT fScaleX , FLOAT fScaleY )
{
if( !pTexture ) //gmpbigsun
return FALSE;
if( !pTexture2 )
return FALSE;
pt += m_ptOrigin;
CPoint ptCenter = pTexture->m_ptCenter;
ptCenter.x = (LONG)( ptCenter.x * fScaleX );
ptCenter.y = (LONG)( ptCenter.y * fScaleY );
pt -= ptCenter;
FLOAT left = (FLOAT)( pt.x );
FLOAT top = (FLOAT)( pt.y );
FLOAT right = pt.x + ( fScaleX * pTexture->m_size.cx );
FLOAT bottom = pt.y + ( fScaleY * pTexture->m_size.cy );
tDXVertexTextureMask vertex[ 4 ];
tDXVertexTextureMask* pVertices = vertex;
SettDXVertexTextureMask( pVertices, left, top, pTexture->m_fuLT, pTexture->m_fvLT );
pVertices++;
SettDXVertexTextureMask( pVertices, right, top, pTexture->m_fuRT, pTexture->m_fvRT);
pVertices++;
SettDXVertexTextureMask( pVertices, left, bottom, pTexture->m_fuLB, pTexture->m_fvLB);
pVertices++;
SettDXVertexTextureMask( pVertices, right, bottom, pTexture->m_fuRB, pTexture->m_fvRB);
pVertices++;
////
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetVertexShader( NULL );
m_pd3dDevice->SetTexture( 0, pTexture->m_pTexture );
m_pd3dDevice->SetTexture( 1, pTexture2->m_pTexture );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSU, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_ADDRESSV, 1 );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetFVF( D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1 | D3DFVF_TEX2 );
m_pd3dDevice->SetRenderState( D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB( dwBlendFactorAlhpa, 0, 0, 0 ) );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TFACTOR );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_SELECTARG1 );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_CURRENT );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_MODULATE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
m_pd3dDevice->SetTextureStageState( 1, D3DTSS_ALPHAARG2, D3DTA_CURRENT );
m_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLESTRIP, 2, vertex, sizeof( tDXVertexTextureMask ) );
m_pd3dDevice->SetTexture( 0, NULL );
m_pd3dDevice->SetTexture( 1, NULL );
return TRUE;
}
hoffentlich kann mir einer weiterhelfen
(die alpha mask ist eine textur mit einem alphakreis(der teil soll nur noch am ende gezeigt werden))
Wie ihr euch sicher denken könnt , es ist für die MiniMap.
Hab nicht so viel ahnung von texturstages etc. und mein DX buch ist seeeehr alt und kann mir über dieses Problem keine antwort geben :C
hoffe jemand kann helfen ;D
Similar Threads
rendern
04/17/2012 - elite*gold Trading - 2 Replies
Jo, kann mir vll jmd gaaanz schnell nen Bild rendern ?
gebe 3 Egold (:
http://s7.directupload.net/images/120417/co8tqhgr .jpg
Rendern
01/06/2012 - Off Topic - 2 Replies
http://www.imgbox.de/users/public/images/JPjfZIS12 N.jpg
Könnte mir das bitte einer Rendern :o
Rendern ;)
10/19/2011 - Video Art - 4 Replies
Hy Com,
ehrlich geagt habe ich keine ahnung ob ich hier richtig bin ;)
wen nicht dan entschuldige ich mich
Also ich habe folgendes problem:
Bei meinen videos (die ich von der Ps3 aufgenommen habe) ist immer rechts und link ein schwarzer streifen:
http://www.youtube.com/user/GameMusicGFX?feature= mhee
Meine Frage wie render ich das richtig damit der nicht mehr da ist
ae rendern
02/12/2011 - General Art - 5 Replies
hay ich suche hilfe beim rendern von videos bei After Effects
rendern geht aber nur leider hat das video was ca 10 sek geht 4,33gb speicher
ich habe After Effects cs5
würde mich freun wen mir einer helfen würde
All times are GMT +2. The time now is 06:13 .