Search in sources :

Example 31 with Quad

use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.

the class BasicProfilerState method refreshBackground.

protected void refreshBackground() {
    Mesh mesh = background.getMesh();
    int size = profiler.getFrameCount();
    float frameTime = 1000f / 60;
    mesh.setBuffer(Type.Position, 3, new float[] { // first quad
    0, 0, 0, size, 0, 0, size, frameTime, 0, 0, frameTime, 0, // second quad
    0, frameTime, 0, size, frameTime, 0, size, frameTime * 2, 0, 0, frameTime * 2, 0, // 'update' stats against bright backgrounds
    0, -2, 0, size, -2, 0, size, 0, 0, 0, 0, 0 });
    mesh.setBuffer(Type.Color, 4, new float[] { // first quad, within normal frame limits
    0, 1, 0, 0.25f, 0, 1, 0, 0.25f, 0, 0.25f, 0, 0.25f, 0, 0.25f, 0, 0.25f, // Second quad, dropped frames                    
    0.25f, 0, 0, 0.25f, 0.25f, 0, 0, 0.25f, 1, 0, 0, 0.25f, 1, 0, 0, 0.25f, 0, 0, 0, 0.5f, 0, 0, 0, 0.5f, 0, 0, 0, 0.5f, 0, 0, 0, 0.5f });
    mesh.setBuffer(Type.Index, 3, new short[] { 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11 });
}
Also used : Mesh(com.jme3.scene.Mesh)

Example 32 with Quad

use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.

the class FilterPostProcessor method initialize.

public void initialize(RenderManager rm, ViewPort vp) {
    renderManager = rm;
    renderer = rm.getRenderer();
    viewPort = vp;
    fsQuad = new Picture("filter full screen quad");
    fsQuad.setWidth(1);
    fsQuad.setHeight(1);
    if (fbFormat == Format.RGB111110F && !renderer.getCaps().contains(Caps.PackedFloatTexture)) {
        fbFormat = Format.RGB8;
    }
    Camera cam = vp.getCamera();
    //save view port diensions
    left = cam.getViewPortLeft();
    right = cam.getViewPortRight();
    top = cam.getViewPortTop();
    bottom = cam.getViewPortBottom();
    originalWidth = cam.getWidth();
    originalHeight = cam.getHeight();
    //first call to reshape
    reshape(vp, cam.getWidth(), cam.getHeight());
}
Also used : Picture(com.jme3.ui.Picture)

Example 33 with Quad

use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.

the class MikktspaceTangentGenerator method genTangSpace.

public static boolean genTangSpace(MikkTSpaceContext mikkTSpace, final float angularThreshold) {
    // count nr_triangles
    int[] piTriListIn;
    int[] piGroupTrianglesBuffer;
    TriInfo[] pTriInfos;
    Group[] pGroups;
    TSpace[] psTspace;
    int iNrTrianglesIn = 0;
    int iNrTSPaces, iTotTris, iDegenTriangles, iNrMaxGroups;
    int iNrActiveGroups, index;
    final int iNrFaces = mikkTSpace.getNumFaces();
    //boolean bRes = false;
    final float fThresCos = (float) FastMath.cos((angularThreshold * (float) FastMath.PI) / 180.0f);
    // count triangles on supported faces
    for (int f = 0; f < iNrFaces; f++) {
        final int verts = mikkTSpace.getNumVerticesOfFace(f);
        if (verts == 3) {
            ++iNrTrianglesIn;
        } else if (verts == 4) {
            iNrTrianglesIn += 2;
        }
    }
    if (iNrTrianglesIn <= 0) {
        return false;
    }
    piTriListIn = new int[3 * iNrTrianglesIn];
    pTriInfos = new TriInfo[iNrTrianglesIn];
    // make an initial triangle -. face index list
    iNrTSPaces = generateInitialVerticesIndexList(pTriInfos, piTriListIn, mikkTSpace, iNrTrianglesIn);
    // make a welded index list of identical positions and attributes (pos, norm, texc)        
    generateSharedVerticesIndexList(piTriListIn, mikkTSpace, iNrTrianglesIn);
    // Mark all degenerate triangles
    iTotTris = iNrTrianglesIn;
    iDegenTriangles = 0;
    for (int t = 0; t < iTotTris; t++) {
        final int i0 = piTriListIn[t * 3 + 0];
        final int i1 = piTriListIn[t * 3 + 1];
        final int i2 = piTriListIn[t * 3 + 2];
        final Vector3f p0 = getPosition(mikkTSpace, i0);
        final Vector3f p1 = getPosition(mikkTSpace, i1);
        final Vector3f p2 = getPosition(mikkTSpace, i2);
        if (p0.equals(p1) || p0.equals(p2) || p1.equals(p2)) {
            // degenerate
            pTriInfos[t].flag |= MARK_DEGENERATE;
            ++iDegenTriangles;
        }
    }
    iNrTrianglesIn = iTotTris - iDegenTriangles;
    // mark all triangle pairs that belong to a quad with only one
    // good triangle. These need special treatment in DegenEpilogue().
    // Additionally, move all good triangles to the start of
    // pTriInfos[] and piTriListIn[] without changing order and
    // put the degenerate triangles last.
    degenPrologue(pTriInfos, piTriListIn, iNrTrianglesIn, iTotTris);
    // evaluate triangle level attributes and neighbor list        
    initTriInfo(pTriInfos, piTriListIn, mikkTSpace, iNrTrianglesIn);
    // based on the 4 rules, identify groups based on connectivity
    iNrMaxGroups = iNrTrianglesIn * 3;
    pGroups = new Group[iNrMaxGroups];
    piGroupTrianglesBuffer = new int[iNrTrianglesIn * 3];
    iNrActiveGroups = build4RuleGroups(pTriInfos, pGroups, piGroupTrianglesBuffer, piTriListIn, iNrTrianglesIn);
    psTspace = new TSpace[iNrTSPaces];
    for (int t = 0; t < iNrTSPaces; t++) {
        TSpace tSpace = new TSpace();
        tSpace.os.set(1.0f, 0.0f, 0.0f);
        tSpace.magS = 1.0f;
        tSpace.ot.set(0.0f, 1.0f, 0.0f);
        tSpace.magT = 1.0f;
        psTspace[t] = tSpace;
    }
    // make tspaces, each group is split up into subgroups if necessary
    // based on fAngularThreshold. Finally a tangent space is made for
    // every resulting subgroup
    generateTSpaces(psTspace, pTriInfos, pGroups, iNrActiveGroups, piTriListIn, fThresCos, mikkTSpace);
    // degenerate quads with one good triangle will be fixed by copying a space from
    // the good triangle to the coinciding vertex.
    // all other degenerate triangles will just copy a space from any good triangle
    // with the same welded index in piTriListIn[].
    DegenEpilogue(psTspace, pTriInfos, piTriListIn, mikkTSpace, iNrTrianglesIn, iTotTris);
    index = 0;
    for (int f = 0; f < iNrFaces; f++) {
        final int verts = mikkTSpace.getNumVerticesOfFace(f);
        if (verts != 3 && verts != 4) {
            continue;
        }
        // set data
        for (int i = 0; i < verts; i++) {
            final TSpace pTSpace = psTspace[index];
            float[] tang = { pTSpace.os.x, pTSpace.os.y, pTSpace.os.z };
            float[] bitang = { pTSpace.ot.x, pTSpace.ot.y, pTSpace.ot.z };
            mikkTSpace.setTSpace(tang, bitang, pTSpace.magS, pTSpace.magT, pTSpace.orient, f, i);
            mikkTSpace.setTSpaceBasic(tang, pTSpace.orient == true ? 1.0f : (-1.0f), f, i);
            ++index;
        }
    }
    return true;
}
Also used : Vector3f(com.jme3.math.Vector3f)

Example 34 with Quad

use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.

the class TestJaime method setupFloor.

public void setupFloor() {
    Quad q = new Quad(20, 20);
    q.scaleTextureCoordinates(Vector2f.UNIT_XY.mult(10));
    Geometry geom = new Geometry("floor", q);
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    mat.setColor("Diffuse", ColorRGBA.White);
    mat.setColor("Specular", ColorRGBA.White);
    mat.setColor("Ambient", ColorRGBA.Black);
    mat.setBoolean("UseMaterialColors", true);
    mat.setFloat("Shininess", 0);
    geom.setMaterial(mat);
    geom.rotate(-FastMath.HALF_PI, 0, 0);
    geom.center();
    geom.setShadowMode(RenderQueue.ShadowMode.Receive);
    rootNode.attachChild(geom);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Material(com.jme3.material.Material)

Example 35 with Quad

use of com.jme3.scene.shape.Quad in project jmonkeyengine by jMonkeyEngine.

the class TestOnlineJar 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://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/town.zip", HttpZipLocator.class);
    assetManager.registerLocator("https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/jmonkeyengine/wildhouse.zip", HttpZipLocator.class);
    Picture pic1 = new Picture("Picture1");
    pic1.move(0, 0, -1);
    pic1.setPosition(0, 0);
    pic1.setWidth(128);
    pic1.setHeight(128);
    pic1.setImage(assetManager, "grass.jpg", false);
    guiNode.attachChild(pic1);
    Picture pic2 = new Picture("Picture1");
    pic2.move(0, 0, -1);
    pic2.setPosition(128, 0);
    pic2.setWidth(128);
    pic2.setHeight(128);
    pic2.setImage(assetManager, "glasstile2.png", false);
    guiNode.attachChild(pic2);
}
Also used : Geometry(com.jme3.scene.Geometry) Quad(com.jme3.scene.shape.Quad) Picture(com.jme3.ui.Picture)

Aggregations

Geometry (com.jme3.scene.Geometry)36 Quad (com.jme3.scene.shape.Quad)35 Material (com.jme3.material.Material)30 Vector3f (com.jme3.math.Vector3f)23 Node (com.jme3.scene.Node)11 Spatial (com.jme3.scene.Spatial)10 DirectionalLight (com.jme3.light.DirectionalLight)9 Quaternion (com.jme3.math.Quaternion)9 Texture (com.jme3.texture.Texture)9 TerrainQuad (com.jme3.terrain.geomipmap.TerrainQuad)7 ColorRGBA (com.jme3.math.ColorRGBA)6 Vector2f (com.jme3.math.Vector2f)6 AmbientLight (com.jme3.light.AmbientLight)5 Mesh (com.jme3.scene.Mesh)5 Texture2D (com.jme3.texture.Texture2D)5 Picture (com.jme3.ui.Picture)5 File (java.io.File)5 ScreenshotAppState (com.jme3.app.state.ScreenshotAppState)4 BulletAppState (com.jme3.bullet.BulletAppState)4 CapsuleCollisionShape (com.jme3.bullet.collision.shapes.CapsuleCollisionShape)4