本文整理汇总了Java中com.jme3.texture.Image.Format.RGB8属性的典型用法代码示例。如果您正苦于以下问题:Java Format.RGB8属性的具体用法?Java Format.RGB8怎么用?Java Format.RGB8使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.jme3.texture.Image.Format
的用法示例。
在下文中一共展示了Format.RGB8属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertToNormalMapTexture
/**
* This method converts the given texture into normal-map texture.
*
* @param source
* the source texture
* @param strengthFactor
* the normal strength factor
* @return normal-map texture
*/
public Image convertToNormalMapTexture(Image source, float strengthFactor) {
BufferedImage sourceImage = ImageToAwt.convert(source, false, false, 0);
BufferedImage heightMap = new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
BufferedImage bumpMap = new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
ColorConvertOp gscale = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
gscale.filter(sourceImage, heightMap);
Vector3f S = new Vector3f();
Vector3f T = new Vector3f();
Vector3f N = new Vector3f();
for (int x = 0; x < bumpMap.getWidth(); ++x) {
for (int y = 0; y < bumpMap.getHeight(); ++y) {
// generating bump pixel
S.x = 1;
S.y = 0;
S.z = strengthFactor * this.getHeight(heightMap, x + 1, y) - strengthFactor * this.getHeight(heightMap, x - 1, y);
T.x = 0;
T.y = 1;
T.z = strengthFactor * this.getHeight(heightMap, x, y + 1) - strengthFactor * this.getHeight(heightMap, x, y - 1);
float den = (float) Math.sqrt(S.z * S.z + T.z * T.z + 1);
N.x = -S.z;
N.y = -T.z;
N.z = 1;
N.divideLocal(den);
// setting thge pixel in the result image
bumpMap.setRGB(x, y, this.vectorToColor(N.x, N.y, N.z));
}
}
ByteBuffer byteBuffer = BufferUtils.createByteBuffer(source.getWidth() * source.getHeight() * 3);
ImageToAwt.convert(bumpMap, Format.RGB8, byteBuffer);
return new Image(Format.RGB8, source.getWidth(), source.getHeight(), byteBuffer);
}
示例2: getTexture
/**
* This method creates a RGB8 texture with the sizes of 10x10x10 pixels.
*/
private Texture getTexture() throws IOException {
ArrayList<ByteBuffer> data = new ArrayList<ByteBuffer>(1);
ByteBuffer bb = BufferUtils.createByteBuffer(10 * 10 * 10 * 3);//all data must be inside one buffer
for (int i = 0; i < 10; ++i) {
for (int j = 0; j < 10 * 10; ++j) {
bb.put((byte) (255f*i/10f));
bb.put((byte) (255f*i/10f));
bb.put((byte) (255f));
}
}
bb.rewind();
data.add(bb);
return new Texture3D(new Image(Format.RGB8, 10, 10, 10, data));
}
示例3: readTextureImage
private void readTextureImage(){
// texture image def
String ln = scan.nextLine();
String path = null;
// find extension
int extStart = ln.lastIndexOf(".");
for (int i = extStart; i < ln.length(); i++){
char c = ln.charAt(i);
if (Character.isWhitespace(c)){
// extension ends here
path = ln.substring(0, i).trim();
ln = ln.substring(i+1).trim();
break;
}
}
if (path == null){
path = ln.trim();
ln = "";
}
Scanner lnScan = new Scanner(ln);
String mips = null;
String type = null;
if (lnScan.hasNext()){
// more params
type = lnScan.next();
// if (!lnScan.hasNext("\n") && lnScan.hasNext()){
// mips = lnScan.next();
// if (lnScan.hasNext()){
// even more params..
// will have to ignore
// }
// }
}
boolean genMips = true;
boolean cubic = false;
if (type != null && type.equals("0"))
genMips = false;
if (type != null && type.equals("cubic")){
cubic = true;
}
TextureKey key = new TextureKey(folderName + path, false);
key.setGenerateMips(genMips);
key.setAsCube(cubic);
Texture loadedTexture = assetManager.loadTexture(key);
if (loadedTexture == null){
ByteBuffer tempData = BufferUtils.createByteBuffer(3);
tempData.put((byte)0xFF).put((byte)0x00).put((byte)0x00);
texture = new Texture2D(new Image(Format.RGB8, 1,1,tempData));
logger.log(Level.WARNING, "Using RED texture instead of {0}", path);
}else{
texture.setImage(loadedTexture.getImage());
texture.setMinFilter(loadedTexture.getMinFilter());
texture.setKey(loadedTexture.getKey());
// XXX: Is this really neccessary?
texture.setWrap(WrapMode.Repeat);
if (texName != null){
texture.setName(texName);
texName = null;
}else{
texture.setName(key.getName());
}
}
}
示例4: initialize
public void initialize(RenderManager rm, ViewPort vp){
if (!enabled)
return;
renderer = rm.getRenderer();
renderManager = rm;
viewPort = vp;
// loadInitial()
fsQuad = new Picture("HDR Fullscreen Quad");
Format lumFmt = Format.RGB8;
scene64FB = new FrameBuffer(64, 64, 1);
scene64 = new Texture2D(64, 64, lumFmt);
scene64FB.setColorTexture(scene64);
scene64.setMagFilter(fbMagFilter);
scene64.setMinFilter(fbMinFilter);
scene8FB = new FrameBuffer(8, 8, 1);
scene8 = new Texture2D(8, 8, lumFmt);
scene8FB.setColorTexture(scene8);
scene8.setMagFilter(fbMagFilter);
scene8.setMinFilter(fbMinFilter);
scene1FB[0] = new FrameBuffer(1, 1, 1);
scene1[0] = new Texture2D(1, 1, lumFmt);
scene1FB[0].setColorTexture(scene1[0]);
scene1FB[1] = new FrameBuffer(1, 1, 1);
scene1[1] = new Texture2D(1, 1, lumFmt);
scene1FB[1].setColorTexture(scene1[1]);
// prepare tonemap shader
tone = new Material(manager, "Common/MatDefs/Hdr/ToneMap.j3md");
tone.setFloat("A", 0.18f);
tone.setFloat("White", 100);
// load();
int w = vp.getCamera().getWidth();
int h = vp.getCamera().getHeight();
reshape(vp, w, h);
}
示例5: getPlaceholderImage
public static Image getPlaceholderImage(){
ByteBuffer tempData = BufferUtils.createByteBuffer(3 * 4 * 4);
tempData.put(imageData).flip();
return new Image(Format.RGB8, 4, 4, tempData);
}