当前位置: 首页>>代码示例>>Java>>正文


Java Format类代码示例

本文整理汇总了Java中com.jme3.texture.Image.Format的典型用法代码示例。如果您正苦于以下问题:Java Format类的具体用法?Java Format怎么用?Java Format使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Format类属于com.jme3.texture.Image包,在下文中一共展示了Format类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadDX10Header

import com.jme3.texture.Image.Format; //导入依赖的package包/类
private void loadDX10Header() throws IOException {
    int dxgiFormat = in.readInt();
    if (dxgiFormat == 0) {
            pixelFormat = Format.ETC1;
            bpp = 4;
    } else {
            throw new IOException("Unsupported DX10 format: " + dxgiFormat);
    }
    compressed = true;
    
    int resDim = in.readInt();
    if (resDim == DX10DIM_TEXTURE3D) {
        texture3D = true;
    }
    int miscFlag = in.readInt();
    int arraySize = in.readInt();
    if (is(miscFlag, DX10MISC_TEXTURECUBE)) {
        // mark texture as cube
        if (arraySize != 6) {
            throw new IOException("Cubemaps should consist of 6 images!");
        }
    }

    in.skipBytes(4); // skip reserved value
}
 
开发者ID:riccardobl,项目名称:DDSWriter,代码行数:26,代码来源:DDSLoader.java

示例2: BasicShadowRenderer

import com.jme3.texture.Image.Format; //导入依赖的package包/类
/**
 * Creates a BasicShadowRenderer
 * @param manager the asset manager
 * @param size the size of the shadow map (the map is square)
 */
public BasicShadowRenderer(AssetManager manager, int size) {
    shadowFB = new FrameBuffer(size, size, 1);
    shadowMap = new Texture2D(size, size, Format.Depth);
    shadowFB.setDepthTexture(shadowMap);
    shadowCam = new Camera(size, size);

    preshadowMat = new Material(manager, "Common/MatDefs/Shadow/PreShadow.j3md");
    postshadowMat = new Material(manager, "Common/MatDefs/Shadow/PostShadow.j3md");
    postshadowMat.setTexture("ShadowMap", shadowMap);

    dispPic.setTexture(manager, shadowMap, false);

    for (int i = 0; i < points.length; i++) {
        points[i] = new Vector3f();
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:BasicShadowRenderer.java

示例3: checkImagesForCubeMap

import com.jme3.texture.Image.Format; //导入依赖的package包/类
private static void checkImagesForCubeMap(Image ... images){
    if (images.length == 1) return;

    Format fmt = images[0].getFormat();
    int width = images[0].getWidth();
    int size = images[0].getData(0).capacity();

    checkImage(images[0]);

    for (int i = 1; i < images.length; i++){
        Image image = images[i];
        checkImage(images[i]);
        if (image.getFormat() != fmt) throw new IllegalArgumentException("Images must have same format");
        if (image.getWidth() != width) throw new IllegalArgumentException("Images must have same resolution");
        if (image.getData(0).capacity() != size) throw new IllegalArgumentException("Images must have same size");
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:SkyFactory.java

示例4: loadDX10Header

import com.jme3.texture.Image.Format; //导入依赖的package包/类
private void loadDX10Header() throws IOException{
    int dxgiFormat = in.readInt();
    if (dxgiFormat != 83){
        throw new IOException("Only DXGI_FORMAT_BC5_UNORM " +
                              "is supported for DirectX10 DDS! Got: "+dxgiFormat);
    }
    pixelFormat = Format.LATC;
    bpp = 8;
    compressed = true;

    int resDim = in.readInt();
    if (resDim == DX10DIM_TEXTURE3D){
        // mark texture as 3D
    }
    int miscFlag = in.readInt();
    int arraySize = in.readInt();
    if (is(miscFlag, DX10MISC_TEXTURECUBE)){
        // mark texture as cube
        if (arraySize != 6){
            throw new IOException("Cubemaps should consist of 6 images!");
        }
    }
    
    in.skipBytes(4); // skip reserved value
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:DDSLoader.java

示例5: ImageCapturer

import com.jme3.texture.Image.Format; //导入依赖的package包/类
public ImageCapturer(Camera cam, RenderManager renderManager, Node camNode, Node rootNode) {
        this.cam = cam;
        this.renderManager = renderManager;
        this.camNode = camNode;

//        bbuf = BufferUtils.createByteBuffer(cam.getWidth() * cam.getHeight() * 4);
        bbuf = BufferUtils.createByteBuffer(cam.getWidth() * cam.getHeight() * 4);
        image = new BufferedImage(cam.getWidth(), cam.getHeight(), IMAGE_TYPE);

        vp = renderManager.createPreView(cam.getName() + " recorder", cam);
        vp.setBackgroundColor(ColorRGBA.Black);
        vp.setClearFlags(true, true, true);
        fbuf = new FrameBuffer(cam.getWidth(), cam.getHeight(), 1);
        fbuf.setDepthBuffer(Format.Depth);
        fbuf.setColorBuffer(Format.RGBA8);
        vp.setOutputFrameBuffer(fbuf);
        vp.attachScene(rootNode);                
    }
 
开发者ID:dwhuang,项目名称:SMILE,代码行数:19,代码来源:ImageCapturer.java

示例6: JfxRenderer

import com.jme3.texture.Image.Format; //导入依赖的package包/类
public JfxRenderer(ImageView imageView, int width, int height, boolean depthBuffer) {
    this.imageView = imageView;
    this.width = width;
    this.height = height;
    this.byteBuffer = BufferUtils.createByteBuffer(width * height * 4);
    this.scanlineStride = width * 4;
    this.renderImage = new WritableImage(width, height);
    this.imageView.setImage(renderImage);
    if (depthBuffer) {
        frameBuffer = new FrameBuffer(width, height, 1);
        frameBuffer.setDepthBuffer(Format.Depth);
        frameBuffer.setColorBuffer(Format.BGRA8);
    } else {
        frameBuffer = null;
    }
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:17,代码来源:JfxRenderer.java

示例7: generateNormalMap

import com.jme3.texture.Image.Format; //导入依赖的package包/类
/**
 * Generates a normal map from a base texture. The normal map is based
 * on a displacement map that is automatically generated beforehand. Both
 * maps are printed as images.
 * 
 * @param tex The texture used as base.
 * @param flipX Used to flip the texture.
 * @param flipY Used to flip the texture.
 * @param normalStrength Edges becomes more accented with a higher normalStrength.
 */
public void generateNormalMap(Texture tex, boolean flipX, boolean flipY, float normalStrength){
    this.normalStrength = normalStrength;
    float[] disp = generateDispMap(tex,flipX,flipY);
    byte[] normals = generateNormMap(disp);
    byte[] dispByte = new byte[disp.length];
    for(int i = 0; i < disp.length; i++){
        dispByte[i] = (byte) (disp[i]*255);
    }
    //Don't print another displacement map if image uses a grayscale format.
    if(tex.getImage().getFormat() != Format.Luminance8 && 
            tex.getImage().getFormat() != Format.Luminance16F){
        printImage(dispByte,1,tex);
    }
    printImage(normals,3,tex);
}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:26,代码来源:NormDispGenerator.java

示例8: convertTextureFormat

import com.jme3.texture.Image.Format; //导入依赖的package包/类
public static int convertTextureFormat(Format fmt){
    switch (fmt){
        case Alpha16:
        case Alpha8:
            return GL.GL_ALPHA;
        case Luminance8Alpha8:
        case Luminance16Alpha16:
            return GL.GL_LUMINANCE_ALPHA;
        case Luminance8:
        case Luminance16:
            return GL.GL_LUMINANCE;
        case RGB10:
        case RGB16:
        case BGR8:
        case RGB8:
        case RGB565:
            return GL.GL_RGB;
        case RGB5A1:
        case RGBA16:
        case RGBA8:
            return GL.GL_RGBA;
        default:
            throw new UnsupportedOperationException("Unrecognized format: "+fmt);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:26,代码来源:TextureUtil.java

示例9: getTinAndAlpha

import com.jme3.texture.Image.Format; //导入依赖的package包/类
/**
 * This method return texture intensity and alpha value.
 * 
 * @param data
 *            the texture data
 * @param imageFormat
 *            the image format
 * @param neg
 *            indicates if the texture is negated
 * @param result
 *            the table (2 elements) where the result is being stored
 */
protected void getTinAndAlpha(ByteBuffer data, Format imageFormat, boolean neg, float[] result) {
    byte pixelValue = data.get();// at least one byte is always taken
    float firstPixelValue = pixelValue >= 0 ? pixelValue / 255.0f : 1.0f - ~pixelValue / 255.0f;
    switch (imageFormat) {
        case Luminance8:
            result[0] = neg ? 1.0f - firstPixelValue : firstPixelValue;
            result[1] = 1.0f;
            break;
        case Luminance8Alpha8:
            result[0] = neg ? 1.0f - firstPixelValue : firstPixelValue;
            pixelValue = data.get();
            result[1] = pixelValue >= 0 ? pixelValue / 255.0f : 1.0f - ~pixelValue / 255.0f;
            break;
        case Luminance16:
        case Luminance16Alpha16:
        case Luminance16F:
        case Luminance16FAlpha16F:
        case Luminance32F:
            LOGGER.log(Level.WARNING, "Image type not yet supported for blending: {0}", imageFormat);
            break;
        default:
            throw new IllegalStateException("Invalid image format type for Luminance texture blender: " + imageFormat);
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:37,代码来源:TextureBlenderLuminance.java

示例10: readData

import com.jme3.texture.Image.Format; //导入依赖的package包/类
@Override
public void readData(Structure tex, BlenderContext blenderContext) {
    super.readData(tex, blenderContext);
    voronoiWeights = new float[4];
    voronoiWeights[0] = ((Number) tex.getFieldValue("vn_w1")).floatValue();
    voronoiWeights[1] = ((Number) tex.getFieldValue("vn_w2")).floatValue();
    voronoiWeights[2] = ((Number) tex.getFieldValue("vn_w3")).floatValue();
    voronoiWeights[3] = ((Number) tex.getFieldValue("vn_w4")).floatValue();
    noisesize = ((Number) tex.getFieldValue("noisesize")).floatValue();
    outscale = ((Number) tex.getFieldValue("ns_outscale")).floatValue();
    mexp = ((Number) tex.getFieldValue("vn_mexp")).floatValue();
    distanceType = ((Number) tex.getFieldValue("vn_distm")).intValue();
    voronoiColorType = ((Number) tex.getFieldValue("vn_coltype")).intValue();
    hashPoint = voronoiColorType != 0 ? new float[3] : null;
    weightSum = voronoiWeights[0] + voronoiWeights[1] + voronoiWeights[2] + voronoiWeights[3];
    if (weightSum != 0.0f) {
        weightSum = outscale / weightSum;
    }
    if (voronoiColorType != 0 || colorBand != null) {
        this.imageFormat = Format.RGBA8;
    }
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:23,代码来源:TextureGeneratorVoronoi.java

示例11: loadDX10Header

import com.jme3.texture.Image.Format; //导入依赖的package包/类
private void loadDX10Header() throws IOException {
    int dxgiFormat = in.readInt();
    if (dxgiFormat != 83) {
        throw new IOException("Only DXGI_FORMAT_BC5_UNORM "
                + "is supported for DirectX10 DDS! Got: " + dxgiFormat);
    }
    pixelFormat = Format.LATC;
    bpp = 8;
    compressed = true;

    int resDim = in.readInt();
    if (resDim == DX10DIM_TEXTURE3D) {
        texture3D = true;
    }
    int miscFlag = in.readInt();
    int arraySize = in.readInt();
    if (is(miscFlag, DX10MISC_TEXTURECUBE)) {
        // mark texture as cube
        if (arraySize != 6) {
            throw new IOException("Cubemaps should consist of 6 images!");
        }
    }

    in.skipBytes(4); // skip reserved value
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:26,代码来源:DDSLoader.java

示例12: TextureArray

import com.jme3.texture.Image.Format; //导入依赖的package包/类
/**
 * Construct a TextureArray from the given list of images.
 * To check if a hardware supports TextureArray check : 
 * renderManager.getRenderer().getCaps().contains(Caps.TextureArray)
 * @param images 
 */
public TextureArray(List<Image> images) {
    super();
    
    int width = images.get(0).getWidth();
    int height = images.get(0).getHeight();
    Format format = images.get(0).getFormat();
    Image arrayImage = new Image(format, width, height, null);

    for (Image img : images) {
        if (img.getHeight() != height || img.getWidth() != width) {
            throw new IllegalArgumentException("Images in texture array must have same dimensions");
        }
        if (img.getFormat() != format) {
            throw new IllegalArgumentException("Images in texture array must have same format");
        }
        
        arrayImage.addData(img.getData(0));
    }
    setImage(arrayImage);
}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:27,代码来源:TextureArray.java

示例13: checkImagesForCubeMap

import com.jme3.texture.Image.Format; //导入依赖的package包/类
private static void checkImagesForCubeMap(@NotNull final Image... images) {

        if (images.length == 1) {
            return;
        }

        Format fmt = images[0].getFormat();
        int width = images[0].getWidth();
        int height = images[0].getHeight();

        ByteBuffer data = images[0].getData(0);
        int size = data != null ? data.capacity() : 0;

        checkImage(images[0]);

        for (int i = 1; i < images.length; i++) {
            Image image = images[i];
            checkImage(images[i]);
            if (image.getFormat() != fmt) {
                throw new IllegalArgumentException("Images must have same format");
            }
            if (image.getWidth() != width || image.getHeight() != height) {
                throw new IllegalArgumentException("Images must have same resolution");
            }
            ByteBuffer data2 = image.getData(0);
            if (data2 != null) {
                if (data2.capacity() != size) {
                    throw new IllegalArgumentException("Images must have same size");
                }
            }
        }
    }
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:33,代码来源:JmbSkyFactory.java

示例14: simpleInitApp

import com.jme3.texture.Image.Format; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    int w = settings.getWidth();
    int h = settings.getHeight();

    //setup framebuffer
    fb = new FrameBuffer(w, h, 1);

    Texture2D fbTex = new Texture2D(w, h, Format.RGBA8);
    fb.setDepthBuffer(Format.Depth);
    fb.setColorTexture(fbTex);

    // setup framebuffer's scene
    Sphere sphMesh = new Sphere(20, 20, 1);
    Material solidColor = assetManager.loadMaterial("Common/Materials/RedColor.j3m");

    Geometry sphere = new Geometry("sphere", sphMesh);
    sphere.setMaterial(solidColor);
    fbNode.attachChild(sphere);

    //setup main scene
    Picture p = new Picture("Picture");
    p.setPosition(0, 0);
    p.setWidth(w);
    p.setHeight(h);
    p.setTexture(assetManager, fbTex, false);

    rootNode.attachChild(p);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:30,代码来源:TestFBOPassthrough.java

示例15: setupOffscreenView

import com.jme3.texture.Image.Format; //导入依赖的package包/类
public Texture setupOffscreenView(){
    Camera offCamera = new Camera(512, 512);

    offView = renderManager.createPreView("Offscreen View", offCamera);
    offView.setClearFlags(true, true, true);
    offView.setBackgroundColor(ColorRGBA.DarkGray);

    // create offscreen framebuffer
    FrameBuffer offBuffer = new FrameBuffer(512, 512, 1);

    //setup framebuffer's cam
    offCamera.setFrustumPerspective(45f, 1f, 1f, 1000f);
    offCamera.setLocation(new Vector3f(0f, 0f, -5f));
    offCamera.lookAt(new Vector3f(0f, 0f, 0f), Vector3f.UNIT_Y);

    //setup framebuffer's texture
    Texture2D offTex = new Texture2D(512, 512, Format.RGBA8);
    offTex.setMinFilter(Texture.MinFilter.Trilinear);
    offTex.setMagFilter(Texture.MagFilter.Bilinear);

    //setup framebuffer to use texture
    offBuffer.setDepthBuffer(Format.Depth);
    offBuffer.setColorTexture(offTex);
    
    //set viewport to render to offscreen framebuffer
    offView.setOutputFrameBuffer(offBuffer);

    // setup framebuffer's scene
    Box boxMesh = new Box(Vector3f.ZERO, 1,1,1);
    Material material = assetManager.loadMaterial("Interface/Logo/Logo.j3m");
    offBox = new Geometry("box", boxMesh);
    offBox.setMaterial(material);

    // attach the scene to the viewport to be rendered
    offView.attachScene(offBox);
    
    return offTex;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:39,代码来源:TestRenderToTexture.java


注:本文中的com.jme3.texture.Image.Format类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。