Package com.jme3.scene.plugins.blender.textures.io

Examples of com.jme3.scene.plugins.blender.textures.io.PixelInputOutput


    }
// ============= Public Methods ============== //
    public Model loadModel(Avatar avatar){
  // TEST, just load
  Model model = new Model();
  Node node = null;
  // load the body
  Node body = baseTable.loadBody(avatar.skin.color,avatar.shirt.color);
  Node head = baseTable.loadHead(avatar.head.type,avatar.skin.color);
        baseTable.loadEyes(avatar.eye,head);
  if(head != null && body != null){
      model.load(head,body);
  }
View Full Code Here


    /**
     * Handles loading a single node from file.
     * @param obj the path to the object.
     **/
    public Node loadNode(String obj){
  Node node = new Node();
  try{
            Spatial spatial = assetManager.loadModel(obj);
            //Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
            //spatial.setMaterial(mat);
            node.attachChild(spatial);

      node.setModelBound(new BoundingSphere());
      node.updateModelBound();
  } catch (Exception e) {
            e.printStackTrace();
      //logger.logp(Level.SEVERE, this.getClass().toString(),"loadNode()", "Exception", e);
      node = null;
  }
View Full Code Here

   
    setPointLight(true);
   
    guiNode.detachChildNamed("Statistics View");

    camNode = new Node("Cam Node");

    flyCam.setEnabled(false);
    ChaseCamera chaseCam = new ChaseCamera(cam, camNode, inputManager);
    chaseCam.setSmoothMotion(true);
    chaseCam.setMaxDistance(100000);
View Full Code Here

        if (path.startsWith(File.separator)) {
          relPath = path.substring(1);
        } else {
          relPath = path;
        }
        Node model = (Node) assetManager.loadModel(relPath);
        if (model == null) {
          assetLogger.modelFinished();
          logger.log(Level.SEVERE, "Couldn't load model "+path);
          return null;
        }
        Geometry modelGeom = (Geometry) model.getChild(0);

        try {
          // trows an Exception if lod is not supported
          modelGeom.setLodLevel(0);
View Full Code Here

     * @param obj the path to the object.
     **/
    public Node loadNode(String obj){
  Node node = new Node();
  try{
            Spatial spatial = assetManager.loadModel(obj);
            //Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
            //spatial.setMaterial(mat);
            node.attachChild(spatial);

      node.setModelBound(new BoundingSphere());
View Full Code Here

        app.start();
    }

    @Override
    public void simpleInitApp() {
        Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
      
        teapot.setLocalScale(2f);
        Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        mat.setFloat("m_Shininess", 32f);
        mat.setBoolean("m_UseMaterialColors", true);

        mat.setColor("m_Ambient",  ColorRGBA.Black);
        mat.setColor("m_Diffuse",  ColorRGBA.Green);
        mat.setColor("m_Specular", ColorRGBA.Red);
       
        teapot.setMaterial(mat);
        rootNode.attachChild(teapot);

        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
        lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
        lightMdl.getMesh().setStatic();
View Full Code Here

        try {
          // trows an Exception if lod is not supported
          modelGeom.setLodLevel(0);

          LodControl control = new LodControl();
          modelGeom.addControl(control);
        } catch (Exception e) {}
        assetLogger.modelFinished();
        camNode.detachAllChildren();
        camNode.attachChild(model);
View Full Code Here

     *            start X position on the target image
     * @param targetYPos
     *            start Y position on the target image
     */
    private void draw(Image target, Image source, int targetXPos, int targetYPos) {
        PixelInputOutput sourceIO = PixelIOFactory.getPixelIO(source.getFormat());
        PixelInputOutput targetIO = PixelIOFactory.getPixelIO(target.getFormat());
        TexturePixel pixel = new TexturePixel();

        for (int x = 0; x < source.getWidth(); ++x) {
            for (int y = 0; y < source.getHeight(); ++y) {
                sourceIO.read(source, 0, pixel, x, y);
                targetIO.write(target, 0, pixel, targetXPos + x, targetYPos + y);
            }
        }
    }
View Full Code Here

            if (height == 0) {
                height = 1;
            }

            // copy the pixel from the texture to the result image
            PixelInputOutput pixelReader = PixelIOFactory.getPixelIO(sourceImage.getFormat());
            TexturePixel pixel = new TexturePixel();
            ByteBuffer data = BufferUtils.createByteBuffer(width * height * 4);
            for (int y = minY; y < maxY; ++y) {
                for (int x = minX; x < maxX; ++x) {
                    int xPos = x >= sourceImage.getWidth() ? x - sourceImage.getWidth() : x;
                    int yPos = y >= sourceImage.getHeight() ? y - sourceImage.getHeight() : y;
                    pixelReader.read(sourceImage, 0, pixel, xPos, yPos);
                    data.put(pixel.getR8());
                    data.put(pixel.getG8());
                    data.put(pixel.getB8());
                    data.put(pixel.getA8());
                }
View Full Code Here

            }
            ByteBuffer data = BufferUtils.createByteBuffer(imageWidth * imageHeight * (imageFormat.getBitsPerPixel() >> 3));
            image = new Image(texture.getImage().getFormat(), imageWidth, imageHeight, data);

            // computing the pixels
            PixelInputOutput pixelWriter = PixelIOFactory.getPixelIO(imageFormat);
            TexturePixel pixel = new TexturePixel();
            float[] uvs = new float[3];
            Vector3f point = new Vector3f(envelope.min);
            Vector3f vecY = new Vector3f();
            Vector3f wDelta = new Vector3f(envelope.w).multLocal(1.0f / imageWidth);
            Vector3f hDelta = new Vector3f(envelope.h).multLocal(1.0f / imageHeight);
            for (int x = 0; x < imageWidth; ++x) {
                for (int y = 0; y < imageHeight; ++y) {
                    this.toTextureUV(boundingBox, point, uvs);
                    texture.getPixel(pixel, uvs[0], uvs[1], uvs[2]);
                    pixelWriter.write(image, 0, pixel, x, y);
                    point.addLocal(hDelta);
                }

                vecY.addLocal(wDelta);
                point.set(envelope.min).addLocal(vecY);
View Full Code Here

TOP

Related Classes of com.jme3.scene.plugins.blender.textures.io.PixelInputOutput

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.