Addition to last e-mail:

Also, you can probably set the appearance of each PART of the primitive by
setting the Appearance capability of each part.  (Get the appearance from
getShape(partid) and set the capability bit).  This is only relevant to
primitives with more than one part.  (Sphere have one part - BODY).

Regards,

Andy Phelps

-----Original Message-----
From:   [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]] On Behalf Of Ali Crossley
Sent:   11 June 1999 10:51
To:     [EMAIL PROTECTED]
Subject:        [java3d] Sphere Capabilities

Dear All,

I am still miffed at why I cannot modify the Appearance of the
utils.geometry Sphere class during execution. The CREATE SPHERES section
below shows my basic arrangement for creating a number of Spheres and
setting all capabilities to read and write. The MODIFY COLOUR section is the
method I use to modify the Appearance objects during execution. I keep
getting a

javax.media.j3d.CapabilityNotSetException: Shape3D: no capability to

set appearance
        at javax.media.j3d.Shape3D.setAppearance(Compiled Code)
        at com.sun.j3d.utils.geometry.Sphere.setAppearance(Compiled Code)
        at appearance.ColourSchemeManager.process(Compiled Code)
        at
appearance.AppearanceManager.setColourScheme(AppearanceManager.java:7

exception when calling the MODIFY COLOUR part of the code. Strangely enouogh
if I use the COLORCUBE subclass of SHAPE3D then it all works fine. Is this
somethng to do with Sphere's superclass being PRIMITIVE???

Any help REALLY appreciated.

Cheers,

Allistair Crossley

CREATE SPHERES CODE
----------------------------------------

{
  Atom[] atoms = m.getAtoms();

  boolean renderHeteroAtoms = dOptions.isHeteroAtomsOn();

  TransformGroup aTG = new TransformGroup();
  aTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
  aTG.setCapability(Group.ALLOW_CHILDREN_READ);

  for(int i = 0; i < atoms.length; i++)
  {
   if( (!renderHeteroAtoms) && (atoms[i].isHetatm()) )
    continue;

   Transform3D atomT3D = new Transform3D();
   atomT3D.set(0.1, new Vector3d(atoms[i].getX(), atoms[i].getY(),
atoms[i].getZ()));
   TransformGroup atomTG = new TransformGroup(atomT3D);

   file://atomTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
   atomTG.setCapability(Group.ALLOW_CHILDREN_READ);
   atomTG.setCapability(Group.ALLOW_CHILDREN_WRITE);

   Appearance app = new Appearance();
   Sphere atom = new Sphere(5.0f, app);

   file://Sphere s = new
ere( 
(ElementsManager.getElement(atoms[i].getRefNo()).getVDWRadius()) / 20, 1, 
app);
   file://Shape3D atom = s.getShape();



   atom.setCapability(Group.ALLOW_CHILDREN_READ);
   atom.setCapability(Group.ALLOW_CHILDREN_WRITE);

   atomTG.addChild(atom);
      aTG.addChild(atomTG);
  }

  return aTG;
}

]

MODIFY COLOUR CODE
-------------------------------------

this.molecule = m;

  Atom[] a = molecule.getAtoms();
  Bond[] bonds = molecule.getBonds();
  TransformGroup theAtoms;
  int numAtomChildren;

  switch(mode)
  {
   case DisplayModeManager.SPACEFILL :

    int numChildren = atomsTG.numChildren();

    for(int i = 0; i < numChildren; i++)
    {
     TransformGroup atomTG = (TransformGroup)atomsTG.getChild(i);
     Sphere atom = (Sphere)atomTG.getChild(0);

     switch(s)
     {
      case AMINO : atom.setAppearance(getAmino(a[i], 
DisplayModeManager.SPACEFILL, false));
           break;
      case CHAIN : atom.setAppearance(getChain(a[i].getChain(), 
a[i].isHetatm(), DisplayModeManager.SPACEFILL, false));
           break;
      case CPK   : atom.setAppearance(getCPK(a[i], 
DisplayModeManager.SPACEFILL, false));
           break;
     }
    }
    break;


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/
products/java-media/3D/

=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/

Reply via email to