当前位置: 首页>>代码示例>>Java>>正文


Java Vector3f.cross方法代码示例

本文整理汇总了Java中org.lwjgl.util.vector.Vector3f.cross方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.cross方法的具体用法?Java Vector3f.cross怎么用?Java Vector3f.cross使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.lwjgl.util.vector.Vector3f的用法示例。


在下文中一共展示了Vector3f.cross方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calculateNormals

import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
/**
    * Calculates the normals of the mesh using vector cross products
    * @param vertices The vertices of the mesh
    * @param indices The indices of the mesh
    */
   public static void calculateNormals(Vertex[] vertices, int[] indices) {
// Iterate through every face
for(int i = 0; i < indices.length; i+=3) {
    // Get the three indices for the triangle face
    int i0 = indices[i];
    int i1 = indices[i+1];
    int i2 = indices[i+2];
    
    // Get the two displacement vectors for the face from the base vertex (arbitrary)
    Vector3f v1 = Vector3f.sub(vertices[i1].getPos(), vertices[i0].getPos(), null);
    Vector3f v2 = Vector3f.sub(vertices[i2].getPos(), vertices[i0].getPos(), null);
    
    // Calculate the normal using the cross product of the two displacements
    Vector3f normal = Vector3f.cross(v1, v2, null);
    normal.normalise();
    
    // Set the normal to all the vertices in the face
    vertices[i0].setNormal(normal);
    vertices[i1].setNormal(normal);
    vertices[i2].setNormal(normal);
}
   }
 
开发者ID:camilne,项目名称:open-world,代码行数:28,代码来源:Mesh.java

示例2: calcNormal

import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
/**
 * Calculates the normal of the triangle made from the 3 vertices. The vertices must be specified in counter-clockwise order.
 * @param vertex0
 * @param vertex1
 * @param vertex2
 * @return
 */
public static Vector3f calcNormal(Vector3f vertex0, Vector3f vertex1, Vector3f vertex2) {
	Vector3f tangentA = Vector3f.sub(vertex1, vertex0, null);
	Vector3f tangentB = Vector3f.sub(vertex2, vertex0, null);
	Vector3f normal = Vector3f.cross(tangentA, tangentB, null);
	normal.normalise();
	return normal;
}
 
开发者ID:TheThinMatrix,项目名称:LowPolyWater,代码行数:15,代码来源:Maths.java

示例3: getFacingFromVertexData

import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (enumfacing == null)
    {
        return EnumFacing.UP;
    }
    else
    {
        return enumfacing;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:41,代码来源:FaceBakery.java

示例4: getFacingFromVertexData

import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (f1 < 0.719F)
    {
        if (enumfacing != EnumFacing.EAST && enumfacing != EnumFacing.WEST && enumfacing != EnumFacing.NORTH && enumfacing != EnumFacing.SOUTH)
        {
            enumfacing = EnumFacing.UP;
        }
        else
        {
            enumfacing = EnumFacing.NORTH;
        }
    }

    return enumfacing == null ? EnumFacing.UP : enumfacing;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:46,代码来源:FaceBakery.java

示例5: getFacingFromVertexData

import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
public static EnumFacing getFacingFromVertexData(int[] faceData)
{
    int i = faceData.length / 4;
    int j = i * 2;
    Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2]));
    Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[i]), Float.intBitsToFloat(faceData[i + 1]), Float.intBitsToFloat(faceData[i + 2]));
    Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[j]), Float.intBitsToFloat(faceData[j + 1]), Float.intBitsToFloat(faceData[j + 2]));
    Vector3f vector3f3 = new Vector3f();
    Vector3f vector3f4 = new Vector3f();
    Vector3f vector3f5 = new Vector3f();
    Vector3f.sub(vector3f, vector3f1, vector3f3);
    Vector3f.sub(vector3f2, vector3f1, vector3f4);
    Vector3f.cross(vector3f4, vector3f3, vector3f5);
    float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z));
    vector3f5.x /= f;
    vector3f5.y /= f;
    vector3f5.z /= f;
    EnumFacing enumfacing = null;
    float f1 = 0.0F;

    for (EnumFacing enumfacing1 : EnumFacing.values())
    {
        Vec3i vec3i = enumfacing1.getDirectionVec();
        Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
        float f2 = Vector3f.dot(vector3f5, vector3f6);

        if (f2 >= 0.0F && f2 > f1)
        {
            f1 = f2;
            enumfacing = enumfacing1;
        }
    }

    if (enumfacing == null)
    {
        return EnumFacing.UP;
    }
    else
    {
        return enumfacing;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:43,代码来源:FaceBakery.java

示例6: calcNormal

import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
/**
 * Calculates the normal of the triangle made from the 3 vertices. The vertices must be specified in counter-clockwise order.
 *
 * @param vertex0
 * @param vertex1
 * @param vertex2
 * @return
 */
public static Vector3f calcNormal(Vector3f vertex0, Vector3f vertex1, Vector3f vertex2) {
    Vector3f tangentA = Vector3f.sub(vertex1, vertex0, null);
    Vector3f tangentB = Vector3f.sub(vertex2, vertex0, null);
    Vector3f normal = Vector3f.cross(tangentA, tangentB, null);
    normal.normalise();
    return normal;
}
 
开发者ID:GryPLOfficial,项目名称:EcoSystem-Official,代码行数:16,代码来源:Maths.java


注:本文中的org.lwjgl.util.vector.Vector3f.cross方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。