本文整理汇总了Java中com.jme3.scene.VertexBuffer.setNormalized方法的典型用法代码示例。如果您正苦于以下问题:Java VertexBuffer.setNormalized方法的具体用法?Java VertexBuffer.setNormalized怎么用?Java VertexBuffer.setNormalized使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.scene.VertexBuffer
的用法示例。
在下文中一共展示了VertexBuffer.setNormalized方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RenderDeviceJme
import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public RenderDeviceJme(NiftyJmeDisplay display) {
this.display = display;
quadColor = new VertexBuffer(Type.Color);
quadColor.setNormalized(true);
ByteBuffer bb = BufferUtils.createByteBuffer(4 * 4);
quadColor.setupData(Usage.Stream, 4, Format.UnsignedByte, bb);
quad.setBuffer(quadColor);
quadModTC.setUsage(Usage.Stream);
niftyMat = new Material(display.getAssetManager(), "Common/MatDefs/Nifty/NiftyTex.j3md");
niftyMat.getAdditionalRenderState().setDepthTest(false);
niftyQuadMat = new Material(display.getAssetManager(), "Common/MatDefs/Nifty/NiftyQuad.j3md");
niftyQuadMat.getAdditionalRenderState().setDepthTest(false);
}
示例2: RenderDeviceJme
import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public RenderDeviceJme(NiftyJmeDisplay display){
this.display = display;
quadColor = new VertexBuffer(Type.Color);
quadColor.setNormalized(true);
ByteBuffer bb = BufferUtils.createByteBuffer(4 * 4);
quadColor.setupData(Usage.Stream, 4, Format.UnsignedByte, bb);
quad.setBuffer(quadColor);
quadModTC.setUsage(Usage.Stream);
niftyMat = new Material(display.getAssetManager(), "Common/MatDefs/Nifty/Nifty.j3md");
niftyMat.getAdditionalRenderState().setDepthTest(false);
}
示例3: initParticleData
import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
@Override
public void initParticleData(ParticleEmitter emitter, int numParticles) {
setMode(Mode.Points);
this.emitter = emitter;
// set positions
FloatBuffer pb = BufferUtils.createVector3Buffer(numParticles);
VertexBuffer pvb = new VertexBuffer(VertexBuffer.Type.Position);
pvb.setupData(Usage.Stream, 3, Format.Float, pb);
setBuffer(pvb);
// set colors
ByteBuffer cb = BufferUtils.createByteBuffer(numParticles * 4);
VertexBuffer cvb = new VertexBuffer(VertexBuffer.Type.Color);
cvb.setupData(Usage.Stream, 4, Format.UnsignedByte, cb);
cvb.setNormalized(true);
setBuffer(cvb);
// set sizes
FloatBuffer sb = BufferUtils.createFloatBuffer(numParticles);
VertexBuffer svb = new VertexBuffer(VertexBuffer.Type.Size);
svb.setupData(Usage.Stream, 1, Format.Float, sb);
setBuffer(svb);
// set UV-scale
FloatBuffer tb = BufferUtils.createFloatBuffer(numParticles*4);
VertexBuffer tvb = new VertexBuffer(VertexBuffer.Type.TexCoord);
tvb.setupData(Usage.Stream, 4, Format.Float, tb);
setBuffer(tvb);
}
示例4: optimize
import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public static void optimize(Mesh mesh, boolean toFixed){
// update any data that need updating
mesh.updateBound();
mesh.updateCounts();
// set all buffers into STATIC_DRAW mode
mesh.setStatic();
if (mesh.getBuffer(Type.Index) != null){
// compress index buffer from UShort to UByte (if possible)
FloatToFixed.compressIndexBuffer(mesh);
// generate triangle strips stitched with degenerate tris
generateStrips(mesh, false, false, 16, 0);
}
IntMap<VertexBuffer> bufs = mesh.getBuffers();
for (Entry<VertexBuffer> entry : bufs){
VertexBuffer vb = entry.getValue();
if (vb == null || vb.getBufferType() == Type.Index)
continue;
if (vb.getFormat() == Format.Float){
if (vb.getBufferType() == Type.Color){
// convert the color buffer to UByte
vb = FloatToFixed.convertToUByte(vb);
vb.setNormalized(true);
}else if (toFixed){
// convert normals, positions, and texcoords
// to fixed-point (16.16)
vb = FloatToFixed.convertToFixed(vb);
// vb = FloatToFixed.convertToFloat(vb);
}
mesh.clearBuffer(vb.getBufferType());
mesh.setBuffer(vb);
}
}
mesh.setInterleaved();
}
示例5: convertToUByte
import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
public static VertexBuffer convertToUByte(VertexBuffer vb){
FloatBuffer fb = (FloatBuffer) vb.getData();
ByteBuffer bb = BufferUtils.createByteBuffer(fb.capacity());
convertToUByte(fb, bb);
VertexBuffer newVb = new VertexBuffer(vb.getBufferType());
newVb.setupData(vb.getUsage(),
vb.getNumComponents(),
Format.UnsignedByte,
bb);
newVb.setNormalized(true);
return newVb;
}
示例6: initParticleData
import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
@Override
public void initParticleData(ParticleEmitter emitter, int numParticles) {
setMode(Mode.Triangles);
this.emitter = emitter;
particlesCopy = new Particle[numParticles];
// set positions
FloatBuffer pb = BufferUtils.createVector3Buffer(numParticles * 4);
VertexBuffer pvb = new VertexBuffer(VertexBuffer.Type.Position);
pvb.setupData(Usage.Stream, 3, Format.Float, pb);
setBuffer(pvb);
// set colors
ByteBuffer cb = BufferUtils.createByteBuffer(numParticles * 4 * 4);
VertexBuffer cvb = new VertexBuffer(VertexBuffer.Type.Color);
cvb.setupData(Usage.Stream, 4, Format.UnsignedByte, cb);
cvb.setNormalized(true);
setBuffer(cvb);
// set texcoords
VertexBuffer tvb = new VertexBuffer(VertexBuffer.Type.TexCoord);
FloatBuffer tb = BufferUtils.createVector2Buffer(numParticles * 4);
uniqueTexCoords = false;
for (int i = 0; i < numParticles; i++){
tb.put(0f).put(1f);
tb.put(1f).put(1f);
tb.put(0f).put(0f);
tb.put(1f).put(0f);
}
tb.flip();
tvb.setupData(Usage.Static, 2, Format.Float, tb);
setBuffer(tvb);
// set indices
ShortBuffer ib = BufferUtils.createShortBuffer(numParticles * 6);
for (int i = 0; i < numParticles; i++){
int startIdx = (i * 4);
// triangle 1
ib.put((short)(startIdx + 1))
.put((short)(startIdx + 0))
.put((short)(startIdx + 2));
// triangle 2
ib.put((short)(startIdx + 1))
.put((short)(startIdx + 2))
.put((short)(startIdx + 3));
}
ib.flip();
VertexBuffer ivb = new VertexBuffer(VertexBuffer.Type.Index);
ivb.setupData(Usage.Static, 3, Format.UnsignedShort, ib);
setBuffer(ivb);
}
示例7: initParticleData
import com.jme3.scene.VertexBuffer; //导入方法依赖的package包/类
@Override
public void initParticleData(ParticleEmitter emitter, int numParticles) {
setMode(Mode.Points);
this.emitter = emitter;
// set positions
FloatBuffer pb = BufferUtils.createVector3Buffer(numParticles);
VertexBuffer pvb = new VertexBuffer(VertexBuffer.Type.Position);
pvb.setupData(Usage.Stream, 3, Format.Float, pb);
//if the buffer is already set only update the data
VertexBuffer buf = getBuffer(VertexBuffer.Type.Position);
if (buf != null) {
buf.updateData(pb);
} else {
setBuffer(pvb);
}
// set colors
ByteBuffer cb = BufferUtils.createByteBuffer(numParticles * 4);
VertexBuffer cvb = new VertexBuffer(VertexBuffer.Type.Color);
cvb.setupData(Usage.Stream, 4, Format.UnsignedByte, cb);
cvb.setNormalized(true);
buf = getBuffer(VertexBuffer.Type.Color);
if (buf != null) {
buf.updateData(cb);
} else {
setBuffer(cvb);
}
// set sizes
FloatBuffer sb = BufferUtils.createFloatBuffer(numParticles);
VertexBuffer svb = new VertexBuffer(VertexBuffer.Type.Size);
svb.setupData(Usage.Stream, 1, Format.Float, sb);
buf = getBuffer(VertexBuffer.Type.Size);
if (buf != null) {
buf.updateData(sb);
} else {
setBuffer(svb);
}
// set UV-scale
FloatBuffer tb = BufferUtils.createFloatBuffer(numParticles*4);
VertexBuffer tvb = new VertexBuffer(VertexBuffer.Type.TexCoord);
tvb.setupData(Usage.Stream, 4, Format.Float, tb);
buf = getBuffer(VertexBuffer.Type.TexCoord);
if (buf != null) {
buf.updateData(tb);
} else {
setBuffer(tvb);
}
}