use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class GeoMap method createMesh.
public Mesh createMesh(Vector3f scale, Vector2f tcScale, boolean center) {
FloatBuffer pb = writeVertexArray(null, scale, center);
FloatBuffer tb = writeTexCoordArray(null, Vector2f.ZERO, tcScale);
FloatBuffer nb = writeNormalArray(null, scale);
IntBuffer ib = writeIndexArray(null);
Mesh m = new Mesh();
m.setBuffer(Type.Position, 3, pb);
m.setBuffer(Type.Normal, 3, nb);
m.setBuffer(Type.TexCoord, 2, tb);
m.setBuffer(Type.Index, 3, ib);
m.setStatic();
m.updateBound();
return m;
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TerrainGrid method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule c = im.getCapsule(this);
name = c.readString("name", null);
size = c.readInt("size", 0);
patchSize = c.readInt("patchSize", 0);
stepScale = (Vector3f) c.readSavable("stepScale", null);
offset = (Vector2f) c.readSavable("offset", null);
offsetAmount = c.readFloat("offsetAmount", 0);
gridTileLoader = (TerrainGridTileLoader) c.readSavable("terrainQuadGrid", null);
material = (Material) c.readSavable("material", null);
initData();
if (gridTileLoader != null) {
gridTileLoader.setPatchSize(this.patchSize);
gridTileLoader.setQuadSize(this.quadSize);
}
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TerrainGrid method adjustHeight.
@Override
public void adjustHeight(List<Vector2f> xz, List<Float> height) {
Vector3f currentGridLocation = getCurrentCell().mult(getLocalScale()).multLocal(quadSize - 1);
for (Vector2f vect : xz) {
vect.x -= currentGridLocation.x;
vect.y -= currentGridLocation.z;
}
super.adjustHeight(xz, height);
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestEverything method setupFloor.
public void setupFloor() {
Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
Box floor = new Box(50, 1f, 50);
TangentBinormalGenerator.generate(floor);
floor.scaleTextureCoordinates(new Vector2f(5, 5));
Geometry floorGeom = new Geometry("Floor", floor);
floorGeom.setMaterial(mat);
floorGeom.setShadowMode(ShadowMode.Receive);
rootNode.attachChild(floorGeom);
}
use of com.jme3.math.Vector2f in project jmonkeyengine by jMonkeyEngine.
the class TestEverything method setupRobotGuy.
// public void setupTerrain(){
// Material mat = manager.loadMaterial("Textures/Terrain/Rock/Rock.j3m");
// mat.getTextureParam("DiffuseMap").getValue().setWrap(WrapMode.Repeat);
// mat.getTextureParam("NormalMap").getValue().setWrap(WrapMode.Repeat);
// try{
// Geomap map = GeomapLoader.fromImage(TestEverything.class.getResource("/textures/heightmap.png"));
// Mesh m = map.createMesh(new Vector3f(0.35f, 0.0005f, 0.35f), new Vector2f(10, 10), true);
// Logger.getLogger(TangentBinormalGenerator.class.getName()).setLevel(Level.SEVERE);
// TangentBinormalGenerator.generate(m);
// Geometry t = new Geometry("Terrain", m);
// t.setLocalTranslation(85, -15, 0);
// t.setMaterial(mat);
// t.updateModelBound();
// t.setShadowMode(ShadowMode.Receive);
// rootNode.attachChild(t);
// }catch (IOException ex){
// ex.printStackTrace();
// }
//
// }
public void setupRobotGuy() {
Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Oto/Oto.j3m");
model.getChild(0).setMaterial(mat);
// model.setAnimation("Walk");
model.setLocalTranslation(30, 10.5f, 30);
model.setLocalScale(2);
model.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(model);
}
Aggregations