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


Java FrameBuffer.setColorBuffer方法代码示例

本文整理汇总了Java中com.jme3.texture.FrameBuffer.setColorBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java FrameBuffer.setColorBuffer方法的具体用法?Java FrameBuffer.setColorBuffer怎么用?Java FrameBuffer.setColorBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.texture.FrameBuffer的用法示例。


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

示例1: ImageCapturer

import com.jme3.texture.FrameBuffer; //导入方法依赖的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

示例2: JfxRenderer

import com.jme3.texture.FrameBuffer; //导入方法依赖的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

示例3: setupOffBuffer

import com.jme3.texture.FrameBuffer; //导入方法依赖的package包/类
private void setupOffBuffer() {
        image = new BufferedImage(width, height,
                BufferedImage.TYPE_4BYTE_ABGR);
        cpuBuf = BufferUtils.createByteBuffer(width * height * 4);
//        cpuArray = new byte[width * height * 4];
        offBuffer = new FrameBuffer(width, height, 0);
        //setup framebuffer to use texture
        offBuffer.setDepthBuffer(Format.Depth);
        offBuffer.setColorBuffer(Format.RGBA8);
        //set viewport to render to offscreen framebuffer
        viewPort.setOutputFrameBuffer(offBuffer);
        camera.resize(width, height, false);
    }
 
开发者ID:jMonkeyEngine,项目名称:sdk,代码行数:14,代码来源:OffScenePanel.java

示例4: fillMatrix

import com.jme3.texture.FrameBuffer; //导入方法依赖的package包/类
/**
		 * Renders the given scene in a top-down manner in the given matrix
		 * @param matrix
		 * @param scene 
		 */
		private void fillMatrix(Matrix matrix, Spatial scene, boolean max) {
			//init
			Camera cam = new Camera(size, size);
			cam.setParallelProjection(true);
			ViewPort view = new ViewPort("Off", cam);
			view.setClearFlags(true, true, true);
			FrameBuffer buffer = new FrameBuffer(size, size, 1);
			buffer.setDepthBuffer(Image.Format.Depth);
			buffer.setColorBuffer(Image.Format.RGBA32F);
			view.setOutputFrameBuffer(buffer);
			view.attachScene(scene);
			//render
			scene.updateGeometricState();
			view.setEnabled(true);
			app.getRenderManager().renderViewPort(view, 0);
			//retrive data
			ByteBuffer data = BufferUtils.createByteBuffer(size*size*4*4);
			app.getRenderer().readFrameBufferWithFormat(buffer, data, Image.Format.RGBA32F);
			data.rewind();
			for (int y=0; y<size; ++y) {
				for (int x=0; x<size; ++x) {
//					byte d = data.get();
//					matrix.set(x, y, (d & 0xff) / 255.0);
//					data.get(); data.get(); data.get();
					double v = data.getFloat();
					double old = matrix.get(x, y);
					if (max) {
						v = Math.max(v, old);
					} else {
						v += old;
					}
					matrix.set(x, y, v);
					data.getFloat(); data.getFloat(); data.getFloat();
				}
			}
		}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:42,代码来源:SketchTerrain.java

示例5: TransfertImage

import com.jme3.texture.FrameBuffer; //导入方法依赖的package包/类
TransfertImage(int width, int height) {
	this.width = width;
	this.height = height;
	fb = new FrameBuffer(width, height, 1);
	fb.setDepthBuffer(Format.Depth);
	fb.setColorBuffer(Format.BGRA8);
	byteBuf = BufferUtils.createByteBuffer(width * height * BGRA_size);
}
 
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:9,代码来源:SceneProcessorCaptureToBGRA.java

示例6: reshapeInThread

import com.jme3.texture.FrameBuffer; //导入方法依赖的package包/类
private void reshapeInThread(int width, int height) {
        byteBuf = BufferUtils.ensureLargeEnough(byteBuf, width * height * 4);
        intBuf = byteBuf.asIntBuffer();
        
        fb = new FrameBuffer(width, height, 1);
        fb.setDepthBuffer(Format.Depth);
        fb.setColorBuffer(Format.RGB8);
        
        if (attachAsMain){
            rm.getRenderer().setMainFrameBufferOverride(fb);
        }
        
        synchronized (lock){
            img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        }
        
//        synchronized (lock){
//            img = (BufferedImage) getGraphicsConfiguration().createCompatibleImage(width, height);
//        }
        
        AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
        tx.translate(0, -img.getHeight());
        transformOp = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
        
        for (ViewPort vp : viewPorts){
            if (!attachAsMain){
                vp.setOutputFrameBuffer(fb);
            }
            vp.getCamera().resize(width, height, true);
            
            // NOTE: Hack alert. This is done ONLY for custom framebuffers.
            // Main framebuffer should use RenderManager.notifyReshape().
            for (SceneProcessor sp : vp.getProcessors()){
                sp.reshape(vp, width, height);
            }
        }
    }
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:38,代码来源:AwtPanel.java

示例7: setupOffscreenView

import com.jme3.texture.FrameBuffer; //导入方法依赖的package包/类
public void setupOffscreenView(){
        offCamera = new Camera(width, height);

        // create a pre-view. a view that is rendered before the main view
        offView = renderManager.createPreView("Offscreen View", offCamera);
        offView.setBackgroundColor(ColorRGBA.DarkGray);
        offView.setClearFlags(true, true, true);
        
        // this will let us know when the scene has been rendered to the 
        // frame buffer
        offView.addProcessor(this);

        // create offscreen framebuffer
        offBuffer = new FrameBuffer(width, height, 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
//        offTex = new Texture2D(width, height, Format.RGBA8);

        //setup framebuffer to use renderbuffer
        // this is faster for gpu -> cpu copies
        offBuffer.setDepthBuffer(Format.Depth);
        offBuffer.setColorBuffer(Format.RGBA8);
//        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);
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:42,代码来源:TestRenderToMemory.java

示例8: fillSlopeMatrix

import com.jme3.texture.FrameBuffer; //导入方法依赖的package包/类
/**
		 * Renders the given scene in a top-down manner in the given matrix
		 * @param matrix
		 * @param scene 
		 */
		private void fillSlopeMatrix(Spatial scene) {
			//init
			Camera cam = new Camera(size, size);
			cam.setParallelProjection(true);
			ViewPort view = new ViewPort("Off", cam);
			view.setClearFlags(true, true, true);
			view.setBackgroundColor(new ColorRGBA(0.5f, 0.5f, 0.5f, 0f));
			FrameBuffer buffer = new FrameBuffer(size, size, 1);
			buffer.setDepthBuffer(Image.Format.Depth);
			buffer.setColorBuffer(Image.Format.RGBA32F);
			view.setOutputFrameBuffer(buffer);
			view.attachScene(scene);
			//render
			scene.updateGeometricState();
			view.setEnabled(true);
			app.getRenderManager().renderViewPort(view, 0);
			//retrive data
			ByteBuffer data = BufferUtils.createByteBuffer(size*size*4*4);
			app.getRenderer().readFrameBufferWithFormat(buffer, data, Image.Format.RGBA32F);
			data.rewind();
			for (int y=0; y<size; ++y) {
				for (int x=0; x<size; ++x) {
//					double gx = (((data.get() & 0xff) / 256.0) - 0.5) * 2;
//					double gy = (((data.get() & 0xff) / 256.0) - 0.5) * 2;
					double gx = (data.getFloat() - 0.5) * 2;
					double gy = (data.getFloat() - 0.5) * 2;
					double s = Math.sqrt(gx*gx + gy*gy);
					if (s==0) {
						gx=0; gy=0; s=1;
					}
					gradX.set(x, y, (gx / s) + gradX.get(x, y));
					gradY.set(x, y, (gy / s) + gradY.get(x, y));
//					double v = (((data.get() & 0xff) / 255.0) - 0.5);
					double v = (data.getFloat() - 0.5);
					if (Math.abs(v)<0.002) {
						v=0;
					}
					gradH.set(x, y, v*2 + gradH.get(x, y));
//					data.get();
					double a = data.getFloat();
					alpha.set(x, y, a);
				}
			}
		}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:50,代码来源:SketchTerrain.java

示例9: setupPreviewView

import com.jme3.texture.FrameBuffer; //导入方法依赖的package包/类
public void setupPreviewView() {
    if (offCamera == null) {
        offCamera = new Camera(width, height);
    } else {
        offCamera.resize(width, height, true);
    }

    // create a pre-view. a view that is rendered before the main view
    if (offView == null) {
        offView = SceneApplication.getApplication().getRenderManager().createPreView("Offscreen View", offCamera);
        offView.setBackgroundColor(ColorRGBA.DarkGray);
        offView.setClearFlags(true, true, true);
        offView.addProcessor(this);
        // setup framebuffer's scene
        light = new PointLight();
        light.setPosition(offCamera.getLocation());
        light.setColor(ColorRGBA.White);
        previewNode.addLight(light);

        // attach the scene to the viewport to be rendered
        offView.attachScene(previewNode);
    }

    cpuBuf = BufferUtils.createByteBuffer(width * height * 4);
    cpuArray = new byte[width * height * 4];

    // create offscreen framebuffer        
    offBuffer = new FrameBuffer(width, height, 0);

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

    //setup framebuffer to use texture
    offBuffer.setDepthBuffer(Format.Depth);
    offBuffer.setColorBuffer(Format.RGBA8);

    //set viewport to render to offscreen framebuffer
    offView.setOutputFrameBuffer(offBuffer);


}
 
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:44,代码来源:ScenePreviewProcessor.java


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