Search in sources :

Example 31 with Vector2f

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;
}
Also used : IntBuffer(java.nio.IntBuffer) Mesh(com.jme3.scene.Mesh) FloatBuffer(java.nio.FloatBuffer)

Example 32 with Vector2f

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);
    }
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Example 33 with Vector2f

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);
}
Also used : Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f)

Example 34 with Vector2f

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);
}
Also used : Geometry(com.jme3.scene.Geometry) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box)

Example 35 with Vector2f

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);
}
Also used : Node(com.jme3.scene.Node) Material(com.jme3.material.Material)

Aggregations

Vector2f (com.jme3.math.Vector2f)80 Vector3f (com.jme3.math.Vector3f)38 Geometry (com.jme3.scene.Geometry)22 Material (com.jme3.material.Material)20 Box (com.jme3.scene.shape.Box)17 ArrayList (java.util.ArrayList)14 Texture (com.jme3.texture.Texture)9 List (java.util.List)9 Node (com.jme3.scene.Node)8 Sphere (com.jme3.scene.shape.Sphere)8 FloatBuffer (java.nio.FloatBuffer)8 InputCapsule (com.jme3.export.InputCapsule)7 Spatial (com.jme3.scene.Spatial)7 DirectionalLight (com.jme3.light.DirectionalLight)6 Mesh (com.jme3.scene.Mesh)6 AmbientLight (com.jme3.light.AmbientLight)5 Quad (com.jme3.scene.shape.Quad)5 BoundingBox (com.jme3.bounding.BoundingBox)4 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)4 CollisionResult (com.jme3.collision.CollisionResult)4