Package javax.media.j3d

Examples of javax.media.j3d.Switch


    ca.setColor(1.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
    mainSwitch = new Switch(Switch.CHILD_MASK);
   
    mainSwitch.addChild(branchgroup);
    mainSwitch.addChild(axisGroup);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
View Full Code Here


    ca.setColor(1.0f,0.0f,1.0f);
    a.setColoringAttributes(ca);
    saxis = new Shape3D(la, a);
    axisGroup.addChild(saxis);
       
    mainSwitch = new Switch(Switch.CHILD_MASK);
   
    mainSwitch.addChild(branchgroup);
    mainSwitch.addChild(axisGroup);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    mainSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
View Full Code Here

    }

   
    private void readObject(java.io.ObjectInputStream in) throws java.lang.ClassNotFoundException, java.io.IOException {
      in.defaultReadObject();
      sw = new Switch(Switch.CHILD_MASK);
      sw.setUserData(this);
      sw.setPickable(true);
      sw.setCapability(Switch.ALLOW_SWITCH_WRITE);
      sw.setChildMask(status);
    }
View Full Code Here

       
        public void apply() {
            super.apply();
            for (GraphObjectReference o : getReferences()) {
                if(o.getObject() instanceof Switch){
                    Switch s=((Switch)o.getObject());
                    switch(_kind){
                    case SELECTION:
                        if(s.getWhichChild()!=params[0]){
                            s.setWhichChild(params[0]);
                        }
                        break;
                    case MASK:
                        BitSet b=new BitSet();
                        intToBitSet(params[0],b);
                        if(!b.equals(s.getChildMask())){
                            ((Switch)o.getObject()).setChildMask(b);
                        }
                        break;
                    }
                }
View Full Code Here

    static class AddSwitchAction extends AbstractNodeAction {
        // required for dynamic action creation
        public AddSwitchAction() {
        }
        public void actionPerformed(ActionEvent e) {
            ((GroupNode)getNode()).addChildUndoable(new Switch());
            getNode().refresh();
        }
View Full Code Here

        b.getLower(fixl);
        double h2 = fixu.y-fixl.y;
        upper.y = h1;
        lower.y = h1-h2;

        Switch sw = new Switch(Switch.CHILD_MASK);
        sw.setCapability(Switch.ALLOW_SWITCH_WRITE);
        DistanceLOD lod = new DistanceLOD(new float[] { font.getFont().getSize()*10*(float)BoardModel.HEX_DIAMETER });
        lod.addSwitch(sw);
        lod.setSchedulingBounds(BoardModel.bounds);

        Appearance app = new Appearance();
        app.setColoringAttributes(new ColoringAttributes(fg, ColoringAttributes.SHADE_FLAT));
        sw.addChild(new Shape3D(geom, app));

        app = new Appearance();
        Color3f lodfg = new Color3f(fg);
        lodfg.scale(2/3f);
        lodfg.add(C.grey10);
        app.setColoringAttributes(new ColoringAttributes(lodfg, ColoringAttributes.SHADE_FLAT));
        sw.addChild(makeQuad(lower.x, lower.y+(upper.y-lower.y)/4, upper.x-lower.x, (upper.y-lower.y)/2, 0, app));

        addChild(sw);
        addChild(lod);

        setTransform(new Transform3D(C.nullRot, new Vector3d(0,0,0.1), 1.0));
View Full Code Here

    tgmCyl.addChild(cylMoveR);
    tgmCyl.addChild(cylMoveL);


    //A Switch for the green and the red sphere.
    Switch colourSwitch = new Switch();
    colourSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    //An Appearance for the green sphere.
    Color3f ambientColourGSphere = new Color3f(0.0f,0.8f,0.0f);
    Color3f emissiveColourGSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourGSphere = new Color3f(0.0f,0.8f,0.0f);
    Color3f specularColourGSphere = new Color3f(0.0f,0.8f,0.0f);
    float shininessGSphere = 1.0f;

    Appearance greenSphereApp = new Appearance();
    greenSphereApp.setMaterial(new Material(ambientColourGSphere,
                                            emissiveColourGSphere,
                                            diffuseColourGSphere,
                                            specularColourGSphere,
                                            shininessGSphere));

    //Generate the green sphere.
    float radius = 0.1f;
    Sphere greenSphere = new Sphere(radius,greenSphereApp);



    //The same for the red sphere.
    Color3f ambientColourRSphere = new Color3f(0.6f,0.0f,0.0f);
    Color3f emissiveColourRSphere = new Color3f(0.0f,0.0f,0.0f);
    Color3f diffuseColourRSphere = new Color3f(0.6f,0.0f,0.0f);
    Color3f specularColourRSphere = new Color3f(0.8f,0.0f,0.0f);
    float shininessRSphere = 20.0f;

    Appearance redSphereApp = new Appearance();

    redSphereApp.setMaterial(new Material(ambientColourRSphere,emissiveColourRSphere,
                             diffuseColourRSphere,specularColourRSphere,shininessRSphere));

    Sphere redSphere = new Sphere(radius,redSphereApp);



    //Add the two spheres to the Switch.
    colourSwitch.addChild(greenSphere);
    colourSwitch.addChild(redSphere);

    //The CollisionBounds for the two spheres.
    colourSwitch.setCollisionBounds(new BoundingSphere(new Point3d(0.0,0.0,0.0),radius));

    //Enable the test for collision.
    colourSwitch.setCollidable(true);

    //The green sphere should be visible in the beginning.
    colourSwitch.setWhichChild(0);

    //A transformation group for the Switch (the spheres).
    Transform3D tfSphere = new Transform3D();
    tfSphere.setTranslation(new Vector3f(0.7f,0.0f,0.0f));
    TransformGroup tgSphere = new TransformGroup(tfSphere);
View Full Code Here

/*     */     throws IncorrectFormatException, FileNotFoundException
/*     */   {
/* 180 */     if (this.fileName.indexOf("000") != -1) {
/* 181 */       int index = this.fileName.indexOf("000");
/* 182 */       String fileNameBase = this.fileName.substring(0, index);
/* 183 */       Switch s = new Switch();
/* 184 */       s.setCapability(17);
/* 185 */       s.setCapability(18);
/* 186 */       String tempFileName = this.fileName;
/* 187 */       int fileNum = 0;
/* 188 */       while (new File(tempFileName).exists()) {
/* 189 */         if (storedRefList.get(tempFileName) != null)
/*     */         {
/* 192 */           SharedGroup storedGroup = (SharedGroup)storedRefList.get(tempFileName);
/*     */
/* 194 */           Link newLink = new Link(storedGroup);
/* 195 */           s.addChild(newLink);
/*     */         }
/*     */         else
/*     */         {
/* 199 */           J3dLwoParser objParser = new J3dLwoParser(tempFileName, debugVals);
/*     */
/* 201 */           objParser.createJava3dGeometry();
/* 202 */           TransformGroup t = new TransformGroup();
/* 203 */           SharedGroup newSharedGroup = new SharedGroup();
/* 204 */           storedRefList.put(tempFileName, newSharedGroup);
/* 205 */           newSharedGroup.addChild(t);
/* 206 */           Link newLink = new Link(newSharedGroup);
/* 207 */           s.addChild(newLink);
/* 208 */           if (objParser.getJava3dShapeList() != null) {
/* 209 */             Enumeration e = objParser.getJava3dShapeList().elements();
/*     */
/* 211 */             while (e.hasMoreElements()) {
/* 212 */               t.addChild((Shape3D)e.nextElement());
View Full Code Here

/* 53 */     super(symbol, control);
/*    */   }
/*    */
/*    */   public void writeObject(DataOutput out) throws IOException {
/* 57 */     super.writeObject(out);
/* 58 */     Switch attr = (Switch)this.node;
/* 59 */     this.control.writeSerializedData(out, attr.getChildMask());
/* 60 */     out.writeInt(attr.getWhichChild());
/*    */   }
View Full Code Here

/* 60 */     out.writeInt(attr.getWhichChild());
/*    */   }
/*    */
/*    */   public void readObject(DataInput in) throws IOException {
/* 64 */     super.readObject(in);
/* 65 */     Switch attr = (Switch)this.node;
/*    */
/* 67 */     attr.setChildMask((BitSet)this.control.readSerializedData(in));
/* 68 */     attr.setWhichChild(in.readInt());
/*    */   }
View Full Code Here

TOP

Related Classes of javax.media.j3d.Switch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.