Author Topic: Transparent blitting  (Read 11897 times)

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent blitting
« Reply #15 on: December 25, 2008, 12:25:41 pm »
I need a simple test case for this, please. I still can't verify it and i don't fully understand your description of the solution... ???

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Re: Transparent blitting
« Reply #16 on: December 25, 2008, 12:48:22 pm »
I'd paste the code if I could, but the project would give too much overhead, so I hope this drawing will do.



Object3D B is a direct successor of Object3D A in both cases, and respectively same for C and B on the left. Object3D C is the billboard. Now my inverted scaling only works if this scaling is done on the direct successor of the previously normally scaled Object3D.

Object B and C are sharing matrices.
« Last Edit: December 25, 2008, 12:50:04 pm by ErDetEnAnd? »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent blitting
« Reply #17 on: December 25, 2008, 01:00:06 pm »
So it seems like it doesn't work if the chain is longer than 2 elements...strange. However, why do B and C share one matrix? Maybe that causes the problem. A bill boarded object usually don't need to share the rotation matrix with another object. What should that be good for? It inherits the global rotation from above anyway and it's own, local rotation doesn't matter, because it's bill boarded.

If it doesn't help to decouple the matrices, i'll try to create a proper test case myself and find what the actual problem is, but that will take some days, because of all the family and christmas-stuff going on right now... ;)

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Re: Transparent blitting
« Reply #18 on: December 25, 2008, 03:20:50 pm »
Np.

I got it wrong. A, B and C each has their own matrices.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent blitting
« Reply #19 on: December 28, 2008, 08:45:14 pm »
Ok, here we go again: http://www.jpct.net/download/beta/jpct.jar

I really hope i got it right this time. I have created myself a test case, i was able to verify the problem, i found a flaw in my calculations, corrected it and my test case works fine now...i hope that your application will do to...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent blitting
« Reply #20 on: December 29, 2008, 08:02:27 pm »
Is it better now?

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Transparent blitting
« Reply #21 on: December 30, 2008, 02:40:03 am »
This may not be related, but when using the above beta version of jPCT, it appears that child billboarded objects have become invisible in a few of my applets.

Here is an example:
Using old jpct.jar
Using beta jpct.jar

Here is the Source Code for this applet.

I haven't pinpointed exactly where this problem is coming from (some billboarded child objects are fine).  I'll tinker around with this some more to see if I can provide more information.

Offline ErDetEnAnd?

  • int
  • **
  • Posts: 87
    • View Profile
Re: Transparent blitting
« Reply #22 on: December 30, 2008, 10:32:03 am »
Mine aren't invisible  ???

It seems to work.

Since children inherits the scale value, its much easier for me to make the child (object c) a child of object a, because it is never scaled. Thanks alot Egon.

I guess finding a solution to the "billboards rotation around its 0;0 problem" harder to solve without help ;). http://www.jpct.net/forum2/index.php/topic,1253.15.html

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Transparent blitting
« Reply #23 on: December 30, 2008, 01:04:38 pm »
A couple quick questions on how this works now (as this will affect how I create complex parent/child relationships).

1) Children inherit scale from their parents now, correct (or am I misreading this topic)?

2) Is the scale inheritance recursive (i.e. a grandchild inherits scale from both the parent and grandparent <asuming parent was further scaled, not just what it inheritied from grandparent>)?

3) This update affects all Object3Ds not just billboarded ones, correct?

4) When loading a model with Loader using a scale value, the resulting Object3D(s) all have an initial scale of 1, correct?

Thanks in advance!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent blitting
« Reply #24 on: December 30, 2008, 01:36:59 pm »
This change only affect bill boarded object. All other should behave as before. To answer your points:

1) Yes. They should have always done this, but is was wrong for bill boards. It hasn't changed for normal objects

2) Yes

3) No, only the bill boarded behaviour has changed. The rest should stay as before, because normal objects inherit the scaling anyway

4) Yes, that's correct. The loader applies a permanent scaling, it has nothing to do with the setScale-scaling.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Transparent blitting
« Reply #25 on: December 30, 2008, 02:22:18 pm »
This may not be related, but when using the above beta version of jPCT, it appears that child billboarded objects have become invisible in a few of my applets.

The old bill boarding code was wrong. Maybe you relied somehow on this wrong behavior. The beta version should behave correctly....i think...bill boarding of scaled childs or bill boarded childs of scaled parents really sucks... ;)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Transparent blitting
« Reply #26 on: December 30, 2008, 10:11:16 pm »
The old bill boarding code was wrong. Maybe you relied somehow on this wrong behavior. The beta version should behave correctly....i think...bill boarding of scaled childs or bill boarded childs of scaled parents really sucks... ;)

I don't think that scaling is causing my problem, unless some code that was added for it changed something else (I only posted it here since the problem seems to have appeared after the scaling bug was fixed).  The Object3Ds in the above applet are created like this:

Code: [Select]
        parent = Object3D.createDummyObj();
        glowObject = createGlow( 8.0f, 3.0f, "Red Glow" );
        world.addObject( glowObject );
       
        parent.addChild( glowObject );

(the createGlow method for reference)
Code: [Select]
    // creates a billboarded glowing object:
    public Object3D createGlow( float offset, float zoffset, String texture )
    {
        Object3D obj = new Object3D( 4 );
       
        obj.addTriangle( new SimpleVector( -offset, -offset, -zoffset ),
                         0, 0,
                         new SimpleVector( -offset, offset, -zoffset ), 0, 1,
                         new SimpleVector( offset, offset, -zoffset ), 1, 1,
                         TextureManager.getInstance().getTextureID( texture ) );
        obj.addTriangle( new SimpleVector( offset, offset, -zoffset ),
                         1, 1,
                         new SimpleVector( offset, -offset, -zoffset ), 1, 0,
                         new SimpleVector( -offset, -offset, -zoffset ), 0, 0,
                         TextureManager.getInstance().getTextureID( texture ) );
        obj.addTriangle( new SimpleVector( offset, offset, zoffset ),
                         1, 1,
                         new SimpleVector( -offset, offset, zoffset ), 0, 1,
                         new SimpleVector( -offset, -offset, zoffset ), 0, 0,
                         TextureManager.getInstance().getTextureID(
                                                              "Transparent" ) );
        obj.addTriangle( new SimpleVector( -offset, -offset, zoffset ),
                         0, 0,
                         new SimpleVector( offset, -offset, zoffset ), 1, 0,
                         new SimpleVector( offset, offset, zoffset ), 1, 1,
                         TextureManager.getInstance().getTextureID(
                                                              "Transparent" ) );
        // Make it billboard:
        obj.setBillboarding( Object3D.BILLBOARDING_ENABLED );
        // Set up the transparency:
        obj.setTransparency( 0 );
        obj.setTransparencyMode( Object3D.TRANSPARENCY_MODE_ADD );
        obj.setLighting( Object3D.LIGHTING_NO_LIGHTS );
        obj.build();
        return obj;
    }

That demo applet is the simplest example I have that experienced the change.  I'll spend a little time on this today to try and create a more basic test case, and I'll post a new thread in the Bugs section, since the problem is not really related to this thread.