Package com.jme3.collision

Examples of com.jme3.collision.Collidable


        return flame;
  }

  public void onMove(int cursorId, int delta, int delta2, int newX, int newY) {
    if (cursorId == 0) {
      flame1.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(newX, newY), zPos));
    } else if(cursorId == 1) {
      flame2.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(newX, newY), zPos));
    }
  }
View Full Code Here


    }
  }

  public void onNew(int cursorId, int x, int y) {
    if (cursorId == 0) {
      flame1.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(x, y), zPos));
      flame1.setParticlesPerSec(100);
    } else if(cursorId == 1) {
      flame2.setLocalTranslation(cam.getWorldCoordinates(new Vector2f(x, y), zPos));
      flame2.setParticlesPerSec(100);
    }
  }
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

    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

TOP

Related Classes of com.jme3.collision.Collidable

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.