Package com.base.engine.core

Examples of com.base.engine.core.Vector3f


    {
      int i0 = m_indices.get(i);
      int i1 = m_indices.get(i + 1);
      int i2 = m_indices.get(i + 2);

      Vector3f v1 = m_positions.get(i1).Sub(m_positions.get(i0));
      Vector3f v2 = m_positions.get(i2).Sub(m_positions.get(i0));

      Vector3f normal = v1.Cross(v2).Normalized();

      m_normals.get(i0).Set(m_normals.get(i0).Add(normal));
      m_normals.get(i1).Set(m_normals.get(i1).Add(normal));
      m_normals.get(i2).Set(m_normals.get(i2).Add(normal));
    }
View Full Code Here


    {
      int i0 = m_indices.get(i);
      int i1 = m_indices.get(i + 1);
      int i2 = m_indices.get(i + 2);

      Vector3f edge1 = m_positions.get(i1).Sub(m_positions.get(i0));
      Vector3f edge2 = m_positions.get(i2).Sub(m_positions.get(i0));

      float deltaU1 = m_texCoords.get(i1).GetX() - m_texCoords.get(i0).GetX();
      float deltaV1 = m_texCoords.get(i1).GetY() - m_texCoords.get(i0).GetY();
      float deltaU2 = m_texCoords.get(i2).GetX() - m_texCoords.get(i0).GetX();
      float deltaV2 = m_texCoords.get(i2).GetY() - m_texCoords.get(i0).GetY();

      float dividend = (deltaU1*deltaV2 - deltaU2*deltaV1);
      //TODO: The first 0.0f may need to be changed to 1.0f here.
      float f = dividend == 0 ? 0.0f : 1.0f/dividend;

      Vector3f tangent = new Vector3f(0,0,0);
      tangent.SetX(f * (deltaV2 * edge1.GetX() - deltaV1 * edge2.GetX()));
      tangent.SetY(f * (deltaV2 * edge1.GetY() - deltaV1 * edge2.GetY()));
      tangent.SetZ(f * (deltaV2 * edge1.GetZ() - deltaV1 * edge2.GetZ()));

      m_tangents.get(i0).Set(m_tangents.get(i0).Add(tangent));
      m_tangents.get(i1).Set(m_tangents.get(i1).Add(tangent));
      m_tangents.get(i2).Set(m_tangents.get(i2).Add(tangent));
    }
 
View Full Code Here

    this(pos, new Vector2f(0,0));
  }
 
  public Vertex(Vector3f pos, Vector2f texCoord)
  {
    this(pos, texCoord, new Vector3f(0,0,0));
  }
View Full Code Here

    this(pos, texCoord, new Vector3f(0,0,0));
  }
 
  public Vertex(Vector3f pos, Vector2f texCoord, Vector3f normal)
  {
    this(pos, texCoord, normal, new Vector3f(0,0,0));
  }
View Full Code Here

  public void AddVector3f(String name, Vector3f vector3f) { m_vector3fHashMap.put(name, vector3f); }
  public void AddFloat(String name, float floatValue) { m_floatHashMap.put(name, floatValue); }

  public Vector3f GetVector3f(String name)
  {
    Vector3f result = m_vector3fHashMap.get(name);
    if(result != null)
      return result;

    return new Vector3f(0,0,0);
  }
View Full Code Here

    {
      int i0 = indices[i];
      int i1 = indices[i + 1];
      int i2 = indices[i + 2];
     
      Vector3f v1 = vertices[i1].GetPos().Sub(vertices[i0].GetPos());
      Vector3f v2 = vertices[i2].GetPos().Sub(vertices[i0].GetPos());
     
      Vector3f normal = v1.Cross(v2).Normalized();
     
      vertices[i0].SetNormal(vertices[i0].GetNormal().Add(normal));
      vertices[i1].SetNormal(vertices[i1].GetNormal().Add(normal));
      vertices[i2].SetNormal(vertices[i2].GetNormal().Add(normal));
    }
View Full Code Here

        if(tokens.length == 0 || tokens[0].equals("#"))
          continue;
        else if(tokens[0].equals("v"))
        {
          m_positions.add(new Vector3f(Float.valueOf(tokens[1]),
              Float.valueOf(tokens[2]),
              Float.valueOf(tokens[3])));
        }
        else if(tokens[0].equals("vt"))
        {
          m_texCoords.add(new Vector2f(Float.valueOf(tokens[1]),
              1.0f - Float.valueOf(tokens[2])));
        }
        else if(tokens[0].equals("vn"))
        {
          m_normals.add(new Vector3f(Float.valueOf(tokens[1]),
              Float.valueOf(tokens[2]),
              Float.valueOf(tokens[3])));
        }
        else if(tokens[0].equals("f"))
        {
View Full Code Here

    for(int i = 0; i < m_indices.size(); i++)
    {
      OBJIndex currentIndex = m_indices.get(i);

      Vector3f currentPosition = m_positions.get(currentIndex.GetVertexIndex());
      Vector2f currentTexCoord;
      Vector3f currentNormal;

      if(m_hasTexCoords)
        currentTexCoord = m_texCoords.get(currentIndex.GetTexCoordIndex());
      else
        currentTexCoord = new Vector2f(0,0);

      if(m_hasNormals)
        currentNormal = m_normals.get(currentIndex.GetNormalIndex());
      else
        currentNormal = new Vector3f(0,0,0);

      Integer modelVertexIndex = resultIndexMap.get(currentIndex);

      if(modelVertexIndex == null)
      {
        modelVertexIndex = result.GetPositions().size();
        resultIndexMap.put(currentIndex, modelVertexIndex);

        result.GetPositions().add(currentPosition);
        result.GetTexCoords().add(currentTexCoord);
        if(m_hasNormals)
          result.GetNormals().add(currentNormal);
      }

      Integer normalModelIndex = normalIndexMap.get(currentIndex.GetVertexIndex());

      if(normalModelIndex == null)
      {
        normalModelIndex = normalModel.GetPositions().size();
        normalIndexMap.put(currentIndex.GetVertexIndex(), normalModelIndex);

        normalModel.GetPositions().add(currentPosition);
        normalModel.GetTexCoords().add(currentTexCoord);
        normalModel.GetNormals().add(currentNormal);
        normalModel.GetTangents().add(new Vector3f(0,0,0));
      }

      result.GetIndices().add(modelVertexIndex);
      normalModel.GetIndices().add(normalModelIndex);
      indexMap.put(modelVertexIndex, normalModelIndex);
View Full Code Here

    m_samplerMap = new HashMap<String, Integer>();
    m_samplerMap.put("diffuse", 0);
    m_samplerMap.put("normalMap", 1);
    m_samplerMap.put("dispMap", 2);

    AddVector3f("ambient", new Vector3f(0.1f, 0.1f, 0.1f));

    m_forwardAmbient = new Shader("forward-ambient");

    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
View Full Code Here

TOP

Related Classes of com.base.engine.core.Vector3f

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.