Examples of WorldManager


Examples of org.jdesktop.mtgame.WorldManager

     *
     * @param skybox
     * @return Entity reflecting new skybox.
     */
    private Entity createSkyboxEntity(Skybox skybox) {
        WorldManager wm = ClientContextJME.getWorldManager();
       
        skybox.setLightCombineMode(Spatial.LightCombineMode.Off);
        skybox.setCullHint(Spatial.CullHint.Never);
        skybox.setTextureCombineMode(TextureCombineMode.Replace);
        skybox.updateRenderState();
        skybox.lockBounds();   
   
        Entity e = new Entity("Skybox");
        SkyboxComponent sbc = wm.getRenderManager().createSkyboxComponent(skybox, true);
        e.addComponent(SkyboxComponent.class, sbc);

        skyboxProcessor = new SkyboxProcessor(wm, skybox);
        e.addComponent(SkyboxProcessor.class, skyboxProcessor);
        return e;
View Full Code Here

Examples of org.jdesktop.mtgame.WorldManager

            URL eastURL = AssetUtils.getAssetURL("wla://defaultenvironment/skybox1/2.jpg", cell);
            URL westURL = AssetUtils.getAssetURL("wla://defaultenvironment/skybox1/4.jpg", cell);
            URL downURL = AssetUtils.getAssetURL("wla://defaultenvironment/skybox1/5.jpg", cell);
            URL upURL = AssetUtils.getAssetURL("wla://defaultenvironment/skybox1/6.jpg", cell);

            WorldManager wm = ClientContextJME.getWorldManager();
            skybox = new Skybox("skybox", 1000, 1000, 1000);
            Texture north = TextureManager.loadTexture(northURL, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
            Texture south = TextureManager.loadTexture(southURL, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
            Texture east = TextureManager.loadTexture(eastURL, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
            Texture west = TextureManager.loadTexture(westURL, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
            Texture up = TextureManager.loadTexture(upURL, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
            Texture down = TextureManager.loadTexture(downURL, Texture.MinificationFilter.BilinearNearestMipMap, Texture.MagnificationFilter.Bilinear);
            skybox.setTexture(Skybox.Face.North, north);
            skybox.setTexture(Skybox.Face.West, west);
            skybox.setTexture(Skybox.Face.South, south);
            skybox.setTexture(Skybox.Face.East, east);
            skybox.setTexture(Skybox.Face.Up, up);
            skybox.setTexture(Skybox.Face.Down, down);
            //skybox.preloadTextures();
            CullState cullState = (CullState) wm.getRenderManager().createRendererState(RenderState.RS_CULL);
            cullState.setEnabled(true);
            skybox.setRenderState(cullState);
            ZBufferState zState = (ZBufferState) wm.getRenderManager().createRendererState(RenderState.RS_ZBUFFER);
            //zState.setEnabled(false);
            skybox.setRenderState(zState);
            FogState fs = (FogState) wm.getRenderManager().createRendererState(RenderState.RS_FOG);
            fs.setEnabled(false);
            skybox.setRenderState(fs);
            skybox.setLightCombineMode(Spatial.LightCombineMode.Off);
            skybox.setCullHint(Spatial.CullHint.Never);
            skybox.setTextureCombineMode(TextureCombineMode.Replace);
            skybox.updateRenderState();
            skybox.lockBounds();
            //skybox.lockMeshes();
            Entity e = new Entity("Skybox");
//            e.addComponent(ProcessorComponent.class, new TextureAnimationProcessor(up));
            SkyboxComponent sbc = wm.getRenderManager().createSkyboxComponent(skybox, true);
            e.addComponent(SkyboxComponent.class, sbc);

            skyboxProcessor = new SkyboxProcessor(wm, skybox);
            e.addComponent(SkyboxProcessor.class, skyboxProcessor);
View Full Code Here

Examples of org.jdesktop.mtgame.WorldManager

            final TexturedQuad quad = (TexturedQuad) node.getChild(0);

            RenderUpdater updater = new RenderUpdater() {

                public void update(Object arg0) {
                    WorldManager wm = (WorldManager) arg0;

                    BlendState as = (BlendState) wm.getRenderManager().createRendererState(RenderState.StateType.Blend);
                    // activate blending
                    as.setBlendEnabled(true);
                    // set the source function
                    as.setSourceFunction(BlendState.SourceFunction.SourceAlpha);
                    // set the destination function
                    as.setDestinationFunction(BlendState.DestinationFunction.OneMinusSourceAlpha);
                    // disable test
                    as.setTestEnabled(false);
                    // activate the blend state
                    as.setEnabled(true);

                    // assign the blender state to the node
                    quad.setRenderState(as);
                    quad.updateRenderState();

                    MaterialState ms = (MaterialState) quad.getRenderState(RenderState.StateType.Material);
                    if (ms == null) {
                        ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
                        quad.setRenderState(ms);
                    }

                    if (ms != null) {
                        ColorRGBA diffuse = ms.getDiffuse();
                        diffuse.a = 1.0f - transparency;
                        ms.setDiffuse(diffuse);
                    } else {
                        logger.warning("quad has no material state, unable to set transparency");
                        return;
                    }

                    ColorRGBA color = quad.getDefaultColor();
                    color.a = transparency;
                    quad.setDefaultColor(color);

                    wm.addToUpdateList(quad);
                }
            };
            WorldManager wm = ClientContextJME.getWorldManager();
            wm.addRenderUpdater(updater, wm);
        }
    }
View Full Code Here

Examples of org.jdesktop.mtgame.WorldManager

     * {@inheritDoc}
     */
    public WlAvatarCharacter getAvatarCharacter(Cell avatarCell,
            String userName, AvatarConfigInfo info) {

        WorldManager wm = ClientContextJME.getWorldManager();
        CharacterParams attributes = new MaleAvatarParams(userName);

        // Formulate the configuration URL to load the info. If null, then use
        // some default.
        String avatarURL = DEFAULT_URL;
View Full Code Here

Examples of org.jdesktop.mtgame.WorldManager

    }

    // For debug
    public static void printOrthoNodes () {
        // Print ortho nodes attached to the world manager
        WorldManager wm = ClientContextJME.getWorldManager();
        for (int i=0; i < wm.numEntities(); i++) {
            Entity e = wm.getEntity(i);
            RenderComponent rc = (RenderComponent) e.getComponent(RenderComponent.class);
            if (rc == null || !rc.getOrtho()) continue;
            System.err.println("Ortho node = " + rc.getSceneRoot());
            GraphicsUtils.printNode(rc.getSceneRoot());
        }
View Full Code Here

Examples of rakama.worldtools.WorldManager

{
    static String directory = "C:/Users/My Computer/AppData/Roaming/.minecraft/saves/mandelbrot";
   
    public static void main(String[] args) throws IOException
    {
        WorldManager manager = WorldManager.getWorldManager(new File(directory));
        BlockCanvas canvas = manager.getCanvas();
        renderMandelbrot(canvas, 512, 128, 4);
        manager.closeAll();
    }
View Full Code Here

Examples of rakama.worldtools.WorldManager

        if(length < 0){zSrc += length; length = -length;}

        File srcFile = new File(src);
        File destFile = new File(dest);
               
        WorldManager destManager = WorldManager.getWorldManager(new File(dest));
        WorldManager srcManager = destManager;
       
        if(!srcFile.equals(destFile))
            srcManager = WorldManager.getWorldManager(new File(src), true);

        WorldCanvas srcCanvas = srcManager.getCanvas();
        WorldCanvas destCanvas = destManager.getCanvas();
       
        // export schematic from source map
        Schematic schema = srcCanvas.exportSchematic(xSrc, ySrc, zSrc,
                            xSrc+width-1, ySrc+height-1, zSrc+length-1);

        int dx = xSrc - xDest;
        int dy = ySrc - yDest;
        int dz = zSrc - zDest;

        // regular expression for tp commands
        String space = "\\s+?";
        String target = "(@[prafPRAF](?:\\[.*\\])*?)";
        String number = "(~?-?[\\p{Digit}]+?)";
        String tpstr = "/tp" + space + target + space + number
                        + space + number + space + number + "\\s*?";

        // regular expression for general commands
        String argstr = "/([^\\s]*)" + space + "(.*)";
        String argsplit = "(@[prafPRAF])(\\[.*\\])*?)";
       
        Pattern apattern = Pattern.compile(argstr);
        Pattern tpattern = Pattern.compile(tpstr);

        // edit command block teleport coordinates   
        List<TileEntity> tileEntities = schema.getTileEntities();
        for(TileEntity e : new ArrayList<TileEntity>(tileEntities))
        {
            if(e instanceof CommandBlock)
            {
                CommandBlock cb = (CommandBlock)e;
                int xc = cb.getX();
                int yc = cb.getY();
                int zc = cb.getZ();
                String cmd = cb.getCommand();
               
                if(cmd == null)
                    continue;               

                Matcher tmatcher = tpattern.matcher(cmd);
               
                if(tmatcher.matches())
                {
                    String tar = tmatcher.group(1);
                    String xstr = tmatcher.group(2);
                    String ystr = tmatcher.group(3);
                    String zstr = tmatcher.group(4);
                                       
                    int xt = Integer.parseInt(xstr.replace("~", "")) - dx;
                    int yt = Integer.parseInt(ystr.replace("~", "")) - dy;
                    int zt = Integer.parseInt(zstr.replace("~", "")) - dz;
                   
                    xstr = xstr.startsWith("~") ? xstr : Integer.toString(xt);
                    ystr = ystr.startsWith("~") ? ystr : Integer.toString(yt);
                    zstr = zstr.startsWith("~") ? zstr : Integer.toString(zt);        
                       
                    cmd = "/tp " + tar + " " + xt + " " + yt + " " + zt;
                }
               
                Matcher amatcher = apattern.matcher(cmd);
               
                if(amatcher.matches())
                {
                    String arg = tmatcher.group(1);
                    String val = tmatcher.group(2);
                   
                    // TODO: split val into tokens, fix the xyz ones
                }
                else
                    continue;
                       
                cb = EntityFactory.getDefaultFactory().createCommandBlock(xc, yc, zc, cmd);
                schema.removeTileEntity(e);
                schema.addTileEntity(cb);
            }
        }
       
        // remove existing entities from target region
        List<Entity> removeEntities = destCanvas.getEntities(xDest, yDest, zDest,
                xDest+width-1, yDest+height-1, zDest+length-1);
        for(Entity e : new ArrayList<Entity>(removeEntities))
            destCanvas.removeEntity(e);

        // remove existing tile entities from target region
        List<TileEntity> removeTiles = destCanvas.getTileEntities(xDest, yDest, zDest,
                xDest+width-1, yDest+height-1, zDest+length-1);
        for(TileEntity e : new ArrayList<TileEntity>(removeTiles))
            destCanvas.removeTileEntity(e);
       
        // import schematic to destination map
        destCanvas.importSchematic(xDest, yDest, zDest, schema);
       
        // copy biomes from source to destination
        if(copy_biomes)
        {
            for(int z=zSrc; z<zSrc+length; z++)
            {
                for(int x=xSrc; x<xSrc+width; x++)
                {
                    int biome = srcCanvas.getBiome(x, z);
                    if(biome < 0)
                        biome = 0;
                   
                    destCanvas.setBiome(x - dx, z - dz, biome);
                }
            }
        }
       
        destManager.closeAll();
        srcManager.closeAll();
       
        System.out.println("Success...");
    }
View Full Code Here
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.