本文整理汇总了Java中com.jme3.util.BufferUtils.createVector3Buffer方法的典型用法代码示例。如果您正苦于以下问题:Java BufferUtils.createVector3Buffer方法的具体用法?Java BufferUtils.createVector3Buffer怎么用?Java BufferUtils.createVector3Buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.util.BufferUtils
的用法示例。
在下文中一共展示了BufferUtils.createVector3Buffer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: duUpdateGeometryVertices
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
protected void duUpdateGeometryVertices() {
FloatBuffer fpb = BufferUtils.createVector3Buffer(8 * 3);
Vector3f[] v = computeVertices();
fpb.put(new float[] {
v[0].x, v[0].y, v[0].z,
v[1].x, v[1].y, v[1].z,
v[2].x, v[2].y, v[2].z,
v[3].x, v[3].y, v[3].z,
v[4].x, v[4].y, v[4].z,
v[5].x, v[5].y, v[5].z,
v[6].x, v[6].y, v[6].z,
v[7].x, v[7].y, v[7].z,
});
setBuffer(Type.Position, 3, fpb);
setMode(Mode.TriangleStrip);
updateBound();
}
示例2: setGeometryData
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void setGeometryData() {
setMode(Mode.Lines);
FloatBuffer posBuf = BufferUtils.createVector3Buffer(3);
FloatBuffer texBuf = BufferUtils.createVector2Buffer(3);
setBuffer(VertexBuffer.Type.Position, 3, posBuf);
setBuffer(VertexBuffer.Type.TexCoord, 2, texBuf);
posBuf.put(-width).put(0).put(0);
posBuf.put(0).put(height).put(0);
posBuf.put(width).put(0).put(0);
texBuf.put(-width).put(0);
texBuf.put(0).put(height);
texBuf.put(width).put(0);
}
示例3: duUpdateGeometryVertices
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
protected void duUpdateGeometryVertices() {
FloatBuffer fpb = BufferUtils.createVector3Buffer(24);
Vector3f[] v = computeVertices();
fpb.put(new float[] {
v[0].x, v[0].y, v[0].z, v[1].x, v[1].y, v[1].z, v[2].x, v[2].y, v[2].z, v[3].x, v[3].y, v[3].z, // back
v[1].x, v[1].y, v[1].z, v[4].x, v[4].y, v[4].z, v[6].x, v[6].y, v[6].z, v[2].x, v[2].y, v[2].z, // right
v[4].x, v[4].y, v[4].z, v[5].x, v[5].y, v[5].z, v[7].x, v[7].y, v[7].z, v[6].x, v[6].y, v[6].z, // front
v[5].x, v[5].y, v[5].z, v[0].x, v[0].y, v[0].z, v[3].x, v[3].y, v[3].z, v[7].x, v[7].y, v[7].z, // left
v[2].x, v[2].y, v[2].z, v[6].x, v[6].y, v[6].z, v[7].x, v[7].y, v[7].z, v[3].x, v[3].y, v[3].z, // top
v[0].x, v[0].y, v[0].z, v[5].x, v[5].y, v[5].z, v[4].x, v[4].y, v[4].z, v[1].x, v[1].y, v[1].z // bottom
});
setBuffer(Type.Position, 3, fpb);
updateBound();
}
示例4: initParticleData
import com.jme3.util.BufferUtils; //导入方法依赖的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);
}
示例5: setGeometryData
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private void setGeometryData() {
// allocate vertices
int vertCount = (circleSamples + 1) * (radialSamples + 1);
FloatBuffer fpb = BufferUtils.createVector3Buffer(vertCount);
setBuffer(Type.Position, 3, fpb);
// allocate normals if requested
FloatBuffer fnb = BufferUtils.createVector3Buffer(vertCount);
setBuffer(Type.Normal, 3, fnb);
// allocate texture coordinates
FloatBuffer ftb = BufferUtils.createVector2Buffer(vertCount);
setBuffer(Type.TexCoord, 2, ftb);
// generate geometry
float inverseCircleSamples = 1.0f / circleSamples;
float inverseRadialSamples = 1.0f / radialSamples;
int i = 0;
// generate the cylinder itself
Vector3f radialAxis = new Vector3f(), torusMiddle = new Vector3f(), tempNormal = new Vector3f();
for (int circleCount = 0; circleCount < circleSamples; circleCount++) {
// compute center point on torus circle at specified angle
float circleFraction = circleCount * inverseCircleSamples;
float theta = FastMath.TWO_PI * circleFraction;
float cosTheta = FastMath.cos(theta);
float sinTheta = FastMath.sin(theta);
radialAxis.set(cosTheta, sinTheta, 0);
radialAxis.mult(outerRadius, torusMiddle);
// compute slice vertices with duplication at end point
int iSave = i;
for (int radialCount = 0; radialCount < radialSamples; radialCount++) {
float radialFraction = radialCount * inverseRadialSamples;
// in [0,1)
float phi = FastMath.TWO_PI * radialFraction;
float cosPhi = FastMath.cos(phi);
float sinPhi = FastMath.sin(phi);
tempNormal.set(radialAxis).multLocal(cosPhi);
tempNormal.z += sinPhi;
fnb.put(tempNormal.x).put(tempNormal.y).put(
tempNormal.z);
tempNormal.multLocal(innerRadius).addLocal(torusMiddle);
fpb.put(tempNormal.x).put(tempNormal.y).put(
tempNormal.z);
ftb.put(radialFraction).put(circleFraction);
i++;
}
BufferUtils.copyInternalVector3(fpb, iSave, i);
BufferUtils.copyInternalVector3(fnb, iSave, i);
ftb.put(1.0f).put(circleFraction);
i++;
}
// duplicate the cylinder ends to form a torus
for (int iR = 0; iR <= radialSamples; iR++, i++) {
BufferUtils.copyInternalVector3(fpb, iR, i);
BufferUtils.copyInternalVector3(fnb, iR, i);
BufferUtils.copyInternalVector2(ftb, iR, i);
ftb.put(i * 2 + 1, 1.0f);
}
}
示例6: initParticleData
import com.jme3.util.BufferUtils; //导入方法依赖的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: createCone
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
private static Mesh createCone(int radialSamples, float radius, float height) {
Mesh cone = new Mesh();
float fInvRS = 1.0f / radialSamples;
// Generate points on the unit circle to be used in computing the mesh
// points on a dome slice.
float[] afSin = new float[radialSamples];
float[] afCos = new float[radialSamples];
for (int i = 0; i < radialSamples; i++) {
float fAngle = FastMath.TWO_PI * fInvRS * i;
afCos[i] = FastMath.cos(fAngle);
afSin[i] = FastMath.sin(fAngle);
}
FloatBuffer vb = BufferUtils.createVector3Buffer(radialSamples + 2);
cone.setBuffer(Type.Position, 3, vb);
TempVars vars = TempVars.get();
Vector3f tempVa = vars.vect1;
for (int i = 0; i < radialSamples; i++) {
Vector3f kRadial = tempVa.set(afCos[i], 0, afSin[i]);
kRadial.mult(radius, tempVa);
vb.put(tempVa.x).put(tempVa.y).put(tempVa.z);
BufferUtils.populateFromBuffer(tempVa, vb, i);
}
vars.release();
// top of the cone
vb.put(0).put(height).put(0);
// base of the cone
vb.put(0).put(0).put(0);
ShortBuffer ib = BufferUtils.createShortBuffer(3 * (radialSamples) * 2);
cone.setBuffer(Type.Index, 3, ib);
short top = (short) radialSamples;
short bot = (short) (radialSamples + 1);
for (int i = 0; i < radialSamples; i++) {
short a = (short) i;
short b = (short) ((i + 1) % radialSamples);
ib.put(top);
ib.put(b);
ib.put(a);
ib.put(a);
ib.put(b);
ib.put(bot);
}
cone.updateBound();
return cone;
}
示例8: setGeometryData
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
* builds the vertices based on the radius
*/
private void setGeometryData() {
setMode(Mode.Lines);
FloatBuffer posBuf = BufferUtils.createVector3Buffer((radialSamples + 1));
FloatBuffer colBuf = BufferUtils.createFloatBuffer((radialSamples + 1) * 4);
FloatBuffer texBuf = BufferUtils.createVector2Buffer(radialSamples + 1);
setBuffer(Type.Position, 3, posBuf);
setBuffer(Type.Color, 4, colBuf);
setBuffer(Type.TexCoord, 2, texBuf);
// generate geometry
float fInvRS = 1.0f / radialSamples;
// Generate points on the unit circle to be used in computing the mesh
// points on a sphere slice.
float[] afSin = new float[(radialSamples + 1)];
float[] afCos = new float[(radialSamples + 1)];
for (int iR = 0; iR < radialSamples; iR++) {
float fAngle = FastMath.TWO_PI * fInvRS * iR;
afCos[iR] = FastMath.cos(fAngle);
afSin[iR] = FastMath.sin(fAngle);
}
afSin[radialSamples] = afSin[0];
afCos[radialSamples] = afCos[0];
for (int iR = 0; iR <= radialSamples; iR++) {
posBuf.put(afCos[iR])
.put(afSin[iR])
.put(0);
colBuf.put(ColorRGBA.Orange.r)
.put(ColorRGBA.Orange.g)
.put(ColorRGBA.Orange.b)
.put(ColorRGBA.Orange.a);
texBuf.put(iR % 2f)
.put(iR % 2f);
}
updateBound();
setStatic();
}
示例9: setGeometryData
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
/**
* builds the vertices based on the radius
*/
private void setGeometryData() {
setMode(Mode.Lines);
FloatBuffer posBuf = BufferUtils.createVector3Buffer((radialSamples + 1));
FloatBuffer colBuf = BufferUtils.createFloatBuffer((radialSamples + 1) * 4);
FloatBuffer texBuf = BufferUtils.createVector2Buffer(radialSamples + 1);
setBuffer(Type.Position, 3, posBuf);
setBuffer(Type.Color, 4, colBuf);
setBuffer(Type.TexCoord, 2, texBuf);
// generate geometry
float fInvRS = 1.0f / radialSamples;
// Generate points on the unit circle to be used in computing the mesh
// points on a sphere slice.
float[] afSin = new float[(radialSamples + 1)];
float[] afCos = new float[(radialSamples + 1)];
for (int iR = 0; iR < radialSamples; iR++) {
float fAngle = FastMath.TWO_PI * fInvRS * iR;
afCos[iR] = FastMath.cos(fAngle);
afSin[iR] = FastMath.sin(fAngle);
}
afSin[radialSamples] = afSin[0];
afCos[radialSamples] = afCos[0];
for (int iR = 0; iR <= radialSamples; iR++) {
posBuf.put(afCos[iR])
.put(afSin[iR])
.put(0);
colBuf.put(ColorRGBA.Orange.r)
.put(ColorRGBA.Orange.g)
.put(ColorRGBA.Orange.b)
.put(ColorRGBA.Orange.a);
texBuf.put(iR % 2f)
.put(iR % 2f);
}
updateBound();
setStatic();
}
示例10: createCone
import com.jme3.util.BufferUtils; //导入方法依赖的package包/类
public static Mesh createCone(int radialSamples, float radius, float height) {
Mesh cone = new Mesh();
float fInvRS = 1.0f / radialSamples;
// Generate points on the unit circle to be used in computing the mesh
// points on a dome slice.
float[] afSin = new float[radialSamples];
float[] afCos = new float[radialSamples];
for (int i = 0; i < radialSamples; i++) {
float fAngle = FastMath.TWO_PI * fInvRS * i;
afCos[i] = FastMath.cos(fAngle);
afSin[i] = FastMath.sin(fAngle);
}
FloatBuffer vb = BufferUtils.createVector3Buffer(radialSamples + 2);
cone.setBuffer(VertexBuffer.Type.Position, 3, vb);
TempVars vars = TempVars.get();
Vector3f tempVa = vars.vect1;
for (int i = 0; i < radialSamples; i++) {
Vector3f kRadial = tempVa.set(afCos[i], 0, afSin[i]);
kRadial.mult(radius, tempVa);
vb.put(tempVa.x).put(tempVa.y).put(tempVa.z);
BufferUtils.populateFromBuffer(tempVa, vb, i);
}
vars.release();
// top of the cone
vb.put(0).put(height).put(0);
// base of the cone
vb.put(0).put(0).put(0);
ShortBuffer ib = BufferUtils.createShortBuffer(3 * (radialSamples) * 2);
cone.setBuffer(VertexBuffer.Type.Index, 3, ib);
short top = (short) radialSamples;
short bot = (short) (radialSamples + 1);
for (int i = 0; i < radialSamples; i++) {
short a = (short) i;
short b = (short) ((i + 1) % radialSamples);
ib.put(top);
ib.put(b);
ib.put(a);
ib.put(a);
ib.put(b);
ib.put(bot);
}
cone.updateBound();
return cone;
}