You are not logged in.

#1 2011-10-13 09:30:32

mdbrim
Member

3D Transparency issue

So i start in 2d mode and draw a background.

then i go into 3d mode and have a plane that i draw using:

Code:

       GRRLIB_ObjectView(0,3,19.6, 0,0,0, 30.2, 3, 1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 4);
            GX_Position3f32(-1.0f,1.0f,1.0f);
                GX_Color1u32(0x40404044);
            GX_Position3f32(1.0f,1.0f,1.0f);
                GX_Color1u32(0x40404044);
            GX_Position3f32(1.0f,-1.0f,1.0f);
                GX_Color1u32(0x40404044);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
                GX_Color1u32(0x40404044);
        GX_End();

and it has some transparency to it as you can see...

then i draw my 3d dice:

Code:

           GRRLIB_SetTexture(img_grrdice3d,0);    
        grrdice[0] = testdice[0]->draw(0, -.9, 0);
        grrdice[1] = testdice[1]->draw(0, -.9, 1);
        grrdice[2] = testdice[2]->draw(0, -.9, 2);
        grrdice[3] = testdice[3]->draw(0, -.9, 3);
        grrdice[4] = testdice[4]->draw(0, -.9, 4);
        grrdice[5] = testdice[5]->draw(0, -.9, 5);

the background shows up thru the semi transparent plane, but the dice disappear behind it.

the dice are drawn with this (draw portion);

Code:

btQuaternion box::draw(int i, float scladj, float dicecol) {
    btTransform trans;
    m_body->getMotionState()->getWorldTransform(trans);
    btQuaternion test=trans.getRotation();
    btQuaternion john=trans.getRotation();
    GRRLIB_diceView(trans.getOrigin().getX(),trans.getOrigin().getY(),trans.getOrigin().getZ(), test);
    float scl = 1.4+scladj;
    GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0/(scl),1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(0.0/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(-1.0/(scl),-1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(0.1667/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),-1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(0.1667/1.0f,((dicecol+1)*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(0.0/1.0f,((dicecol+1)*1/6)/1.0f);

            GX_Position3f32(-1.0/(scl),1.0/(scl),1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(1.0/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(-1.0/(scl),-1.0/(scl),1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(0.8333/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),-1.0/(scl),1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(0.8333/1.0f,((dicecol+1)*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),1.0/(scl),1.0/(scl));
            GX_Color1u32(col[0]);
                GX_TexCoord2f32(1.0/1.0f,((dicecol+1)*1/6)/1.0f);

            GX_Position3f32(-1.0/(scl),1.0/(scl),1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.333/1.0f,((dicecol+1)*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),1.0/(scl),1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.5/1.0f,((dicecol+1)*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.5/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(-1.0/(scl),1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.333/1.0f,(dicecol*1/6)/1.0f);
                

            GX_Position3f32(-1.0/(scl),-1.0/(scl),1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.5/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),-1.0/(scl),1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.6667/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),-1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.6667/1.0f,((dicecol+1)*1/6)/1.0f);
            GX_Position3f32(-1.0/(scl),-1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[1]);
                GX_TexCoord2f32(0.5/1.0f,((dicecol+1)*1/6)/1.0f);

            GX_Position3f32(-1.0/(scl),1.0/(scl),1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.8333/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(-1.0/(scl),1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.6667/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(-1.0/(scl),-1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.6667/1.0f,((dicecol+1)*1/6)/1.0f);
            GX_Position3f32(-1.0/(scl),-1.0/(scl),1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.8333/1.0f,((dicecol+1)*1/6)/1.0f);

            GX_Position3f32(1.0/(scl),1.0/(scl),1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.1667/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.3333/1.0f,(dicecol*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),-1.0/(scl),-1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.3333/1.0f,((dicecol+1)*1/6)/1.0f);
            GX_Position3f32(1.0/(scl),-1.0/(scl),1.0/(scl));
            GX_Color1u32(col[2]);
                GX_TexCoord2f32(0.1667/1.0f,((dicecol+1)*1/6)/1.0f);
        GX_End();

    return(test);

and the GRRLIB_diceview thing is this:

Code:

void GRRLIB_diceView(f32 posx, f32 posy, f32 posz, btQuaternion q) {
            
   btMatrix3x3 m=btMatrix3x3(q);
   btVector3 r1=m.getRow(0);
   btVector3 r2=m.getRow(1);
   btVector3 r3=m.getRow(2);
   
   Mtx rm,mv;
   guMtxIdentity(rm);
   rm[0][0]=r1.getX();
   rm[0][1]=r1.getY();
   rm[0][2]=r1.getZ();

   rm[1][0]=r2.getX();
   rm[1][1]=r2.getY();
   rm[1][2]=r2.getZ();

   rm[2][0]=r3.getX();
   rm[2][1]=r3.getY();
   rm[2][2]=r3.getZ();
   
   guMtxTransApply(rm, rm, posx,posy,posz);
    guMtxConcat(_GRR_view,rm,mv);
    GX_LoadPosMtxImm(mv, GX_PNMTX0);
}

I had to piece it together like this with the bullet physics engine and i needed the quaternoins so i could read dice position after the roll.  It all works great i just can't see why the dice disappear behind a transparent plane that i can see the background thru!

Anyone see the issue?
Thanks!

Offline

 

#2 2011-10-14 03:23:32

mdbrim
Member

Re: 3D Transparency issue

Based on the freezes i'm getting if i try to move that one transparent plane... if i move it to be drawn AFTER i draw the dice, it freezes... i'm guessing it has something to do with drawing a plane using the GRRLIB_diceView way and drawing it using the GRRLIB_ObjectView method.

If i do an objectview type draw after the diceview i made it freezes and if i do the dice view after the objectview, it doesn't show up thru the transparency.

Thoughts?

Offline

 

#3 2011-10-25 21:53:59

owen
Member

Re: 3D Transparency issue

Transparency has always been strange for me but....

GX will freeze if you try to use the GX_TexCoord2f32 when there is no GRRLIB_SetTexture call before it.  Put the set texture function inside the draw dice function (just for testing).

Also I think the stuff in the 2d mode will always be on top.  Stuff drawn in 3d mode are positioned based on the distance from the camera and do not affect the things you draw in 2d mode.  Make sure the 3d plane is further away from the camera than the dice.

Offline

 

#4 2011-10-26 01:04:51

mdbrim
Member

Re: 3D Transparency issue

thanks for the suggestions owen!

Even if i move the set texture call in the draw dice function, draw the dice, and then draw the wall on top of it, there is still a texture loaded or set... i'll try and mess around with it but i don't know.

The stuff in the 2d mode is behaving fine, it's the dice that don't show up thru the transparency... and it's not an order of drawing thing because the dice DO disappear behind the wall... the problem is they disappear behind the wall even when it is transparent... and i can tell it is transparent because the background shows thru the wall fine...

Offline

 

#5 2011-10-26 14:49:13

owen
Member

Re: 3D Transparency issue

But if you draw something in 2d mode it WILL ALWAYS BE ON TOP OF everything you draw in 3d.  I think anything you draw in 2d more is fixed to the camera at 0,0.  If you want the transparent plain to work you will have to draw everything in 3d mode.  The 2d stuff has no Z.

Offline

 

#6 2011-10-27 02:00:18

mdbrim
Member

Re: 3D Transparency issue

but the stuff i'm drawing in 2d isn't the issue... it is in the background... with no problems.

everything that i am drawing is in 3d... the table, the dice, the walls. It's all 3d.  and the 2d stuff is behind the 3d stuff and causing no problems... it's the 3d stuff that is not playing nice.

I think the issue has to be the fact that the 3d table and walls use a dif draw method than the 3d dice.  they seem to not want to cooperate in the world together.

Offline

 

#7 2011-10-27 05:01:13

owen
Member

Re: 3D Transparency issue

you could try drawing them all in one GX block but it would be tricky at best and a total waste of time.  I don't know, stop doing the transparency thing, lol.  Are write a small test program. 

Maybe you are not setting something in your matrix.  instead of drawing the dice with your function.  draw a cube using the standard grrlib GRRLIB_ObjectView.  If it works then you are missing some kinda tev thing or the other.

Offline

 

Board footer

Powered by FluxBB