Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest WME version: WME 1.9.1 (January 1st, 2010) - download

Author Topic: Actor3DX.AlphaColor  (Read 5157 times)

0 Members and 1 Guest are viewing this topic.

mRax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 55
    • View Profile
Actor3DX.AlphaColor
« on: July 23, 2009, 09:16:11 AM »

It looks like .AlphaColor property hasn't effect on Actor3DX-type objects. Is there some reason for such thing? ??? (The property worked with Actor2D...)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Actor3DX.AlphaColor
« Reply #1 on: July 25, 2009, 06:05:43 PM »

It is expected behavior, because AlphaColor is not used by 3D characters. I guess it could override vertex colors or material color or something, but it's not implemented.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

mRax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 55
    • View Profile
Re: Actor3DX.AlphaColor
« Reply #2 on: July 27, 2009, 08:51:10 AM »

I guess it could override vertex colors or material color

That`s the point! Thanks for idea; maybe I'll try it :)
Logged

mRax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 55
    • View Profile
Re: Actor3DX.AlphaColor
« Reply #3 on: September 14, 2009, 08:41:24 AM »

I tried take advantage of material diffuse color. In CXModel::Render after
Code: [Select]
Rend->m_Device->SetRenderState(D3DRS_COLORVERTEX, FALSE);I set
Code: [Select]
Rend->m_Device->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);and in CXMesh::Render before .SetMaterial method set (for testing purposes)
Code: [Select]
Mat->m_Material.Diffuse.a = 0.5f;
Mat->m_Material.Diffuse.r = 0.0f;
Mat->m_Material.Diffuse.g = 1.0f;
Mat->m_Material.Diffuse.b = 0.0f;
The results were successfull partially: all Actor3DX became green (yes!) but not half-transparent (no-o!).

So does somebody have ideas what should be done here more? (this topic must be moved to the childboard about WME sources, I guess)
Logged

mRax

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Posts: 55
    • View Profile
Re: Actor3DX.AlphaColor
« Reply #4 on: October 07, 2009, 08:56:02 AM »

P.S. The goal has been reached.

Here is key steps.

1) In CBRenderD3D::Setup3D method line
Code: [Select]
C3DUtils::SetTextureStageState(m_Device, 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);was changed to next one
Code: [Select]
C3DUtils::SetTextureStageState(m_Device, 0, D3DTSS_ALPHAOP, D3DTOP_BLENDDIFFUSEALPHA);
2) In CXMesh::Render method before SetMaterial call there were added the block
Code: [Select]
D3DMATERIAL m_Material = Mat->m_Material;
if(m_AlphaColor!=0)
{
  if(D3DCOLGetR(m_AlphaColor)!=0)m_Material.Diffuse.r = m_Material.Diffuse.r*((float)(D3DCOLGetR(m_AlphaColor)))/255.0f;
  if(D3DCOLGetG(m_AlphaColor)!=0)m_Material.Diffuse.g = m_Material.Diffuse.g*((float)(D3DCOLGetG(m_AlphaColor)))/255.0f;
  if(D3DCOLGetB(m_AlphaColor)!=0)m_Material.Diffuse.b = m_Material.Diffuse.b*((float)(D3DCOLGetB(m_AlphaColor)))/255.0f;
  if(D3DCOLGetA(m_AlphaColor)!=0)m_Material.Diffuse.a = m_Material.Diffuse.a*((float)(D3DCOLGetA(m_AlphaColor)))/255.0f;
}

// set material
Rend->m_Device->SetMaterial(&m_Material);//Rend->m_Device->SetMaterial(&Mat->m_Material);

It's working. Although I have intention to use not actor3dx.DrawBackfaces property to cut unnecessary polygons but stencil buffer.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Actor3DX.AlphaColor
« Reply #5 on: October 07, 2009, 03:35:27 PM »

In WME 1.9 you can achieve the effect using shaders.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.08 seconds with 20 queries.