Synchronizing of xith3d and odejava objects

Hi

I came across having objects whose render-geometry is different from the bounds, because the bounds are much simpler. Because of these differences, the Positions of the objects weren’t the same any more (espascially when having more xith-objects for one Odejava object), so I wasn’t able to use Xith3DDisplayObject, so I wrote my own DisplayTransformable, which manages exactly that.

Is anybody interested in that code?

Yes, I’m interested.
I would include it in Gamma.
Request the Developer role in Gamma and I will approve it ASAP so you can apport your contributions ( if you want, of course ).

http://gamma.dev.java.net

I requested Developer role now, lets see …
BTW Is there already content added to the cvs? … it looks so empty

If anybody else is interested I could put a link here too, but I think it’s better when such stuff is all at one place together.

Can you use Xith3DDisplayObject if you encapsulate your geometry in a TG which moves it into the correct position?

That’s what I do and it works well. Perhaps your method may save a few matrix calculations though?

Please post the code, I’m interested in seeing it.

Will.

It’s actually not much(It’s what a transformGroup would be doing anyways), so here is it:


public class DisplaySync implements DisplayTransformable {
    Matrix4f diff;
    Matrix4f temp;
    TransformGroup g;
    Transform3D t;
    /** Creates a new instance of DisplaySync */
    public DisplaySync(TransformGroup g, Placeable p) {
        this.g = g;
        t = g.getTransform();
        diff = new Matrix4f();
        temp = new Matrix4f();
        t.get(temp);
        //GeomTransform's Quaternion  doesn't initialize correctly -  so something special here
        if(p instanceof GeomTransform) {
            diff = new Matrix4f();
            ((GeomTransform) p).getTransform(diff);
        }
        else diff.set(p.getQuaternion(), p.getPosition(),1);
        diff.invert();
        diff.mul(temp);
    }

    public void setTransform(Vector3f position, Quat4f quaternion) {
        temp.set(quaternion, position, 1);
        temp.mul(diff);
        t.set(temp);
        g.setTransform(t);
    }
    
}

So is this better than encapsulating the geom inside a TG with the offset?

Will.

yeah - I’d say so, cause you don’t have to create a new tg. And people without very much Matrix knowledge could get proplems there. Please note, that the GeomTransform “Bug” is also work-rounded, here. From the performance side, I think there is no difference.