Package com.jme3.bounding

Examples of com.jme3.bounding.BoundingBox


    private void setColor(Node node, ColorRGBA color){
  for(int i = 0; i < node.getQuantity(); i++){
      Spatial spatial = node.getChild(i);
      if(spatial instanceof Geometry){
                //Material material = new Material();
                AssetManager assetManager = JmeSystem.newAssetManager(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg"));
                Material material = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
                material.setColor("m_Color",color);
                //Material geomMaterial = ((Geometry)spatial).getMaterial();
                spatial.setMaterial(material);
                System.out.println("Spatial: "+spatial.getName());
View Full Code Here


     * Sets the color of the geometries of the children and home.
     * Note, this is a recursive method.
     * @param node the node that contains children
     **/
    private void setColor(Geometry geometry, ColorRGBA color){
        AssetManager assetManager = JmeSystem.newAssetManager(Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg"));
        Material material = new Material(assetManager, "Common/MatDefs/Misc/SolidColor.j3md");
        material.setColor("m_Color",color);
        geometry.setMaterial(material);
        System.out.println("Spatial: "+geometry.getName());
    }
View Full Code Here

         */
        terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());//, new LodPerspectiveCalculatorFactory(getCamera(), 4)); // add this in to see it use entropy for LOD calculations
        TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
        terrain.addControl(control);
        terrain.setMaterial(matTerrain);
        terrain.setModelBound(new BoundingBox());
        terrain.updateModelBound();
        terrain.setLocalTranslation(0, -100, 0);
        terrain.setLocalScale(1f, 1f, 1f);
        rootNode.attachChild(terrain);

View Full Code Here

      if(s instanceof Geometry){
        Node a = s.getParent();
        if(a==null)return;
        BoundingVolume bound = ((Geometry) s).getModelBound();
        if(bound instanceof BoundingBox) {
          BoundingBox bb = ((BoundingBox) bound);
          WireBox b = new WireBox(bb.getXExtent(), bb.getYExtent(), bb.getZExtent());
          Geometry g = new Geometry(null, b);
          Transform t = s.getWorldTransform().clone();
//          Vector3f pos = t.getTranslation();
//          pos.addLocal(bb.getCenter());
//          t.setTranslation(pos);
View Full Code Here

    protected void addModel(){    

      Node n = Assembler2.getModel4(templates[template_index],true, true);
      if(n != null){
        n.setModelBound(new BoundingBox());
        n.updateGeometricState();
        n.updateModelBound();
        nodes.add(n);
        currentNode++;
        int x = currentNode;
View Full Code Here

         */
        terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());//, new LodPerspectiveCalculatorFactory(getCamera(), 4)); // add this in to see it use entropy for LOD calculations
        TerrainLodControl control = new TerrainLodControl(terrain, getCamera());
        terrain.addControl(control);
        terrain.setMaterial(matTerrain);
        terrain.setModelBound(new BoundingBox());
        terrain.updateModelBound();
        terrain.setLocalTranslation(0, -10, 0);
        terrain.setLocalScale(1f, 1f, 1f);
        rootNode.attachChild(terrain);
}
else
{

//    g00 = (Geometry) ((Node)assetManager.loadModel("untitled.mesh.xml")).getChild(0);
//        TangentBinormalGenerator.generate(g00.getMesh());
    //small = 9x9
//  g00 = (Geometry) ((Node)assetManager.loadModel("Models/Terrain/Terrain.mesh.xml")).getChild(0);
       g00 = (Geometry) assetManager.loadModel("com/l2client/test/material/130_153.obj");
//       TangentBinormalGenerator.generateFaceNormalsAndTangents(g00.getMesh());
//       ModelConverter.optimize(g00, true);
        TangentBinormalGenerator.generate(g00.getMesh());
//    TangentUtil.addTangentsToMesh(g00.getMesh());
        g00.getMesh().clearBuffer(Type.Binormal);
        g00.getMesh().clearBuffer(Type.Color);
        g00.getMesh().getBuffer(Type.Tangent).setUsage(Usage.Static);
        g00.setMaterial(matTerrain);
      g00.setModelBound(new BoundingBox());
      g00.updateModelBound();
      g00.setLocalTranslation(0, -100, 0);
      g00.setLocalScale(1f, 1f, 1f);
//      g00.updateGeometricState();
     
View Full Code Here

              Vector3f bonePos = bone.getModelSpacePosition();
              extents.x = Math.max(extents.x, FastMath.abs(bonePos.getX()));
              extents.y = Math.max(extents.y, FastMath.abs(bonePos.getY()));
              extents.z = Math.max(extents.z, FastMath.abs(bonePos.getZ()));
          }
          BoundingBox b = new BoundingBox(new Vector3f(0f,0f,0f), extents.x, extents.y , extents.z);
          spatial.setModelBound(b);
    }
  }
View Full Code Here

      float patchScaleVariation, float patchWidth, float patchHeight,
      float inc, float fadeEnd, float fadeRange, float minIntensity,
      int channelId, int clusters) {
    Node spatNode = (Node) spatial;
    Node grassLayer = new Node("grass_" + spatial.getName());
    grassLayer.setModelBound(new BoundingBox());

    Texture tex = assetManager.loadTexture(texturePath);
    Material faceMat = new Material(assetManager,
        "/com/l2client/materials/LightingGrass.j3md");
    faceMat.getAdditionalRenderState().setBlendMode(
        RenderState.BlendMode.Alpha);
    faceMat.getAdditionalRenderState().setFaceCullMode(FaceCullMode.Off);
    faceMat.getAdditionalRenderState().setDepthWrite(true);
    faceMat.getAdditionalRenderState().setDepthTest(true);
    faceMat.setTransparent(true);
    faceMat.setTextureParam("DiffuseMap", VarType.Texture2D, tex);
    faceMat.setFloat("AlphaDiscardThreshold", 0.3f);
    // faceMat.setTextureParam("AlphaMap", VarType.Texture2D,tex);
    faceMat.setBoolean("UseAlpha", true);
    if (fadeEnd > 0f) {
      faceMat.setFloat("FadeEnd", fadeEnd);// 300f);
      faceMat.setFloat("FadeRange", fadeRange); // 50f);
      faceMat.setBoolean("FadeEnabled", true);
    }
    faceMat.setBoolean("Swaying", true);
    faceMat.setVector3("SwayData", new Vector3f(1.0f, 0.5f, 300f));// frequency,
                                    // variation,
                                    // third?
    faceMat.setVector2("Wind", new Vector2f(1f, 1f));

    Geometry terrain = null;

    if (spatial instanceof Geometry) {
      terrain = (Geometry) spatial;
    } else {
      for (Spatial currentSpatial : spatNode.getChildren()) {
        if (currentSpatial instanceof Geometry) {
          terrain = (Geometry) currentSpatial;
          break;
        }
      }
    }

    if (terrain == null || spatNode.getChildren().isEmpty()) {
      Logger.getLogger(GrassLayerUtil.class.getName()).log(Level.SEVERE,
          "Could not find terrain object.", new Exception());
      System.exit(0);
    }

    // Generate grass uniformly with random offset.
    float terrainWidth = 1f * 256; // get width length of terrain(assuming
                    // its a square)
    BoundingVolume bounds = ((Spatial) terrain).getWorldBound();
    if (BoundingVolume.Type.AABB.equals(bounds.getType())) {
      BoundingBox bb = ((BoundingBox) bounds);
      terrainWidth = Math.max(bb.getXExtent(), bb.getZExtent());
      terrainWidth *= 2f;
    } else if (BoundingVolume.Type.Sphere.equals(bounds.getType())) {
      terrainWidth = ((BoundingSphere) bounds).getRadius();
      terrainWidth *= 2f;
    }
View Full Code Here

          txt.setQueueBucket(Bucket.Transparent);
          txt.addControl(new BillboardControl());
     
      label = new Node("label");
          if(vis.getWorldBound() instanceof BoundingBox){
            BoundingBox bbox = (BoundingBox)vis.getWorldBound();
            label.setLocalTranslation(0f, bbox.getYExtent()+bbox.getYExtent()+0.5f, 0f);
            logger.finest("Label by BBox "+txt.getText()+" @ "+label.getLocalTranslation());
          }
          else if(vis.getWorldBound() instanceof BoundingSphere){
            BoundingSphere bound = (BoundingSphere)vis.getWorldBound();
            label.setLocalTranslation(0f, bound.getRadius()+bound.getRadius()+0.5f, 0f);
View Full Code Here

        Node node = new Node("Message");
        if(label != null){
          node.setLocalTranslation(0f,label.getLocalTranslation().y+0.5f, 0f);
        } else {
          if(vis.getWorldBound() instanceof BoundingBox){
            BoundingBox bbox = (BoundingBox)vis.getWorldBound();
            node.setLocalTranslation(0f, bbox.getYExtent()+bbox.getYExtent()+0.5f, 0f);
            logger.finest("Message by BBox "+msg+" @ "+node.getLocalTranslation());
          }
          else if(vis.getWorldBound() instanceof BoundingSphere){
            BoundingSphere bound = (BoundingSphere)vis.getWorldBound();
            node.setLocalTranslation(0f, bound.getRadius()+bound.getRadius()+0.5f, 0f);
View Full Code Here

TOP

Related Classes of com.jme3.bounding.BoundingBox

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.