本文整理汇总了Java中com.jme3.texture.image.ImageRaster类的典型用法代码示例。如果您正苦于以下问题:Java ImageRaster类的具体用法?Java ImageRaster怎么用?Java ImageRaster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageRaster类属于com.jme3.texture.image包,在下文中一共展示了ImageRaster类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: fromImageRaster
import com.jme3.texture.image.ImageRaster; //导入依赖的package包/类
public static Texel fromImageRaster(ImageRaster ir, Vector2f from, Vector2f to) {
Vector4f pixels[][]=new Vector4f[(int)(to.x-from.x)][(int)(to.y-from.y)];
for(int y=(int)from.y;y<to.y;y++){
for(int x=(int)from.x;x<to.x;x++){
int xl=(int)(x-from.x);
int yl=(int)(y-from.y);
Vector4f c;
if(x>=ir.getWidth()||y>=ir.getHeight()||x<0||y<0){
LOGGER.warn("Invalid coordinates x{} y{} for image w{} h{}. Use padding color.",x,y,ir.getWidth(),ir.getHeight());
c=PADDINGPX_COLOR;
}else{
c=ir.getPixel(x,y).toVector4f();
}
pixels[xl][yl]=c;
}
}
Texel tx=new Texel(PixelFormat.FLOAT_NORMALIZED_RGBA,pixels);
tx.AREA=new Vector2f[]{from,to
};
return tx;
}
开发者ID:riccardobl,项目名称:DDSWriter,代码行数:25,代码来源:Texel.java
示例2: updateTexture
import com.jme3.texture.image.ImageRaster; //导入依赖的package包/类
private void updateTexture(ImageRaster raster) {
for (int i=1; i<points.size(); ++i) {
Vector2f p1 = points.get(i-1);
Vector2f p2 = points.get(i);
int x1 = Math.max(0, (int) Math.floor(p1.x * RESOLUTION));
int x2 = Math.min(RESOLUTION-1, (int) Math.ceil(p2.x * RESOLUTION));
ColorRGBA c = new ColorRGBA();
for (int x=x1; x<=x2; ++x) {
float v = p1.y + (p2.y - p1.y) * ((x-x1)/(float)(x2-x1));
c = raster.getPixel(x, 0, c);
switch (textureChannel) {
case 0: c.r = v; break;
case 1: c.g = v; break;
case 2: c.b = v; break;
case 3: c.a = v; break;
}
raster.setPixel(x, 0, c);
}
}
}
开发者ID:shamanDevel,项目名称:jME3-OpenCL-Library,代码行数:21,代码来源:TransferFunctionEditor.java
示例3: write
import com.jme3.texture.image.ImageRaster; //导入依赖的package包/类
public void write(ImageRaster dst, Vector2f from, Vector2f to) {
for(int y=(int)from.y;y<to.y;y++){
for(int x=(int)from.x;x<to.x;x++){
int xl=(int)(x-from.x);
int yl=(int)(y-from.y);
Vector4f c=get(PixelFormat.FLOAT_NORMALIZED_RGBA,xl,yl);
ColorRGBA crgba=new ColorRGBA(c.x,c.y,c.z,c.w);
if(x>=dst.getWidth()||y>=dst.getHeight()) continue;
dst.setPixel(x,y,crgba);
}
}
}
开发者ID:riccardobl,项目名称:DDSWriter,代码行数:13,代码来源:Texel.java
示例4: getColor
import com.jme3.texture.image.ImageRaster; //导入依赖的package包/类
public static ColorRGBA getColor( Geometry geom, Vector3f pt, int index, Tweed tweed ) {
MatParam param = geom.getMaterial().getParam( "DiffuseMap" );
ImageRaster ir = ImageRaster.create( tweed.getAssetManager().loadTexture( ((Texture2D)param.getValue()).getName() ).getImage() );
Mesh mesh = geom.getMesh();
// geom.getMaterial().getMaterialDef().
VertexBuffer pb = mesh.getBuffer(Type.Position);
VertexBuffer tb = mesh.getBuffer( Type.TexCoord );
IndexBuffer ib = mesh.getIndicesAsList();
Vector2f uva = new Vector2f(), uvb = new Vector2f(), uvc = new Vector2f();
Vector3f la = new Vector3f(), lb = new Vector3f(), lc = new Vector3f();
if (pb != null && pb.getFormat() == Format.Float && pb.getNumComponents() == 3) {
FloatBuffer fpb = (FloatBuffer) pb.getData();
FloatBuffer ftb = (FloatBuffer) tb.getData();
// aquire triangle's vertex indices
int vertIndex = index * 3;
int va = ib.get(vertIndex);
int vb = ib.get(vertIndex+1);
int vc = ib.get(vertIndex+2);
BufferUtils.populateFromBuffer( la, fpb, va );
BufferUtils.populateFromBuffer( lb, fpb, vb );
BufferUtils.populateFromBuffer( lc, fpb, vc );
BufferUtils.populateFromBuffer( uva, ftb, va );
BufferUtils.populateFromBuffer( uvb, ftb, vb );
BufferUtils.populateFromBuffer( uvc, ftb, vc );
// PaintThing.debug.put(1, new Line ( la.x, la.z, lb.x, lb.z) );
// PaintThing.debug.put(2, new Line ( lb.x, lb.z, lc.x, lc.z) );
// PaintThing.debug.put(3, new Line ( lc.x, lc.z, la.x, la.z) );
float[] bary = barycentric( pt, la, lb, lc );
int x = (int)( ( uva.x * bary[0] + uvb.x * bary[1] + uvc.x * bary[2] ) * ir.getWidth ()) ,
y = (int)( ( uva.y * bary[0] + uvb.y * bary[1] + uvc.y * bary[2] ) * ir.getHeight()) ;
ColorRGBA out = ir.getPixel( x, y );//ir.getHeight() - y -1 );
// for (Pair<Vector3f, Vector2f> pair : new Pair[]{ new Pair( la, uva), new Pair (lb, uvb), new Pair (lc, uvc)}) {
//
// int xx = (int)(pair.second().x * ir.getWidth () ),
// yy = (int)(pair.second().y * ir.getHeight() );
//
// System.out.println("xx "+xx+" yy "+ yy );
//
// ColorRGBA o = ir.getPixel(
// xx,
// yy );
//
// PaintThing.debug.put(1, new ColPt( pair.first().x, pair.first().z, o.r, o.g, o.b ));
// }
// System.out.println("<< "+ ((Texture2D)param.getValue()).getName());
// System.out.println( x + " " + y + " :: " + bary[ 0 ] + " " + bary[ 1 ] + " " + bary[ 2 ] +
// " --> " + out.r + "," + out.g + "," + out.b );
return out;
}else{
throw new UnsupportedOperationException("Position buffer not set or has incompatible format");
}
}
开发者ID:twak,项目名称:chordatlas,代码行数:74,代码来源:SkelFootprint.java
示例5: setEmitterShape
import com.jme3.texture.image.ImageRaster; //导入依赖的package包/类
public void setEmitterShape(Texture texture) {
emitterShape = texture;
ir = ImageRaster.create(emitterShape.getImage());
}
开发者ID:rockfireredmoon,项目名称:icetone,代码行数:5,代码来源:ElementEmitter.java
示例6: getImageRaster
import com.jme3.texture.image.ImageRaster; //导入依赖的package包/类
protected ImageRaster getImageRaster() {
return ImageRaster.create(colorImage);
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:4,代码来源:ImageBasedHeightMap.java
示例7: load
import com.jme3.texture.image.ImageRaster; //导入依赖的package包/类
public boolean load(boolean flipX, boolean flipY) {
int imageWidth = colorImage.getWidth();
int imageHeight = colorImage.getHeight();
if (imageWidth != imageHeight)
throw new RuntimeException("imageWidth: " + imageWidth
+ " != imageHeight: " + imageHeight);
size = imageWidth;
ImageRaster raster = getImageRaster();
heightData = new float[(imageWidth * imageHeight)];
ColorRGBA colorStore = new ColorRGBA();
int index = 0;
if (flipY) {
for (int h = 0; h < imageHeight; ++h) {
if (flipX) {
for (int w = imageWidth - 1; w >= 0; --w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
} else {
for (int w = 0; w < imageWidth; ++w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
}
}
} else {
for (int h = imageHeight - 1; h >= 0; --h) {
if (flipX) {
for (int w = imageWidth - 1; w >= 0; --w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
} else {
for (int w = 0; w < imageWidth; ++w) {
//int baseIndex = (h * imageWidth)+ w;
//heightData[index++] = getHeightAtPostion(raster, baseIndex, colorStore)*heightScale;
heightData[index++] = calculateHeight(raster.getPixel(w, h, colorStore))*heightScale*backwardsCompScale;
}
}
}
}
return true;
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:54,代码来源:ImageBasedHeightMap.java
注:本文中的com.jme3.texture.image.ImageRaster类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论