Package edu.cmu.cs.stage3.alice.core

Examples of edu.cmu.cs.stage3.alice.core.Model


    }

    private void synchronize( Model[] curr ) {
        int binCount = getBinCount();
        for( int i=binCount-1; i>=curr.length; i-- ) {
            Model binI = getBinAt( i );
            binI.vehicle.set( null );
      //binI.removeFromParent();
            m_bins.remove( binI );
        }
        Model prototype = getPrototype();
        if( prototype != null ) {
            for( int i=binCount; i<curr.length; i++ ) {
                Class[] share = { edu.cmu.cs.stage3.alice.core.Geometry.class };
        String name = "Sub"+i;
                Model binI = (Model) getChildNamed( name );
                if( binI == null ) {
                  binI = (Model)prototype.HACK_createCopy( name, this, -1, share, null );
          decorateTextureMap( getEmptyTextureMap( binI ), i );
          decorateTextureMap( getFilledTextureMap( binI ), i );
                }
                setBinAt( i, binI );
            }
            binCount = getBinCount();
            for( int i=0; i<binCount; i++ ) {
                Model binI = getBinAt( i );
                binI.vehicle.set( this );
                binI.setPositionRightNow( -(prototype.getWidth()*i), 0, 0 );
                if( curr[ i ] != null ) {
                    curr[ i ].vehicle.set( binI );
                    curr[ i ].visualization.set( this );
                    curr[ i ].setTransformationRightNow( getTransformationFor( curr[ i ], i ), this );
                    binI.diffuseColorMap.set( getFilledTextureMap( binI ) );
                } else {
                    binI.diffuseColorMap.set( getEmptyTextureMap( binI ) );
                }
            }
            Model rightBracket = (Model)getChildNamed( "RightBracket" );
            if( rightBracket != null ) {
                rightBracket.setPositionRightNow( -(prototype.getWidth()*(binCount-0.5)), 0, 0 );
            }
        }
    }
View Full Code Here


        } else {
            System.err.println( "WARNING: collection is null " + this );
        }
    }
    public javax.vecmath.Matrix4d getTransformationFor( edu.cmu.cs.stage3.alice.core.Model model, int i ) {
        Model prototype = getPrototype();

        javax.vecmath.Matrix4d m = new javax.vecmath.Matrix4d();
        m.setIdentity();
        if( model != null ) {
            edu.cmu.cs.stage3.math.Box box = model.getBoundingBox();
            javax.vecmath.Vector3d v = box.getCenterOfBottomFace();
            if( v!=null ) {
                v.negate();
                m.m30 = v.x;
                m.m31 = v.y;
                m.m32 = v.z;
            }
        }
        m.m30 -= prototype.getWidth()*i;
        return m;
    }
View Full Code Here

    }
    public void setItem( Model value ) {
        getItemVariable().value.set( value );
    }
    private void synchronize( Model curr ) {
        Model prev = getItem();
        if( prev != null && prev != curr ) {
            prev.visualization.set( null );
        }
        if( curr != null ) {
            curr.setTransformationRightNow( getTransformationFor( curr ), this );
View Full Code Here

    }
  }

  private void initializeModels(Model part, String parentName, edu.cmu.cs.stage3.math.Vector3 position) {
    // check to see if anything should be parented to this
    Model partsToAttach = (Model) partsTable.get(part.getKey());
    if ((partsToAttach != null) && (partsToAttach.getParent() == null)) {
      addChildToModel(part, partsToAttach, position);
    }
  }
View Full Code Here

    if (parent.getChildCount() > 0) {
      Element[] oldKids = parent.getChildren();
      for (int i = 0; i < oldKids.length; i++) {
        if (oldKids[i] instanceof Model) {
          oldKids[i].removeFromParent();
          Model oldModel = (Model) oldKids[i];
          oldModel.vehicle.set(null);
          parent.removeChild(oldModel);
        }
      }
    }
View Full Code Here

    // remove any old kids the newParent might already have
    removeAllKids(newParent);
    if ((newParent != null) && (kids != null)) {
      for (int i = 0; i < kids.length; i++) {
        if (kids[i] instanceof Model) {
          Model kidModel = (Model) kids[i];
          addChildToModel(newParent, kidModel, null);
        }
      }
    }
  }
View Full Code Here

            } catch (Exception e) {
              e.printStackTrace();
            }
          } else if (attr.getNodeName().equals("model")) {
            String modelString = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            Model part = null;
            try {
              part = (Model) Model.load(PersonBuilder.class.getResource(modelString), null);
              part.vehicle.set(null);
            } catch (java.io.IOException ioe) {
              ioe.printStackTrace();
            } catch (edu.cmu.cs.stage3.alice.core.UnresolvablePropertyReferencesException upre) {
              upre.printStackTrace();
            }
            cmdInfo.model = part;
            cmdInfo.modelFactory = part.createCopyFactory();
            cmdInfo.modelString = modelString;
          } else if (attr.getNodeName().equals("parent")) {
            String parentString = attr.getNodeValue();
            cmdInfo.parentString = parentString;
          } else if (attr.getNodeName().equals("altModel")) {
            String altModelName = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            Model altModel = null;
            try {
              altModel = (Model) Model.load(PersonBuilder.class.getResource(altModelName), null);
              altModel.vehicle.set(null);
            } catch (java.io.IOException ioe) {
              ioe.printStackTrace();
            } catch (edu.cmu.cs.stage3.alice.core.UnresolvablePropertyReferencesException upre) {
              upre.printStackTrace();
            }
            cmdInfo.altModel = altModel;
            cmdInfo.altModelFactory = altModel.createCopyFactory();
            altModelCount++;
          }
        }

        commandInfos.addElement(cmdInfo);

      } else if (choiceNode.getNodeName().equals("addModelAndTexture")) {
        CommandInfo cmdInfo = new CommandInfo();
        cmdInfo.id = "addModelAndTexture";
        NamedNodeMap attrs = choiceNode.getAttributes();
        for (int j = 0; j < attrs.getLength(); j++) {
          Node attr = attrs.item(j);
          if (attr.getNodeName().equals("icon")) {
            String imageFileName = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            ImageIcon icon = new ImageIcon(PersonBuilder.class.getResource(imageFileName), imageFileName);
            cmdInfo.imageIcon = icon;
          } else if (attr.getNodeName().equals("model")) {
            String modelString = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            Model part = null;
            try {
              part = (Model) Model.load(PersonBuilder.class.getResource(modelString), null);
              part.vehicle.set(null);
            } catch (java.io.IOException ioe) {
              ioe.printStackTrace();
            } catch (edu.cmu.cs.stage3.alice.core.UnresolvablePropertyReferencesException upre) {
              upre.printStackTrace();
            }
            cmdInfo.model = part;
            cmdInfo.modelFactory = part.createCopyFactory();
            cmdInfo.modelString = modelString;
          } else if (attr.getNodeName().equals("parent")) {
            String parentString = attr.getNodeValue();
            cmdInfo.parentString = parentString;
          } else if (attr.getNodeName().equals("texture")) {
            String imageFileName = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            Image img = toolkit.createImage(PersonBuilder.class.getResource(imageFileName));
            try {
              java.awt.MediaTracker tracker = new java.awt.MediaTracker(this);
              tracker.addImage(img, 0);
              tracker.waitForID(0);
            } catch (java.lang.InterruptedException ie) {
            }
            cmdInfo.texture = img;
          } else if (attr.getNodeName().equals("layer")) {
            String layerString = attr.getNodeValue();
            int layer = Integer.parseInt(layerString);
            cmdInfo.level = layer;
          } else if (attr.getNodeName().equals("useAltModel")) {
            String altModelName = attr.getNodeValue();
            cmdInfo.altModelName = altModelName;
          } else if (attr.getNodeName().equals("x")) {
            cmdInfo.x = Double.parseDouble(attr.getNodeValue());
          } else if (attr.getNodeName().equals("y")) {
            cmdInfo.y = Double.parseDouble(attr.getNodeValue());
          } else if (attr.getNodeName().equals("z")) {
            cmdInfo.z = Double.parseDouble(attr.getNodeValue());
          }
        }
        commandInfos.addElement(cmdInfo);
      } else if (choiceNode.getNodeName().equals("setMultipleModelsAndTexture")) {
        CommandInfo cmdInfo = new CommandInfo();
        cmdInfo.id = "setMultipleModelsAndTexture";
        NamedNodeMap attrs = choiceNode.getAttributes();
        for (int j = 0; j < attrs.getLength(); j++) {
          Node attr = attrs.item(j);
          if (attr.getNodeName().equals("icon")) {
            String imageFileName = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            ImageIcon icon = new ImageIcon(PersonBuilder.class.getResource(imageFileName), imageFileName);
            cmdInfo.imageIcon = icon;
          } else if (attr.getNodeName().equals("model1")) {
            String modelString = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            Model part = null;
            try {
              part = (Model) Model.load(PersonBuilder.class.getResource(modelString), null);
              part.vehicle.set(null);
            } catch (java.io.IOException ioe) {
              ioe.printStackTrace();
            } catch (edu.cmu.cs.stage3.alice.core.UnresolvablePropertyReferencesException upre) {
              upre.printStackTrace();
            }
            cmdInfo.model = part;
            cmdInfo.modelFactory = part.createCopyFactory();
            cmdInfo.modelString = modelString;
          } else if (attr.getNodeName().equals("parent1")) {
            String parentString = attr.getNodeValue();
            cmdInfo.parentString = parentString;
          } else if (attr.getNodeName().equals("model2")) {
            String modelString = XMLDirectoryUtilities.getPath(dirNode) + "/" + attr.getNodeValue();
            Model part = null;
            try {
              part = (Model) Model.load(PersonBuilder.class.getResource(modelString), null);
              part.vehicle.set(null);
            } catch (java.io.IOException ioe) {
              ioe.printStackTrace();
            } catch (edu.cmu.cs.stage3.alice.core.UnresolvablePropertyReferencesException upre) {
              upre.printStackTrace();
            }
            cmdInfo.altModel = part;
            cmdInfo.altModelFactory = part.createCopyFactory();
            //cmdInfo.altModelName = modelString;
          } else if (attr.getNodeName().equals("parent2")) {
            String parentString = attr.getNodeValue();
            cmdInfo.altParentString = parentString;
          } else if (attr.getNodeName().equals("texture")) {
View Full Code Here

     
    protected javax.vecmath.Vector3d getPositionEnd() {
      javax.vecmath.Vector3d v = new javax.vecmath.Vector3d(0,0,0);
     
      if (asSeenBy.get() instanceof Model) {
        Model character = (Model) asSeenBy.get();
        edu.cmu.cs.stage3.alice.core.Element[] heads = character.search(new edu.cmu.cs.stage3.alice.core.criterion.ElementNamedCriterion("head", true) );
        if ((heads.length > 0) && (heads[0] instanceof Model)) {
          m_characterHead = (Model) heads[0];
          v = m_characterHead.getBoundingBox().getCenterOfFrontFace();
          return m_characterHead.getPosition(v, edu.cmu.cs.stage3.alice.core.ReferenceFrame.ABSOLUTE);
        } else {
          v = character.getBoundingBox().getCenterOfFrontFace();
          v.y *= 1.8;
          return character.getPosition(v, edu.cmu.cs.stage3.alice.core.ReferenceFrame.ABSOLUTE);
        }
      } else {
      }
      return m_asSeenBy.getPosition( v, edu.cmu.cs.stage3.alice.core.ReferenceFrame.ABSOLUTE );
    }
View Full Code Here

    Class elementOverrideValueClass = null;
    String propertyNameValue = propertyName.getStringValue();
    if( propertyNameValue!=null ) {
      Element elementValue = element.getElementValue();
      if( elementValue!=null ) {
        Property property = elementValue.getPropertyNamed( propertyNameValue );
        if( property != null ) {
          elementOverrideValueClass = property.getDeclaredClass();
        } else {
          if( elementValue instanceof Expression ) {
            Class cls = ((Expression)elementValue).getValueClass();
            if( cls != null ) {
              elementOverrideValueClass = cls;
View Full Code Here

      return null;
    }
  }

  public Object getValue() {
    Property property = getPropertyValue();
    if( property != null ) {
      return property.getValue();
    } else {
      throw new RuntimeException();
      //return null;
    }
  }
View Full Code Here

TOP

Related Classes of edu.cmu.cs.stage3.alice.core.Model

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.