Package nu3a.math

Examples of nu3a.math.N3Vector3D


  /**
   * Obtiene la normal del poligono.
   */

  public N3Vector3D getPolygonNormal() {
    N3Vector3D normal = null;
    if (vertexes.size() > 2) {
      N3Point3D c = (N3Point3D) vertexes.elementAt(1);
      N3Point3D e1 = (N3Point3D) vertexes.elementAt(0);
      N3Point3D e2 = (N3Point3D) vertexes.elementAt(2);
      normal = new N3Vector3D(e2.x - c.x, e2.y - c.y, e2.z - c.z);
      normal.crossProduct(new N3Vector3D(e1.x - c.x, e1.y - c.y, e1.z
          - c.z));
      normal.normalize();
    }
    return normal;
  }
View Full Code Here


   * normales.
   */
  public void generateNormal() {
    if (vertexes.size() > 2) {
      try {
        N3Vector3D normal = getPolygonNormal();
        normals.clear();
        for (int i = 0; i < vertexes.size(); i++)
          normals.add(normal.copy());
      } catch (Exception e) {
      }
    }
  }
View Full Code Here

    render.setLightParam(render.N3_LINEAR_ATTENUATION,
        internalLight.getLinearAttenuation(), n);
    render.setLightParam(render.N3_QUADRATIC_ATTENUATION,
        internalLight.getQuadraticAttenuation(), n);

    N3Vector3D direction = internalLight.getDirection();
    this.dir[0] = direction.x;
    this.dir[1] = direction.y;
    this.dir[2] = direction.z;

    if (internalLight.getPositional()) {
View Full Code Here

  /**
   * Crea una instancia de la clase.
   */
  public N3NormalData() {
    normals = new Vector(0, 1);
    lastNormal = new N3Vector3D(0, 0, 1);
    begin();
  }
View Full Code Here

   *            Punto destino del rayo.
   */
  public N3Ray(N3Point3D src, N3Point3D dest) {
    this.src = new N3Point3D(src.x, src.y, src.z);
    this.dest = new N3Point3D(dest.x, dest.y, dest.z);
    d = new N3Vector3D(dest.x - src.x, dest.y - src.y, dest.z - src.z);
    d.normalize();
  }
View Full Code Here

  private boolean testPolygon(N3Polygon poly) {
    // Punto en el interior del poligono proyectado.
    N3Point2D inside;
    // Obtenemos el plano del poligono representado de la forma Ax + By +Cz
    // +D = 0
    N3Vector3D polyNormal = poly.getPolygonNormal();
    N3Point3D v = (N3Point3D) poly.getVertex(0);
    float polyD = -(polyNormal.x * v.x + polyNormal.y * v.y + polyNormal.z
        * v.z);
    // Primero comprobamos si hay intersecci�n entre el rayo y el plano
    // Substituimos (x,y,z)=(px,py,pz) + t(dx,dy,dz) en la ecuacion del
View Full Code Here

    Element vertexData;
    N3Polygon p;

    int index;
    N3Point3D v;
    N3Vector3D n;
    N3ColorRGBA c;
    N3TexCoord2D uv;

    N3GeometryData result = new N3GeometryData();
View Full Code Here

      throws N3NameException {
    super(scene, name);
    matrix = new N3Matrix4D();
    tmpAccMatrix = new N3Matrix4D();
    lastMatrix = new N3Matrix4D();
    translation = new N3Vector3D(0, 0, 0);
    scale = new N3Vector3D(1.0f, 1.0f, 1.0f);
    angle = 0;
    rotation = new N3Vector3D(1.0f, 1.0f, 1.0f);
    needTranslation = needScale = needRotation = false;
    matrix.identity();
  }
View Full Code Here

    grpScene = new N3GroupNode(scene, "grpScene");

    N3TransformationNode sueloRot = new N3TransformationNode(scene, "sueloRot");
    N3TransformationNode sueloTrans;
    sueloRot.rotate(-90.0f, new N3Vector3D(1.0f, 0, 0));
    sueloRot.update();
    N3GeometryData g = N3GeometryData.createPlane(0.4f, 0.4f, new N3ColorRGBA(1, 0, 0), false);
    N3Material sm = new N3Material(scene, "rojo");
    sm.setAmbientColor(new N3ColorRGBA(1, 0, 0));
    sm.setSpecularColor(new N3ColorRGBA(0, 0, 0), 0.1f);
    sm.setDiffuseColor(new N3ColorRGBA(1, 0, 0));
    sm.applyMaterial(true);
    for (int i = -5; i < 4; i++)
      for (int j = -5; j < 4; j++) {
        sueloTrans = new N3TransformationNode(scene, "sueloTrans" + i + "-" + j);
        sueloTrans.translate(new N3Vector3D(i * 0.4f, j * 0.4f, 0));
        sueloTrans.update();
        suelo = new N3VisualMesh(scene, g, "suelo" + i + "-" + j);
        suelo.setMaterial(sm);
        sueloTrans.addChild(suelo);
        sueloRot.addChild(sueloTrans);
      }

    cubeTrans = new N3TransformationNode(scene, "cubeTrans");
    cubeTrans.translate(new N3Vector3D(0, 0.2f, 1.0f));
    cubeTrans.update();

    // El otro cubo
    N3TransformationNode cubeTrans2 = new N3TransformationNode(scene, "cubeTrans2");
    cubeTrans2.translate(new N3Vector3D(-0.5f, 0.2f, -0.5f));
    cubeTrans2.update();

    cube = new N3VisualMesh(scene, N3GeometryData.createCube(0.4f, 0.4f, 0.4f, new N3ColorRGBA(1, 1, 1), true), "cube");
    cube.setMaterial(material);

    // El otro cubo
    cube2 = new N3VisualMesh(scene, N3GeometryData.createCube(0.4f, 0.4f, 0.4f, new N3ColorRGBA(1, 1, 1), true), "cube2");
    cube2.setMaterial(material);

    sphereTrans = new N3TransformationNode(scene, "sphereTrans");
    sphereTrans.translate(new N3Vector3D(0.5f, 0.5f, 0.0f));
    sphereTrans.update();

    sphere = new N3VisualMesh(scene, N3GeometryData.createSphere(20, 20, 0.15f, new N3ColorRGBA(0, 0, 1)), "sphere");
    sphere.setMaterial(new N3Material(scene, "Azul"));
    sphere.getMaterial().setAmbientColor(new N3ColorRGBA(0, 0, 1));
    sphere.getMaterial().setSpecularColor(new N3ColorRGBA(0, 0, 0), 0.1f);
    sphere.getMaterial().setDiffuseColor(new N3ColorRGBA(0, 0, 1));
    sphere.getMaterial().applyMaterial(true);

    camera1Trans = new N3TransformationNode(scene, "camera1Trans");
    camera1Trans.translate(new N3Vector3D(0.0f, 2.0f, 3.0f));
    camera1Trans.update();

    N3Camera camera1 = new N3Camera(new Rectangle(0, 0, c.getWidth(), c.getHeight()), 60.0f, c.getWidth() / c.getHeight(), 0.1f, 100.0f, scene, "camera1");

    light01Trans = new N3TransformationNode(scene, "light01Trans");
    light01Trans.translate(new N3Vector3D(0, 5.0f, 0.0f));
    light01Trans.update();

    light01 = new N3Light(N3LightData.createSpotLightData(new N3ColorRGBA(0, 0, 0), new N3ColorRGBA(1, 1, 1), new N3ColorRGBA(1, 1, 1), new N3Vector3D(0, -1.0f, 0), spotAngle), scene, "light01");

    root.addChild(grpScene);
    root.addChild(camera1Trans);
    root.addChild(light01Trans);
    grpScene.addChild(sueloRot);
    root.addChild(cubeTrans);
    grpScene.addChild(sphereTrans);
    sphereTrans.addChild(sphere);
    cubeTrans.addChild(cube);
    camera1Trans.addChild(camera1);
    light01Trans.addChild(light01);

    // El otro cubo
    cubeTrans2.addChild(cube2);
    grpScene.addChild(cubeTrans2);

    camera1.setTarget(cube, new N3Vector3D(0, 1.0f, 0));
    scene.setActiveCamera(camera1);
    scene.setActiveLightCount(render.getMaxLights());
    scene.addActiveLight(light01);

    // Elegimos que objetos colisionan
View Full Code Here

  public void idle() {
    if (!start) {
      time = System.currentTimeMillis();
      start = true;
    }
    sphereTrans.rotate(1, new N3Vector3D(0, 1, 0));
    sphereTrans.update();

    display();
    i++;
    long now = System.currentTimeMillis();
View Full Code Here

TOP

Related Classes of nu3a.math.N3Vector3D

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.