Package com.jme3.scene.debug

Examples of com.jme3.scene.debug.Arrow


  /**
   * @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


    mat = new Material(assetManager, "MatDefs/SimpleAtmoshere.j3md");
   
    mat.setFloat("radius", radius);
    atmo = new Geometry("atmo_Planet", atmoSphere);
   
    Vector3f pos = new Vector3f(5,0,0);
    atmo.setLocalTranslation(pos);
    mat.setVector3("v3Center", pos);
   
   
    atmo.setMaterial(mat);
View Full Code Here

  @Override
  public void simpleUpdate(float tpf) {
    super.simpleUpdate(tpf);
   
    Vector3f camLocation = getCamera().getLocation();
    Material newMat = mat;
   
    Vector3f planetLocation = Vector3f.ZERO;
   
    newMat.setVector3("v3CameraPos", camLocation);
    /*
    float maxCamDistance = radius + planetLocation.subtract(camLocation).length();
    newMat.setFloat("maxCamDistance", maxCamDistance);
View Full Code Here

    @Override
    public void simpleUpdate(float tpf){
        angle += tpf;
        angle %= FastMath.TWO_PI;
       
        pl.setPosition(new Vector3f(FastMath.cos(angle) * 2f, 0.5f, FastMath.sin(angle) * 2f));
        lightMdl.setLocalTranslation(pl.getPosition());
    }
View Full Code Here

    app.start();
  }

  @Override
  public void simpleInitApp() {
        cam.setLocation(new Vector3f(3, 3, 3));
        cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
       
    Bubble b = new Bubble(1f, 4f);
    /*
    b.setMode(Mesh.Mode.Points);
 
View Full Code Here

    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

    for (int i = 0; i < samples; i++) {
      float x = FastMath.cos(angle) + center.x;
      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);
View Full Code Here

  }

  @Override
  public void onCamLocationChange(Vector3f camLoaction) {
   
        Vector3f newDirection = new Vector3f();
        Vector3f newUp = new Vector3f();
        Vector3f newLeft = new Vector3f();
       
        newDirection.set(camLoaction).subtractLocal(getLocalTranslation()).normalizeLocal();

        newUp.set(Vector3f.UNIT_Y);
       

        newLeft.set(newUp).crossLocal(newDirection).normalizeLocal();
        if (newLeft.equals(Vector3f.ZERO)) {
            if (newDirection.x != 0) {
                newLeft.set(newDirection.y, -newDirection.x, 0f);
            } else {
                newLeft.set(0f, newDirection.z, -newDirection.y);
            }
        }

        newUp.set(newDirection).crossLocal(newLeft).normalizeLocal();
       
View Full Code Here

    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;
View Full Code Here

 
  public void update(float tpf) {
    if (!isFinished()) {
      updateTimer(tpf);
      float p = getProgress();
      Vector3f tar = target.getLocalTranslation();
      Vector3f route = tar.subtract(start);
      route.multLocal(p);
      Vector3f newPos = start.add(route);
      position.setLocalTranslation(newPos);
    }
  }
View Full Code Here

TOP

Related Classes of com.jme3.scene.debug.Arrow

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.