Transparent blitting

Started by ErDetEnAnd?, December 22, 2008, 04:18:33 PM

Previous topic - Next topic

EgonOlsen

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... ???

ErDetEnAnd?

#16
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.

EgonOlsen

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... ;)

ErDetEnAnd?

Np.

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

EgonOlsen

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...

EgonOlsen


paulscode

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.

ErDetEnAnd?

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

paulscode

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!

EgonOlsen

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.

EgonOlsen

Quote from: paulscode 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.

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... ;)

paulscode

Quote from: EgonOlsen on December 30, 2008, 02:22:18 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:

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


(the createGlow method for reference)
    // 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.