Xhizors
Member
|
Blend a mesh.
How can I set alpha value for a mesh for fade out / in effect? I checked the mesh->drawBlended.. in render mode RM_BLEND But no success, Any ideas?
|
|
09-04-2009 10:22 AM |
|
Esenthel
Administrator
|
Re: Blend a mesh.
ive tested this code and it works
Code:
/******************************************************************************/
#include "stdafx.h"
#include "../../resource.h"
/******************************************************************************/
Mesh box,ball;
/******************************************************************************/
void SetShader()
{
box.setShader();
ball.setShader();
}
void InitPre()
{
App.name("Project");
App.icon=(Char*)IDI_ICON1;
App.flag=APP_MEM_LEAKS|APP_FULL_TOGGLE;
D.set_shader=SetShader;
Cam.dist=2;
Cam.pitch=-0.4;
Cam.at.set(0,-2,0);
D.mode(1280,1000);
D.ambPower(0.2);
//D.bloom(0.8,0.6,0.3,false);
D.bumpMode(BUMP_RELIEF).hwDepthBuffer(true);
D.full(1);
}
Bool Init()
{
Material *brick=Materials("mtrl/brick/1.mtrl");
box .create(1).base(0).create(Box (2),VTX_TEX0|VTX_NRM|VTX_TNG).reverse();
ball.create(1).base(0).create(Ball(1),VTX_TEX0|VTX_NRM|VTX_TNG);
box .setMaterial(brick).setRender().setBox();
ball.setMaterial(brick).setRender().setBox();
return true;
}
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
if(Kb.bp(KB_ESC))return false;
CamHandle(0.1f,100,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));
if(Kb.bp(KB_1))D.bumpMode(BUMP_PARALLAX);
if(Kb.bp(KB_2))D.bumpMode(BUMP_RELIEF );
return true;
}
/******************************************************************************/
void Render()
{
switch(Renderer())
{
case RM_SOLID :
case RM_SOLID_M:
case RM_SHD_MAP:
D.wire(Kb.b(KB_TILDE));
box .draw(MatrixIdentity);
//ball.draw(MatrixIdentity);
D.wire(false);
break;
case RM_BLEND:
{
Vec amb=D.ambColor(); D.ambColor(Vec(1));
ball.drawBlended(Sin(Tm.time())*0.5+0.5,MatrixIdentity);
D.ambColor(amb);
}break;
case RM_LIGHT:
LightPoint(5,Vec(0,1,-1)).add();
break;
}
}
void Draw()
{
Renderer(Render);
D.text(0,0.9,S+Tm.fps());
}
/******************************************************************************/
|
|
09-04-2009 10:53 AM |
|
Xhizors
Member
|
Re: Blend a mesh.
I will try it out.
|
|
09-04-2009 12:39 PM |
|
Xhizors
Member
|
Re: Blend a mesh.
I tried this but did not work.
Code:
switch(Renderer())
{
case RM_BLEND:
{
if(mPlayers.elms())
{
mPlayers[0].mesh->drawBlended(Sin(Tm.time())*0.5+0.5,MatrixIdentity);
{
}
}
|
|
09-04-2009 12:53 PM |
|
Esenthel
Administrator
|
Re: Blend a mesh.
did my codes above worked?
|
|
09-04-2009 01:00 PM |
|
Xhizors
Member
|
Re: Blend a mesh.
Esenthel Wrote:did my codes above worked?
Yes that tutorial works just fine, But how about target the player models mesh? the player[0]->mesh, I want to blend that one.
I'll try some more.
|
|
09-04-2009 02:18 PM |
|
Esenthel
Administrator
|
Re: Blend a mesh.
maybe it does work too, but youre also rendering the player with the normal way? rendering it 2 times?
|
|
09-04-2009 02:42 PM |
|
Xhizors
Member
|
Re: Blend a mesh.
Esenthel Wrote:maybe it does work too, but youre also rendering the player with the normal way? rendering it 2 times?
Yes I rendered it 2 times, should I do this render in the extended draw function then for the player?
|
|
09-04-2009 03:02 PM |
|
Esenthel
Administrator
|
Re: Blend a mesh.
when you want to render it using drawblended then dont draw it normally
|
|
09-04-2009 03:10 PM |
|
Xhizors
Member
|
Re: Blend a mesh.
So I will not call the __Super::draw() Instead check for render mode RM_BLEND and call drawBlended?, well I try it out.
|
|
09-04-2009 05:16 PM |
|