use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestImageRaster method convertAndPutImage.
private void convertAndPutImage(Image image, float posX, float posY) {
Texture tex = new Texture2D(image);
tex.setMagFilter(MagFilter.Nearest);
tex.setMinFilter(MinFilter.NearestNoMipMaps);
tex.setAnisotropicFilter(16);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", tex);
Quad q = new Quad(5, 5);
Geometry g = new Geometry("quad", q);
g.setLocalTranslation(posX, posY - 5, -0.0001f);
g.setMaterial(mat);
rootNode.attachChild(g);
BitmapFont fnt = assetManager.loadFont("Interface/Fonts/Default.fnt");
BitmapText txt = new BitmapText(fnt);
txt.setBox(new Rectangle(0, 0, 5, 5));
txt.setQueueBucket(RenderQueue.Bucket.Transparent);
txt.setSize(0.5f);
txt.setText(image.getFormat().name());
txt.setLocalTranslation(posX, posY, 0);
rootNode.attachChild(txt);
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestTexture3DLoading method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.DarkGray);
flyCam.setEnabled(false);
Quad q = new Quad(10, 10);
Geometry geom = new Geometry("Quad", q);
Material material = new Material(assetManager, "jme3test/texture/tex3DThumb.j3md");
TextureKey key = new TextureKey("Textures/3D/flame.dds");
key.setGenerateMips(true);
key.setTextureTypeHint(Texture.Type.ThreeDimensional);
Texture t = assetManager.loadTexture(key);
//4 * 4
int rows = 4;
q.scaleTextureCoordinates(new Vector2f(rows, rows));
//The image only have 8 pictures and we have 16 thumbs, the data will be interpolated by the GPU
material.setFloat("InvDepth", 1f / 16f);
material.setInt("Rows", rows);
material.setTexture("Texture", t);
geom.setMaterial(material);
rootNode.attachChild(geom);
cam.setLocation(new Vector3f(4.7444625f, 5.160054f, 13.1939f));
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TestBlendEquations method simpleInitApp.
public void simpleInitApp() {
Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
teaGeom.scale(6);
teaGeom.getMaterial().getAdditionalRenderState().setBlendEquation(RenderState.BlendEquation.Add);
teaGeom.move(0, -2f, 0);
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.Red);
dl.setDirection(Vector3f.UNIT_XYZ.negate());
rootNode.addLight(dl);
rootNode.attachChild(teaGeom);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", new ColorRGBA(0.5f, 0f, 1f, 0.3f));
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Color);
mat.getAdditionalRenderState().setBlendEquation(RenderState.BlendEquation.Subtract);
Geometry geo = new Geometry("BottomLeft", new Quad(guiViewPort.getCamera().getWidth() / 2, guiViewPort.getCamera().getHeight() / 2));
geo.setMaterial(mat);
geo.setQueueBucket(RenderQueue.Bucket.Gui);
geo.setLocalTranslation(0, 0, 1);
guiNode.attachChild(geo);
Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
m.getAdditionalRenderState().setBlendEquation(RenderState.BlendEquation.ReverseSubtract);
m.setColor("Color", new ColorRGBA(0.0f, 1f, 1.f, 1f));
m.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.AlphaAdditive);
geo = new Geometry("BottomRight", new Quad(guiViewPort.getCamera().getWidth() / 2, guiViewPort.getCamera().getHeight() / 2));
geo.setMaterial(m);
geo.setQueueBucket(RenderQueue.Bucket.Gui);
geo.setLocalTranslation(guiViewPort.getCamera().getWidth() / 2, 0, 1);
guiNode.attachChild(geo);
m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
m.getAdditionalRenderState().setBlendEquation(RenderState.BlendEquation.Min);
m.setColor("Color", new ColorRGBA(0.3f, 0f, 0.1f, 0.3f));
m.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Additive);
geo = new Geometry("TopRight", new Quad(guiViewPort.getCamera().getWidth() / 2, guiViewPort.getCamera().getHeight() / 2));
geo.setMaterial(m);
geo.setQueueBucket(RenderQueue.Bucket.Gui);
geo.setLocalTranslation(guiViewPort.getCamera().getWidth() / 2, guiViewPort.getCamera().getHeight() / 2, 1);
guiNode.attachChild(geo);
geo = new Geometry("OverTeaPot", new Quad(guiViewPort.getCamera().getWidth() / 2, guiViewPort.getCamera().getHeight() / 2));
geo.setMaterial(mat);
geo.setQueueBucket(RenderQueue.Bucket.Transparent);
geo.setLocalTranslation(0, -100, 5);
rootNode.attachChild(geo);
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class TerrainGridSerializationTest method simpleInitApp.
@Override
public void simpleInitApp() {
File file = new File("TerrainGridTestData.zip");
if (!file.exists()) {
assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/TerrainGridTestData.zip", HttpZipLocator.class);
} else {
assetManager.registerLocator("TerrainGridTestData.zip", ZipLocator.class);
}
this.flyCam.setMoveSpeed(100f);
ScreenshotAppState state = new ScreenshotAppState();
this.stateManager.attach(state);
this.terrain = (TerrainGrid) assetManager.loadModel("TerrainGrid/TerrainGrid.j3o");
this.rootNode.attachChild(this.terrain);
TerrainLodControl control = new TerrainGridLodControl(this.terrain, getCamera());
// patch size, and a multiplier
control.setLodCalculator(new DistanceLodCalculator(65, 2.7f));
this.terrain.addControl(control);
final BulletAppState bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
this.getCamera().setLocation(new Vector3f(0, 256, 0));
this.viewPort.setBackgroundColor(new ColorRGBA(0.7f, 0.8f, 1f, 1f));
if (usePhysics) {
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(0.5f, 1.8f, 1);
player3 = new CharacterControl(capsuleShape, 0.5f);
player3.setJumpSpeed(20);
player3.setFallSpeed(10);
player3.setGravity(10);
player3.setPhysicsLocation(new Vector3f(cam.getLocation().x, 256, cam.getLocation().z));
bulletAppState.getPhysicsSpace().add(player3);
terrain.addListener(new TerrainGridListener() {
public void gridMoved(Vector3f newCenter) {
}
public void tileAttached(Vector3f cell, TerrainQuad quad) {
//workaround for bugged test j3o's
while (quad.getControl(RigidBodyControl.class) != null) {
quad.removeControl(RigidBodyControl.class);
}
quad.addControl(new RigidBodyControl(new HeightfieldCollisionShape(quad.getHeightMap(), terrain.getLocalScale()), 0));
bulletAppState.getPhysicsSpace().add(quad);
}
public void tileDetached(Vector3f cell, TerrainQuad quad) {
if (quad.getControl(RigidBodyControl.class) != null) {
bulletAppState.getPhysicsSpace().remove(quad);
quad.removeControl(RigidBodyControl.class);
}
}
});
}
this.initKeys();
}
use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.
the class EnvMapUtils method getCubeMapCrossDebugView.
/**
* Creates a debug Node of the given cube map to attach to the gui node
*
* the cube map is layered this way :
* <pre>
* _____
* | |
* | +Y |
* _____|_____|_____ _____
* | | | | |
* | -X | +Z | +X | -Z |
* |_____|_____|_____|_____|
* | |
* | -Y |
* |_____|
*
*</pre>
*
* @param cubeMap the cube map
* @param assetManager the asset Manager
* @return
*/
public static Node getCubeMapCrossDebugView(TextureCubeMap cubeMap, AssetManager assetManager) {
Node n = new Node("CubeMapDebug" + cubeMap.getName());
int size = cubeMap.getImage().getWidth();
Picture[] pics = new Picture[6];
float ratio = 128f / (float) size;
for (int i = 0; i < 6; i++) {
pics[i] = new Picture("bla");
Texture2D tex = new Texture2D(new Image(cubeMap.getImage().getFormat(), size, size, cubeMap.getImage().getData(i), cubeMap.getImage().getColorSpace()));
pics[i].setTexture(assetManager, tex, true);
pics[i].setWidth(size);
pics[i].setHeight(size);
n.attachChild(pics[i]);
}
pics[0].setLocalTranslation(size, size * 2, 1);
pics[0].setLocalRotation(new Quaternion().fromAngleAxis(PI, Vector3f.UNIT_Z));
pics[1].setLocalTranslation(size * 3, size * 2, 1);
pics[1].setLocalRotation(new Quaternion().fromAngleAxis(PI, Vector3f.UNIT_Z));
pics[2].setLocalTranslation(size * 2, size * 3, 1);
pics[2].setLocalRotation(new Quaternion().fromAngleAxis(PI, Vector3f.UNIT_Z));
pics[3].setLocalTranslation(size * 2, size, 1);
pics[3].setLocalRotation(new Quaternion().fromAngleAxis(PI, Vector3f.UNIT_Z));
pics[4].setLocalTranslation(size * 2, size * 2, 1);
pics[4].setLocalRotation(new Quaternion().fromAngleAxis(PI, Vector3f.UNIT_Z));
pics[5].setLocalTranslation(size * 4, size * 2, 1);
pics[5].setLocalRotation(new Quaternion().fromAngleAxis(PI, Vector3f.UNIT_Z));
Quad q = new Quad(size * 4, size * 3);
Geometry g = new Geometry("bg", q);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Black);
g.setMaterial(mat);
g.setLocalTranslation(0, 0, 0);
n.attachChild(g);
n.setLocalScale(ratio);
return n;
}
Aggregations