use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class BitmapTextPage method assemble.
// Here is where one might add JmeCloneable related stuff except
// the old clone() method doesn't actually bother to clone anything.
// The arrays and the pageQuads are shared across all BitmapTextPage
// clones and it doesn't seem to bother anything. That means the
// fields could probably just as well be static... but this code is
// all very fragile. I'm not tipping that particular boat today. -pspeed
void assemble(Letters quads) {
pageQuads.clear();
quads.rewind();
while (quads.nextCharacter()) {
if (quads.isPrintable()) {
if (quads.getCharacterSetPage() == page) {
pageQuads.add(quads.getQuad());
}
}
}
Mesh m = getMesh();
int vertCount = pageQuads.size() * 4;
int triCount = pageQuads.size() * 2;
VertexBuffer pb = m.getBuffer(Type.Position);
VertexBuffer tb = m.getBuffer(Type.TexCoord);
VertexBuffer ib = m.getBuffer(Type.Index);
VertexBuffer cb = m.getBuffer(Type.Color);
FloatBuffer fpb = (FloatBuffer) pb.getData();
FloatBuffer ftb = (FloatBuffer) tb.getData();
ShortBuffer sib = (ShortBuffer) ib.getData();
ByteBuffer bcb = (ByteBuffer) cb.getData();
// increase capacity of buffers as needed
fpb.rewind();
fpb = BufferUtils.ensureLargeEnough(fpb, vertCount * 3);
fpb.limit(vertCount * 3);
pb.updateData(fpb);
ftb.rewind();
ftb = BufferUtils.ensureLargeEnough(ftb, vertCount * 2);
ftb.limit(vertCount * 2);
tb.updateData(ftb);
bcb.rewind();
bcb = BufferUtils.ensureLargeEnough(bcb, vertCount * 4);
bcb.limit(vertCount * 4);
cb.updateData(bcb);
sib.rewind();
sib = BufferUtils.ensureLargeEnough(sib, triCount * 3);
sib.limit(triCount * 3);
ib.updateData(sib);
m.updateCounts();
// go for each quad and append it to the buffers
if (pos != null) {
for (int i = 0; i < pageQuads.size(); i++) {
LetterQuad fq = pageQuads.get(i);
fq.storeToArrays(pos, tc, idx, color, i);
fpb.put(pos);
ftb.put(tc);
sib.put(idx);
bcb.put(color);
}
} else {
for (int i = 0; i < pageQuads.size(); i++) {
LetterQuad fq = pageQuads.get(i);
fq.appendPositions(fpb);
fq.appendTexCoords(ftb);
fq.appendIndices(sib, i);
fq.appendColors(bcb);
}
}
fpb.rewind();
ftb.rewind();
sib.rewind();
bcb.rewind();
updateModelBound();
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestUrlLoading method simpleInitApp.
@Override
public void simpleInitApp() {
// create a simple plane/quad
Quad quadMesh = new Quad(1, 1);
quadMesh.updateGeometry(1, 1, true);
Geometry quad = new Geometry("Textured Quad", quadMesh);
assetManager.registerLocator("https://raw.githubusercontent.com/jMonkeyEngine/BookSamples/master/assets/Textures/", UrlLocator.class);
TextureKey key = new TextureKey("mucha-window.png", false);
key.setGenerateMips(true);
Texture tex = assetManager.loadTexture(key);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", tex);
quad.setMaterial(mat);
float aspect = tex.getImage().getWidth() / (float) tex.getImage().getHeight();
quad.setLocalScale(new Vector3f(aspect * 1.5f, 1.5f, 1));
quad.center();
rootNode.attachChild(quad);
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class SimpleWaterProcessor method createWaterGeometry.
/**
* Creates a quad with the water material applied to it.
* @param width
* @param height
* @return
*/
public Geometry createWaterGeometry(float width, float height) {
Quad quad = new Quad(width, height);
Geometry geom = new Geometry("WaterGeometry", quad);
geom.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
geom.setMaterial(material);
return geom;
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestColoredTexture method simpleInitApp.
@Override
public void simpleInitApp() {
Quad quadMesh = new Quad(512, 512);
Geometry quad = new Geometry("Quad", quadMesh);
quad.setQueueBucket(Bucket.Gui);
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("Textures/ColoredTex/Monkey.png"));
quad.setMaterial(mat);
guiNode.attachChildAt(quad, 0);
nextColor = ColorRGBA.randomColor();
prevColor = ColorRGBA.Black;
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestCameraNode method simpleInitApp.
public void simpleInitApp() {
// load a teapot model
teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
teaGeom.setMaterial(mat);
//create a node to attach the geometry and the camera node
teaNode = new Node("teaNode");
teaNode.attachChild(teaGeom);
rootNode.attachChild(teaNode);
// create a floor
mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
Geometry ground = new Geometry("ground", new Quad(50, 50));
ground.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
ground.setLocalTranslation(-25, -1, 25);
ground.setMaterial(mat);
rootNode.attachChild(ground);
//creating the camera Node
camNode = new CameraNode("CamNode", cam);
//Setting the direction to Spatial to camera, this means the camera will copy the movements of the Node
camNode.setControlDir(ControlDirection.SpatialToCamera);
//attaching the camNode to the teaNode
teaNode.attachChild(camNode);
//setting the local translation of the cam node to move it away from the teanNode a bit
camNode.setLocalTranslation(new Vector3f(-10, 0, 0));
//setting the camNode to look at the teaNode
camNode.lookAt(teaNode.getLocalTranslation(), Vector3f.UNIT_Y);
//disable the default 1st-person flyCam (don't forget this!!)
flyCam.setEnabled(false);
registerInput();
}
Aggregations