Package org.jdesktop.wonderland.client.jme.artimport

Examples of org.jdesktop.wonderland.client.jme.artimport.DeployedModel


            ModelLoader loader = LoaderManager.getLoaderManager().getLoader(deployedModelURL);
            if (loader==null) {
                logger.warning("No loader for model "+deployedModel.getModelURL());
                return new Node("No Loader");
            }
            deployedModel = new DeployedModel(deployedModelURL, loader);
            deployedModel.setModelTranslation(modelTranslation);
            deployedModel.setModelRotation(modelRotation);
            deployedModel.setModelScale(modelScale);

            return loader.loadDeployedModel(deployedModel, entity);
View Full Code Here


    public DeployedModel deployToModule(File moduleRootDir, ImportedModel importedModel) throws IOException {
        try {
            String modelName = getFilename(importedModel.getOriginalURL().toURI().getPath());
            HashMap<String, String> textureDeploymentMapping = new HashMap();
            DeployedModel deployedModel = new DeployedModel(importedModel.getOriginalURL(), this);
            LoaderData data = new LoaderData();
            data.setDeployedTextures(textureDeploymentMapping);
            data.setModelLoaderClassname(this.getClass().getName());
            deployedModel.setLoaderData(data);

            // TODO replace getName with getModuleName(moduleRootDir)
            String moduleName = moduleRootDir.getName();

            String targetDirName = moduleRootDir.getAbsolutePath()+File.separator+"art"+ File.separator + modelName;
            File targetDir = new File(targetDirName);
            targetDir.mkdirs();

            // Must deploy textures before models so we have the deployment url mapping
            deployTextures(targetDir, textureDeploymentMapping, importedModel);

            ModelCellServerState cellSetup = new ModelCellServerState();
            ModelCellComponentServerState setup = new ModelCellComponentServerState();
            cellSetup.addComponentServerState(setup);
            cellSetup.setName(importedModel.getWonderlandName());
           
           
            BoundingVolume modelBounds = importedModel.getModelBG().getWorldBound();
            float scale = scaleBounds(modelBounds);
            modelBounds = modelBounds.transform(new Quaternion(), Vector3f.ZERO,
                                                new Vector3f(scale, scale, scale));
           
            cellSetup.setBoundingVolumeHint(new BoundingVolumeHint(false, modelBounds));
            deployedModel.setModelBounds(modelBounds);

            Vector3f offset = importedModel.getRootBG().getLocalTranslation();
            PositionComponentServerState position = new PositionComponentServerState();
            Vector3f boundsCenter = modelBounds.getCenter();

            offset.subtractLocal(boundsCenter);
            deployedModel.setModelTranslation(offset);
            deployedModel.setModelRotation(importedModel.getModelBG().getLocalRotation());
            deployedModel.setModelScale(importedModel.getModelBG().getLocalScale().multLocal(scale));

//            System.err.println("BOUNDS CENTER "+boundsCenter);
//            System.err.println("OFfset "+offset);
//            System.err.println("Cell origin "+boundsCenter);
            position.setTranslation(boundsCenter);

            // The cell bounds already have the rotation and scale applied, so these
            // values must not go in the Cell transform. Instead they go in the
            // deployedModel so that the model is correctly oriented and thus
            // matches the bounds in the cell.

            // Center the worldBounds on the cell (ie 0,0,0)
            BoundingVolume worldBounds = modelBounds.clone(null);
            worldBounds.setCenter(new Vector3f(0,0,0));
            position.setBounds(worldBounds);
            cellSetup.addComponentServerState(position);

            deployedModel.addCellServerState(cellSetup);

            deployModels(targetDir,
                         moduleName,
                         deployedModel,
                         importedModel,
View Full Code Here

     * @return
     */
    public Node loadModel(Entity rootEntity) {
        Node ret = new Node();

        DeployedModel dm = getDeployedModel();

        ModelLoader loader = dm.getModelLoader();
        Node model = loader.loadDeployedModel(dm, rootEntity);
        if (model != null) {
            model.setName(dm.getModelURL());
            ret.attachChild(model);
        }
        return ret;
    }
View Full Code Here

                    // get initial models from the model loader
                    out.addAll(deployedModel.getModelLoader().getAssets(deployedModel));
                }
            } else {
                // get additional model from the model loader
                DeployedModel dm = getDeployedModel();
                if (dm != null) {
                    out.addAll(dm.getModelLoader().assetLoaded(dm, u, is));
                }
            }
        } catch (IOException ioe) {
            LOGGER.log(Level.WARNING, "Error loading model information", ioe);
        } catch (JAXBException je) {
View Full Code Here

        // Simply create a new ModelCell by creating a ModelCellServerState
        // with the URL passed in via the properties. First load the deployed
        // model from the given URL.
        LoaderManager lm = LoaderManager.getLoaderManager();
        DeployedModel dm = null;
        try {
            dm = lm.getLoaderFromDeployment(url);
        } catch (IOException excp) {
            LOGGER.log(Level.WARNING, "Unable to load deployed model from " +
                    url.toExternalForm(), excp);
            return null;
        }

        BoundingVolumeHint hint=null;
        PositionComponentServerState posComp = new PositionComponentServerState();

        if (dm.getModelBounds()==null) {
            // Legacy support, the DeployedModels object for new builds contains
            // the model bounds.
            // Go ahead and load the model. We need to load the model in order to
            // find out its bounds to set the hint.
            ModelLoader loader = dm.getModelLoader();
            Node node = loader.loadDeployedModel(dm, null);
            BoundingVolume bounds = node.getWorldBound();
            hint = getBoundingVolumeHint(bounds);
            posComp.setBounds(bounds);
        } else {
            hint = getBoundingVolumeHint(dm.getModelBounds());
            posComp.setBounds(dm.getModelBounds());
        }

        // Create a new server state for a Model Cell that knows how to display
        // the URL.
        ModelCellServerState state = new ModelCellServerState();
View Full Code Here

    @Override
    protected CellRenderer createCellRenderer(RendererType rendererType) {
        if (rendererType == RendererType.RENDERER_JME) {
            try {
                DeployedModel m =
                       LoaderManager.getLoaderManager().getLoaderFromDeployment(AssetUtils.getAssetURL("wla://phone/pwl_3d_conferencephone_001.dae/pwl_3d_conferencephone_001.dae.gz.dep"));

                return new PhoneCellRenderer(this, m);
            } catch (MalformedURLException ex) {
                Logger.getLogger(PhoneCell.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

        if (jmeState.getDeployedModelURL()==null// Legacy support
            deployedModel = getDeployedModel(jmeState);
    }

    private DeployedModel getDeployedModel(JmeColladaCellComponentClientState state) {
        DeployedModel ret = new DeployedModel(state.getModelLoaderClassname());
        ret.setModelURL(state.getModelURI());
        ret.setModelRotation(state.getModelRotation());
        ret.setModelScale(state.getModelScale());
        ret.setModelTranslation(state.getModelTranslation());

        return ret;
    }
View Full Code Here

        // Load the avatar using the new collada loading manager
        Node node = null;
        try {
            URL url = new URL(baseURL + avatarURL);
            DeployedModel dm = LoaderManager.getLoaderManager().getLoaderFromDeployment(url);
            node = dm.getModelLoader().loadDeployedModel(dm, null);
            node.setLocalScale(0.22f);
        } catch (MalformedURLException excp) {
            logger.log(Level.WARNING, "Unable to for .dep URL", excp);
            return null;
        } catch (IOException excp) {
View Full Code Here

    }

    private void attachModel(Node aNode) throws IOException {
        LoaderManager manager = LoaderManager.getLoaderManager();
        URL url = AssetUtils.getAssetURL("wla://coneofsilence/pwl_3d_coneofsilence_016d.dae/pwl_3d_coneofsilence_016d.dae.gz.dep", this.getCell());
        DeployedModel dm = manager.getLoaderFromDeployment(url);
        Node cosModel = dm.getModelLoader().loadDeployedModel(dm, entity);
        aNode.attachChild(cosModel);
    }
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.client.jme.artimport.DeployedModel

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.