Hi,
I would like to change the position of a (Raster) label (by changing Transform3D, see 
method updateLabel() below), but setTransform makes the old label vanish and there is 
no label at the new position.
However, if I detach the Branchgroup, change the transform exactly the same way as 
before, and then add the Branchgroup to its parent again, it works fine. (The label is 
created using the RasterTextLabel class from j3d.org).
As you can see from the submitted "code" the calculation of scale and translate vector 
for Transform3D is exactly the same in the two cases described above (see 
updateTransform3D() method).

Group (parent)
  |
BranchGroup (being detached)
  |
TransformGroup (where I would like to change the
                Transform3D by using setTransform)
  |
RasterTextLabel (Shape3D)


Does anyone know why this happens?

Thanks in advance!

Elisabeth Thorsen

public class test extends Branchgroup {

  blah blah
  ...

  publid test(){
     blah blah blah
     setLabel();
  }

  // this works fine
  private void setLabel() {
            _labelShape =
     new RasterTextLabel(text,Color.white, false, true, x, y, z);
            _transGroup = new TransformGroup();
            _transGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
            _transGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            _transGroup.setTransform(updateTransform3D());
            _transGroup.addChild(_labelShape);
            addChild(_transGroup);
        }
  }


  private void updateLabel(){
        detach(); //  ** if this is commented out setTransform
                  // only makes the label at the old position vanish

        _labelShape.crop();
        _labelShape.getRaster().setPosition(newPosition);
        _labelShape.setText(newText);

        // this has no effect if the branchgroup to which it is
        // attached isn't detached from its parent
        _transGroup.setTransform(updateTransform3D());

       _parent.addChild(this); // see **
  }

  public Transform3D updateTransform3D(){

        Transform3D trans = new Transform3D();
        double dist = (double) newDistance;
        double scale = 0.01d*(dist/7.5d);
        Vector3d tmpVector = new Vector3d();
        tmpVector.set((1.0d-scale)*x,(1.0d-scale)*y,(1.0d-scale)*.z);
        trans.set(scale, tmpVector);
        System.err.println(scale + ", " +tmpVector);
        return trans;
  }

and more methods..

}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to