Package com.jme3.asset

Examples of com.jme3.asset.AssetManager


    ti.onNew(0, 0, 0);
    gestureSystem.update(1);
    ti.onRelease(0);
    gestureSystem.update(1);
    //printList(clickVectors);
    Assert.assertTrue(clickVectors.get(0).equals(new Vector2f(0,0)));
    Assert.assertTrue(zoomValues.isEmpty());
  }
View Full Code Here


   
    float rw = radius/width;
   
    //left center
    vertices[0] = ref.clone();
    texCoord[0] = new Vector2f(0.5f, rw);
   
    // draw left half circle
    int lastPoint = 0;
    for (int i = 0; i <= samples; i++) {
      float x = FastMath.cos(angle);
      float z = FastMath.sin(angle);
      int verticesBase = i+1;
      int indicesBase = (i-1)*3;
      vertices[verticesBase] = new Vector3f((x * radius) + ref.x, ref.y, (z * radius) + ref.z);
      texCoord[verticesBase] = new Vector2f((x * 0.5f) + 0.5f, rw-(z * rw));
      System.out.println(texCoord[verticesBase]);
      if (lastPoint > 0) {
        indices[indicesBase] = 0;
        indices[indicesBase+1] = verticesBase;
        indices[indicesBase+2] = lastPoint;
      }
      lastPoint = verticesBase;
      angle += rate;
    }
   
    // right center
    ref.z = radius-width/2f;
    int base2 = samples+2;
    vertices[base2] = ref.clone();
   
    float rbw = (width-radius)/width;
    texCoord[base2] = new Vector2f(0.5f, rbw);
    angle = FastMath.PI;
    lastPoint = 0;
   
    // draw right half circle
    for (int i = 0; i <= samples; i++) {
      float x = FastMath.cos(angle);
      float z = FastMath.sin(angle);
      int verticesBase = i+samples+3;
      int indicesBase = (i+samples)*3;
      vertices[verticesBase] = new Vector3f((x * radius) + ref.x, ref.y, (z * radius) + ref.z);
      texCoord[verticesBase] = new Vector2f((x * 0.5f) + 0.5f, 1 - (z * rw));
      if (lastPoint > 0) {
        indices[indicesBase] = base2;
        indices[indicesBase+1] = verticesBase;
        indices[indicesBase+2] = lastPoint;
      }
View Full Code Here

      float y = FastMath.sin(angle) + center.y;
      int base = i*2;
      int indicesBase = i*6;
      vertices[base] = new Vector3f(x * radius, y * radius, center.z);
      vertices[base+1] = new Vector3f(x * (radius-width), y * (radius-width), center.z);
      texCoord[base] = new Vector2f(x * radius, y * radius);
      texCoord[base+1] = new Vector2f(x * (radius-width), y * (radius-width));
     
      indices[indicesBase] = base;
      indices[indicesBase+1] = calc(base+1);
      indices[indicesBase+2] = calc(base-1);
     
View Full Code Here

    float rw = radius/width;
    float rbw = (width-radius)/width;
   
    //left center
    vertices[0] = ref.clone();
    texCoord[0] = new Vector2f(rbw, 0.5f);
   
    // draw left half circle
    int lastPoint = 0;
    for (int i = 0; i <= samples; i++) {
      float x = FastMath.cos(angle);
      float z = FastMath.sin(angle);
      int verticesBase = i+1;
      int indicesBase = (i-1)*3;
      vertices[verticesBase] = new Vector3f((x * radius) + ref.x, ref.y, (z * radius) + ref.z);
      texCoord[verticesBase] = new Vector2f(1-rw+(z * rw), (x * 0.5f) + 0.5f);
      if (lastPoint > 0) {
        indices[indicesBase] = 0;
        indices[indicesBase+1] = verticesBase;
        indices[indicesBase+2] = lastPoint;
      }
      lastPoint = verticesBase;
      angle += rate;
    }
   
    // right center
    ref.z = radius-width/2f;
    int base2 = samples+2;
    vertices[base2] = ref.clone();
   
   
    texCoord[base2] = new Vector2f(rw, 0.5f);
    angle = FastMath.PI;
    lastPoint = 0;
   
    // draw right half circle
    for (int i = 0; i <= samples; i++) {
      float x = FastMath.cos(angle);
      float z = FastMath.sin(angle);
      int verticesBase = i+samples+3;
      int indicesBase = (i+samples)*3;
      vertices[verticesBase] = new Vector3f((x * radius) + ref.x, ref.y, (z * radius) + ref.z);
      texCoord[verticesBase] = new Vector2f(rw + (z * rw), (x * 0.5f) + 0.5f);
      System.out.println(texCoord[verticesBase]);
      if (lastPoint > 0) {
        indices[indicesBase] = base2;
        indices[indicesBase+1] = verticesBase;
        indices[indicesBase+2] = lastPoint;
View Full Code Here

    } else {
      cam.setCanZoom(false);
      cam.setZoomDistance(distanceAnimation.getDistance());
    }
    if (!rotationOffsetAnimation.isFinished()) {
      Vector2f rotationOffset = rotationOffsetAnimation.getRotationOffset();
      cam.setRotationOffset(rotationOffset.x, rotationOffset.y);
    }
    if (positionAnimation.isFinished() && target != null) {
      cam.setSpatial(target);
    }
View Full Code Here

    public ModelPosition(){
  this(0,0,0, 0,0,0);
    }
    public ModelPosition(float x, float y, float z,
       float rotx, float roty, float rotz){
  location = new Vector3f(x,y,z);
  rotation = new Vector3f(rotx,roty,rotz);
    }
View Full Code Here

        // calc the y-axis
        float y = 1.5f-base.y*0.072f;
        //1.412 = 0
        //0.207 = 18

        rightEye.move(new Vector3f(xR,y,0.932f));
        leftEye.move(new Vector3f( xL, y, 0.932f ));

        head.attachChild(leftEye);
        head.attachChild(rightEye);
        return true;
    }
View Full Code Here

    assetManager.registerLocator("file:"+path, UrlLocator.class.getName());
  }
 
  public void setDirectionalLight(final boolean on) {
    if (dl == null) {
      Vector3f lightDir = new Vector3f(-0.8719428f, -0.46824604f, 0.14304268f);
      dl = new DirectionalLight();
      dl.setColor(new ColorRGBA(1.0f, 0.92f, 0.75f, 1f));
      dl.setDirection(lightDir);

      Vector3f lightDir2 = new Vector3f(0.70518064f, 0.5902297f, -0.39287305f);
      dl2 = new DirectionalLight();
      dl2.setColor(new ColorRGBA(0.7f, 0.85f, 1.0f, 1f));
      dl2.setDirection(lightDir2);
    }
    this.enqueue(new Callable<Integer>(){
View Full Code Here

 
  public void setPointLight(final boolean on) {
    int dis = 10;
    if (ll == null) {
      ll = getPointLight();
      ll.setPosition(new Vector3f(0,dis,0));
      ll2 = getPointLight();
      ll2.setPosition(new Vector3f(0,-dis,0));
      ll3 = getPointLight();
      ll3.setPosition(new Vector3f(dis,0,0));
      ll4 = getPointLight();
      ll4.setPosition(new Vector3f(-dis,0,0));
      ll5 = getPointLight();
      ll5.setPosition(new Vector3f(0,0,dis));
      ll6 = getPointLight();
      ll6.setPosition(new Vector3f(0,0,-dis));
    }
    this.enqueue(new Callable<Integer>(){
      public Integer call() throws Exception {
        if (on) {
          rootNode.addLight(ll);
View Full Code Here

  /**
   * @param args
   */
  public static void main(String[] args) {
    Vector3f v3Pos = new Vector3f(0,5,0);
    Vector3f m_v3CameraPos = new Vector3f(20,0,0);
    Vector3f m_v3LightPos = Vector3f.UNIT_X;
    float m_fCameraHeight = 15f;
    float m_fSamples = 3f;
    float m_fInnerRadius = 5f;
    float m_fOuterRadius = m_fInnerRadius * 1.025f;
    float m_fCameraHeight2 = m_fCameraHeight * m_fCameraHeight;
    float m_fOuterRadius2 = m_fOuterRadius * m_fOuterRadius;
    float fInvScaleDepth = (1.0f / m_fScaleDepth);
    float m_nSamples = 3f;
    float m_fScale = 1.0f / ((m_fInnerRadius * 1.025f) - m_fInnerRadius);
    float m_fScaleOverScaleDepth = m_fScale / m_fScaleDepth;
    float m_v3InvWavelength = 0;
    float m_fKr4PI = 0;
    float m_fKm4PI = 0;
   
   
    System.out.println(scale(0));
    System.out.println(scale(1));
    System.out.println(scale(2));
    System.out.println(scale(3));
    //vec3 v3Ray = v3Pos - m_v3CameraPos;
    //float fFar = length(v3Ray);
    //v3Ray /= fFar;
    Vector3f v3Ray = v3Pos.subtract(m_v3CameraPos);
    System.out.println("v3Ray: "+v3Ray);
    float fFar = v3Ray.length();
    System.out.println("fFar: "+fFar);
    v3Ray.divideLocal(fFar);
    System.out.println("v3Ray: "+v3Ray);
   
    // Calculate the closest intersection of the ray with the outer atmosphere (which is the near point of the ray passing through the atmosphere)
    // float fNear = getNearIntersection(m_v3CameraPos, v3Ray, m_fCameraHeight2, m_fOuterRadius2);
    float fNear = getNearIntersection(m_v3CameraPos, v3Ray, m_fCameraHeight2, m_fOuterRadius2);
    System.out.println("fNear: "+fNear);
   
    // Calculate the ray's starting position, then calculate its scattering offset
    // vec3 v3Start = m_v3CameraPos + v3Ray * fNear;
    // fFar -= fNear;
    Vector3f v3Start = m_v3CameraPos.add(v3Ray.mult(fNear));
    System.out.println("v3Start: "+v3Start);
    fFar -= fNear;
    System.out.println("fFar: "+fFar);
   
    // Calculate the ray's start and end positions in the atmosphere, then calculate its scattering offset
    // float fStartAngle = dot(v3Ray, v3Start) / m_fOuterRadius;
    // float fStartDepth = exp(-fInvScaleDepth);
    // float fStartOffset = fStartDepth*scale(fStartAngle);
    float fStartAngle = v3Ray.dot(v3Start) / m_fOuterRadius;
    System.out.println("fStartAngle: "+fStartAngle);
    float fStartDepth = FastMath.exp(-fInvScaleDepth);
    System.out.println("fStartDepth: "+fStartDepth);
    float fStartOffset = fStartDepth*scale(fStartAngle);
    System.out.println("fStartOffset: "+fStartOffset);
   
    // Initialize the scattering loop variables
    // float fSampleLength = fFar / m_fSamples;
    // float fScaledLength = fSampleLength * m_fScale;
    // vec3 v3SampleRay = v3Ray * fSampleLength;
    // vec3 v3SamplePoint = v3Start + v3SampleRay * 0.5;
    float fSampleLength = fFar / m_fSamples;
    System.out.println("fSampleLength: "+fSampleLength);
    float fScaledLength = fSampleLength * m_fScale;
    System.out.println("fScaledLength: "+fScaledLength);
    Vector3f v3SampleRay = v3Ray.mult(fSampleLength);
    System.out.println("v3SampleRay: "+v3SampleRay);
    Vector3f v3SamplePoint = v3Start.add(v3SampleRay.mult(0.5f));
    System.out.println("v3SamplePoint: "+v3SamplePoint);
   
    // Now loop through the sample rays
    /*
       vec3 v3FrontColor = vec3(0.0, 0.0, 0.0);
       for(int i=0; i<m_nSamples; i++)
       {
          float fHeight = length(v3SamplePoint);
          float fDepth = exp(m_fScaleOverScaleDepth * (m_fInnerRadius - fHeight));
          float fLightAngle = dot(m_v3LightPos, v3SamplePoint) / fHeight;
          float fCameraAngle = dot(v3Ray, v3SamplePoint) / fHeight;
          float fScatter = (fStartOffset + fDepth*(scale(fLightAngle) - scale(fCameraAngle)));
          vec3 v3Attenuate = exp(-fScatter * (m_v3InvWavelength * m_fKr4PI + m_fKm4PI));
          v3FrontColor += v3Attenuate * (fDepth * fScaledLength);
          v3SamplePoint += v3SampleRay;
       }
      */
    Vector3f v3FrontColor = Vector3f.ZERO;
    for(int i=0; i<m_nSamples; i++) {
      System.out.println("sample: "+i);
      float fHeight = v3SamplePoint.length();
      System.out.println("\tfHeight: "+fHeight);
      float fDepth = FastMath.exp(m_fScaleOverScaleDepth * (m_fInnerRadius - fHeight));
      System.out.println("\tfDepth: "+fDepth);
      float fLightAngle = m_v3LightPos.dot(v3SamplePoint) / fHeight;
      System.out.println("\tfLightAngle: "+fLightAngle);
      float fCameraAngle = v3Ray.dot(v3SamplePoint) / fHeight;
      System.out.println("\tfCameraAngle: "+fCameraAngle);
      float fScatter = (fStartOffset + fDepth*(scale(fLightAngle) - scale(fCameraAngle)));
      System.out.println("\tfScatter: "+fScatter);
      float v3Attenuate = FastMath.exp(-fScatter * (m_v3InvWavelength * m_fKr4PI + m_fKm4PI));
      System.out.println("\tv3Attenuate: "+v3Attenuate);
      v3FrontColor.addLocal(new Vector3f(v3Attenuate,v3Attenuate,v3Attenuate));
      v3SamplePoint.addLocal(v3SampleRay);
    }
    System.out.println("v3FrontColor: "+v3FrontColor);
    System.out.println("v3SamplePoint: "+v3SamplePoint);
  }
View Full Code Here

TOP

Related Classes of com.jme3.asset.AssetManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.