Java源码示例:com.jme3.util.TangentBinormalGenerator

示例1
/**
 * Generate tangents using a standard algorithm.
 *
 * @param spatial       the spatial.
 * @param splitMirrored the split mirrored.
 */
public static void useStandardGenerator(@NotNull Spatial spatial, boolean splitMirrored) {
    try {

        NodeUtils.visitGeometry(spatial, geometry -> {

            var mesh = geometry.getMesh();
            var texCoord = mesh.getBuffer(Type.TexCoord);

            if (texCoord != null) {
                TangentBinormalGenerator.generate(geometry, splitMirrored);
            }
        });

    } catch (Exception e) {
        EditorUtil.handleException(LOGGER, null, e);
    }
}
 
示例2
public void setupFloor() {
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setBoolean("UseMaterialColors", true);
    mat.setColor("Diffuse", ColorRGBA.White.clone());
    mat.setColor("Ambient", ColorRGBA.White.clone());
   // mat.setColor("Specular", ColorRGBA.White.clone());
    // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 0);
    //  mat.setBoolean("VertexLighting", true);


    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);
}
 
示例3
public void setupFloor(){
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
   // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess",3);
  //  mat.setBoolean("VertexLighting", true);
    
    
    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);
}
 
示例4
private void addMesh(String name, Mesh mesh, Vector3f translation) {
    TangentBinormalGenerator.generate(mesh);

    Geometry testGeom = new Geometry(name, mesh);
    Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m");
    testGeom.setMaterial(mat);
    testGeom.getLocalTranslation().set(translation);
    rootNode.attachChild(testGeom);

    Geometry debug = new Geometry(
            "Debug " + name,
            TangentBinormalGenerator.genTbnLines(mesh, 0.08f)
    );
    Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
    debug.setMaterial(debugMat);
    debug.setCullHint(Spatial.CullHint.Never);
    debug.getLocalTranslation().set(translation);
    rootNode.attachChild(debug);
}
 
示例5
private void displayNormals(Spatial s) {
    final Node debugTangents = new Node("debug tangents");
    debugTangents.setCullHint(Spatial.CullHint.Never);

    rootNode.attachChild(debugTangents);

    final Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
    debugMat.getAdditionalRenderState().setLineWidth(2);

    s.depthFirstTraversal(new SceneGraphVisitorAdapter() {
        @Override
        public void visit(Geometry g) {
            Mesh m = g.getMesh();
            Geometry debug = new Geometry(
                    "debug tangents geom",
                    TangentBinormalGenerator.genNormalLines(m, 0.1f)
            );
            debug.setMaterial(debugMat);
            debug.setCullHint(Spatial.CullHint.Never);
            debug.setLocalTransform(g.getWorldTransform());
            debugTangents.attachChild(debug);
        }
    });
}
 
示例6
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
            
    Node floorGeom = new Node("floorGeom");
    Quad q = new Quad(100, 100);
    q.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry g = new Geometry("geom", q);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    floorGeom.attachChild(g);
    
    
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(-50, 22, 60);
    //floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
示例7
@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);

    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.setColor("Ambient", ColorRGBA.DarkGray);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setBoolean("UseMaterialColors", true);
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);

    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(4f, 0f, 0f));
    rootNode.addLight(pl);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);
}
 
示例8
@Override
    public void simpleInitApp() {
        Quad quadMesh = new Quad(1, 1);

        Geometry sphere = new Geometry("Rock Ball", quadMesh);
        Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m");
        sphere.setMaterial(mat);
        TangentBinormalGenerator.generate(sphere);
        rootNode.attachChild(sphere);

        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
        lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
        rootNode.attachChild(lightMdl);

        pl = new PointLight();
        pl.setColor(ColorRGBA.White);
        pl.setPosition(new Vector3f(0f, 0f, 4f));
        rootNode.addLight(pl);

//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
//        dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
//        rootNode.addLight(dl);
    }
 
示例9
@Override
    public void simpleInitApp() {
        Sphere sphMesh = new Sphere(32, 32, 1);
        sphMesh.setTextureMode(Sphere.TextureMode.Projected);
        sphMesh.updateGeometry(32, 32, 1, false, false);
        TangentBinormalGenerator.generate(sphMesh);

        Geometry sphere = new Geometry("Rock Ball", sphMesh);
        Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
        sphere.setMaterial(mat);
        rootNode.attachChild(sphere);

        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
        lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
        rootNode.attachChild(lightMdl);

        pl = new PointLight();
        pl.setColor(ColorRGBA.White);
        pl.setPosition(new Vector3f(0f, 0f, 4f));
        rootNode.addLight(pl);

//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(new Vector3f(1,-1,1).normalizeLocal());
//        dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
//        rootNode.addLight(dl);
    }
 
示例10
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR.j3m");
    //mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWallPBR2.j3m");
            
    Node floorGeom = new Node("floorGeom");
    Quad q = new Quad(100, 100);
    q.scaleTextureCoordinates(new Vector2f(10, 10));
    Geometry g = new Geometry("geom", q);
    g.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.HALF_PI, Vector3f.UNIT_X));
    floorGeom.attachChild(g);
    
    
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(-50, 22, 60);
    //floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
示例11
@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);

    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.setColor("Ambient", ColorRGBA.DarkGray);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setBoolean("UseMaterialColors", true);
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);

    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(4f, 0f, 0f));
    rootNode.addLight(pl);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);
}
 
示例12
@Override
public void simpleInitApp() {
    Spatial signpost = (Spatial) assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml"));
    signpost.setMaterial( (Material) assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"));
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);

    lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
    lightMdl.setMaterial( (Material) assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
    rootNode.attachChild(lightMdl);

    // flourescent main light
    pl = new PointLight();
    pl.setColor(new ColorRGBA(0.88f, 0.92f, 0.95f, 1.0f));
    rootNode.addLight(pl);
    
    AmbientLight al = new AmbientLight();
    al.setColor(new ColorRGBA(0.44f, 0.40f, 0.20f, 1.0f));
    rootNode.addLight(al);
    
    DirectionalLight dl = new DirectionalLight();
    dl.setDirection(new Vector3f(1,-1,-1).normalizeLocal());
    dl.setColor(new ColorRGBA(0.92f, 0.85f, 0.8f, 1.0f));
    rootNode.addLight(dl);
}
 
示例13
public void setupFloor(){
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
   // mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess",3);
  //  mat.setBoolean("VertexLighting", true);
    
    
    Box floor = new Box(Vector3f.ZERO, 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);
}
 
示例14
private void addMesh(String name, Mesh mesh, Vector3f translation) {
    TangentBinormalGenerator.generate(mesh);

    Geometry testGeom = new Geometry(name, mesh);
    Material mat = assetManager.loadMaterial("Textures/BumpMapTest/Tangent.j3m");
    testGeom.setMaterial(mat);
    testGeom.getLocalTranslation().set(translation);
    rootNode.attachChild(testGeom);

    Geometry debug = new Geometry(
            "Debug " + name,
            TangentBinormalGenerator.genTbnLines(mesh, 0.08f)
    );
    Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
    debug.setMaterial(debugMat);
    debug.setCullHint(Spatial.CullHint.Never);
    debug.getLocalTranslation().set(translation);
    rootNode.attachChild(debug);
}
 
示例15
public void setupFloor() {
    mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall2.j3m");
    mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
    mat.setFloat("Shininess", 0);

    Node floorGeom = (Node) assetManager.loadAsset("Models/WaterTest/WaterTest.mesh.xml");
    Geometry g = ((Geometry) floorGeom.getChild(0));
    g.getMesh().scaleTextureCoordinates(new Vector2f(10, 10));
    TangentBinormalGenerator.generate(floorGeom);
    floorGeom.setLocalTranslation(0, 22, 0);
    floorGeom.setLocalScale(100);

    floorGeom.setMaterial(mat);        
    rootNode.attachChild(floorGeom);
}
 
示例16
@Override
public void simpleInitApp() {
    Sphere sphMesh = new Sphere(32, 32, 1);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 1, false, false);
    TangentBinormalGenerator.generate(sphMesh);

    Geometry sphere = new Geometry("Rock Ball", sphMesh);
    Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
    mat.setColor("Ambient", ColorRGBA.DarkGray);
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setBoolean("UseMaterialColors", true);
    sphere.setMaterial(mat);
    rootNode.attachChild(sphere);

    PointLight pl = new PointLight();
    pl.setColor(ColorRGBA.White);
    pl.setPosition(new Vector3f(4f, 0f, 0f));
    rootNode.addLight(pl);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);
}
 
示例17
@Override
    public void simpleInitApp() {
        Quad quadMesh = new Quad(1, 1);

        Geometry sphere = new Geometry("Rock Ball", quadMesh);
        Material mat = assetManager.loadMaterial("Textures/BumpMapTest/SimpleBump.j3m");
        sphere.setMaterial(mat);
        TangentBinormalGenerator.generate(sphere);
        rootNode.attachChild(sphere);

        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
        lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
        rootNode.attachChild(lightMdl);

        pl = new PointLight();
        pl.setColor(ColorRGBA.White);
        pl.setPosition(new Vector3f(0f, 0f, 4f));
        rootNode.addLight(pl);

//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(new Vector3f(1, -1, -1).normalizeLocal());
//        dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
//        rootNode.addLight(dl);
    }
 
示例18
@Override
    public void simpleInitApp() {
        Sphere sphMesh = new Sphere(32, 32, 1);
        sphMesh.setTextureMode(Sphere.TextureMode.Projected);
        sphMesh.updateGeometry(32, 32, 1, false, false);
        TangentBinormalGenerator.generate(sphMesh);

        Geometry sphere = new Geometry("Rock Ball", sphMesh);
        Material mat = assetManager.loadMaterial("Textures/Terrain/Pond/Pond.j3m");
        sphere.setMaterial(mat);
        rootNode.attachChild(sphere);

        lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
        lightMdl.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
        rootNode.attachChild(lightMdl);

        pl = new PointLight();
        pl.setColor(ColorRGBA.White);
        pl.setPosition(new Vector3f(0f, 0f, 4f));
        rootNode.addLight(pl);

//        DirectionalLight dl = new DirectionalLight();
//        dl.setDirection(new Vector3f(1,-1,1).normalizeLocal());
//        dl.setColor(new ColorRGBA(0.22f, 0.15f, 0.1f, 1.0f));
//        rootNode.addLight(dl);
    }
 
示例19
private  void initWidget() {
    SceneApplication.getApplication().addSceneListener(this);
    Sphere sphMesh = new Sphere(32, 32, 2.5f);
    sphMesh.setTextureMode(Sphere.TextureMode.Projected);
    sphMesh.updateGeometry(32, 32, 2.5f, false, false);
    TangentBinormalGenerator.generate(sphMesh);
    sphere = new Geometry("previewSphere", sphMesh);
    sphere.setLocalRotation(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_X));

    Box boxMesh = new Box(new Vector3f(0, 0, 0), 1.75f, 1.75f, 1.75f);
    TangentBinormalGenerator.generate(boxMesh);
    box = new Geometry("previewBox", boxMesh);
    box.setLocalRotation(new Quaternion().fromAngleAxis(-FastMath.DEG_TO_RAD * 30, Vector3f.UNIT_X).multLocal(new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Y)));

    Quad quadMesh = new Quad(4.5f, 4.5f);
    TangentBinormalGenerator.generate(quadMesh);
    quad = new Geometry("previewQuad", quadMesh);
    quad.setLocalTranslation(new Vector3f(-2.25f, -2.25f, 0));

    currentGeom = sphere;
    sphereButton.setSelected(true);
    init=true;
}
 
示例20
private void createTrangentsUndo(final Mesh mesh) {
    if (mesh != null) {
        Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() {
            
            @Override
            public void sceneUndo() throws CannotUndoException {
                mesh.clearBuffer(Type.Tangent);
            }
            
            @Override
            public void sceneRedo() throws CannotRedoException {
                TangentBinormalGenerator.generate(mesh);
            }
        });
    }
}
 
示例21
public void generateDebugTangents(Material mat) {
    for (int x = children.size(); --x >= 0;) {
        Spatial child = children.get(x);
        if (child instanceof TerrainQuad) {
            ((TerrainQuad)child).generateDebugTangents(mat);
        } else if (child instanceof TerrainPatch) {
            Geometry debug = new Geometry( "Debug " + name,
                TangentBinormalGenerator.genTbnLines( ((TerrainPatch)child).getMesh(), 0.8f));
            attachChild(debug);
            debug.setLocalTranslation(child.getLocalTranslation());
            debug.setCullHint(CullHint.Never);
            debug.setMaterial(mat);
        }
    }
}
 
示例22
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);
}
 
示例23
private void createDebugTangents(Geometry geom) {
    Geometry debug = new Geometry(
            "Debug " + geom.getName(),
            TangentBinormalGenerator.genTbnLines(geom.getMesh(), 0.8f)
    );
    Material debugMat = assetManager.loadMaterial("Common/Materials/VertexColor.j3m");
    debug.setMaterial(debugMat);
    debug.setCullHint(Spatial.CullHint.Never);
    debug.getLocalTranslation().set(geom.getWorldTranslation());
    debugNode.attachChild(debug);
}
 
示例24
@Override
    public void simpleInitApp() {
        Box aBox = new Box(1, 1, 1);
        Geometry aGeometry = new Geometry("Box", aBox);
        TangentBinormalGenerator.generate(aBox);

        Material aMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
        aMaterial.setTexture("DiffuseMap",
                assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
        aMaterial.setTexture("NormalMap",
                assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall_normal.jpg"));
        aMaterial.setBoolean("UseMaterialColors", false);
        aMaterial.setColor("Diffuse", ColorRGBA.White);
        aMaterial.setColor("Specular", ColorRGBA.White);
        aMaterial.setFloat("Shininess", 64f);
        aGeometry.setMaterial(aMaterial);

        // Rotate 45 degrees to see multiple faces
        aGeometry.rotate(FastMath.QUARTER_PI, FastMath.QUARTER_PI, 0.0f);
        rootNode.attachChild(aGeometry);

        /**
         * Must add a light to make the lit object visible!
         */
        PointLight aLight = new PointLight();
        aLight.setPosition(new Vector3f(0, 3, 3));
        aLight.setColor(ColorRGBA.Red);
        rootNode.addLight(aLight);
//
//        AmbientLight bLight = new AmbientLight();
//        bLight.setColor(ColorRGBA.Gray);
//        rootNode.addLight(bLight);

        
        ChaseCameraAppState chaser = new ChaseCameraAppState();
        chaser.setTarget(aGeometry);
        getStateManager().attach(chaser);
    }
 
示例25
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    //   mat.setBoolean("VertexLighting", true);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
}
 
示例26
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
  //   mat.setBoolean("VertexLighting", true);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
}
 
示例27
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material matSp = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    TangentBinormalGenerator.generate(signpost);
    signpost.setMaterial(matSp);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 23.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
示例28
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    TangentBinormalGenerator.generate(signpost);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 23.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
示例29
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);
}
 
示例30
public void generateDebugTangents(Material mat) {
    for (int x = children.size(); --x >= 0;) {
        Spatial child = children.get(x);
        if (child instanceof TerrainQuad) {
            ((TerrainQuad)child).generateDebugTangents(mat);
        } else if (child instanceof TerrainPatch) {
            Geometry debug = new Geometry( "Debug " + name,
                TangentBinormalGenerator.genTbnLines( ((TerrainPatch)child).getMesh(), 0.8f));
            attachChild(debug);
            debug.setLocalTranslation(child.getLocalTranslation());
            debug.setCullHint(CullHint.Never);
            debug.setMaterial(mat);
        }
    }
}