Package net.anzix.fsz.voxelworld.features

Source Code of net.anzix.fsz.voxelworld.features.ColladaModel

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package net.anzix.fsz.voxelworld.features;

import com.ardor3d.extension.model.collada.jdom.ColladaImporter;
import com.ardor3d.extension.model.collada.jdom.data.ColladaStorage;
import com.ardor3d.math.Quaternion;
import com.ardor3d.math.type.ReadOnlyVector3;
import com.ardor3d.scenegraph.Node;
import com.ardor3d.util.resource.ResourceLocatorTool;
import com.ardor3d.util.resource.ResourceSource;
import net.anzix.fsz.voxelworld.DetailLevel;
import net.anzix.fsz.voxelworld.Feature;
import net.anzix.fsz.voxelworld.VoxelBlock;
import net.anzix.fsz.voxelworld.layers.LayerBlock;

/**
*
* @author kovacsandras
*/
public class ColladaModel extends Feature {

    boolean attached = false;
    @Override
    public void attachAdditionalNonVoxelModels(DetailLevel level, VoxelBlock block) {
        if (!attached && level.getLevelID() == 0) {
            attached = true;
            block.getColladaNode().attachChild(colladaNode);
        }
    }
   
    private Node colladaNode; 
    public ColladaModel(String resourceName) {
        loadColladaModel(ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_MODEL, resourceName));
   


    private void loadColladaModel( final ResourceSource source) {
        try {
            final ColladaImporter colladaImporter = new ColladaImporter();

            // Load the collada scene
            final ColladaStorage storage = colladaImporter.load(source);
            colladaNode = storage.getScene();
            colladaNode.setRotation(new Quaternion(-1,0,0,1));
        } catch (final Exception ex) {
            ex.printStackTrace();
        }
    }

    @Override
    public void applyDensities(ReadOnlyVector3 basePosition, float[][][] densities, Feature[][][] densitySources, DetailLevel level, LayerBlock layerBlock) {
       
    }
   
}
TOP

Related Classes of net.anzix.fsz.voxelworld.features.ColladaModel

TOP
Copyright © 2018 www.massapi.com. 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.