transparent mesh

7 views
Skip to first unread message

Vamsi Krishna

unread,
Oct 1, 2009, 12:27:13 AM10/1/09
to G3D Users
Hi all,

I've been trying to set a mesh transparent (rather translucent). Here
is the scenario:
I've two different meshes, one lying inside the other. I want to set
the outer mesh transparent, and inner one opaque.

I've tried various versions by modifying the below mentioned code. Can
you please help me out with this? I'm having this code inside a render
() function which loops continuously.


// inner mesh
rd->pushState();
//rd->setBlendFunc(G3D::RenderDevice::BLEND_ONE,
G3D::RenderDevice::BLEND_ZERO, G3D::RenderDevice::BLENDEQ_ADD);
rd->setObjectToWorldMatrix(_virtualToRoomSpace * CoordinateFrame
(Vector3(0,0,-5)) * cfRight[loopVar]);
inner_mesh->draw(rd);
rd->popState();

//outer mesh
rd->pushState();
//setting the alpha value for transparent effect
rd->setBlendFunc(G3D::RenderDevice::BLEND_SRC_ALPHA,
G3D::RenderDevice::BLEND_ONE_MINUS_SRC_ALPHA,
G3D::RenderDevice::BLENDEQ_ADD);
rd->setObjectToWorldMatrix(_virtualToRoomSpace * CoordinateFrame
(Vector3(0,0,-5)) );
outermesh->draw(rd);
//resetting back
rd->setBlendFunc(G3D::RenderDevice::BLEND_ONE,
G3D::RenderDevice::BLEND_ZERO, G3D::RenderDevice::BLENDEQ_ADD);
rd->popState();



Thanks,
Vamsi

Morgan McGuire

unread,
Oct 1, 2009, 6:50:33 AM10/1/09
to g3d-...@googlegroups.com
Set rd->setDepthWrite(false), otherwise the inner mesh will poke a hole in the outer one where they overlap in screenspace.

-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan
Reply all
Reply to author
Forward
0 new messages