本文整理汇总了Java中org.lwjgl.util.vector.Vector3f.sub方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.sub方法的具体用法?Java Vector3f.sub怎么用?Java Vector3f.sub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lwjgl.util.vector.Vector3f
的用法示例。
在下文中一共展示了Vector3f.sub方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例2: calculateNormal
import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
/**
* Calculates the normal of a vertex based on the cross product of adjacent vertices.
* @param src The vertex of which to calculate the normal
* @param v1 The first vertex (Right-hand coordinate system)
* @param v2 The second vertex (Right-hand coordinate system)
*/
private void calculateNormal(Vertex src, Vector3f v, Vector3f v1, Vector3f v2) {
// Get the displacement vectors between the src vertex and the adjacent vertices.
Vector3f a = Vector3f.sub(v1, v, null);
Vector3f b = Vector3f.sub(v2, v, null);
// Calculate the normal and set it.
Vector3f.cross(b, a, src.getNormal()).normalise();
}
示例3: sub
import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
public static Colour sub(Colour colLeft, Colour colRight, Colour dest) {
if (dest == null) {
return new Colour(Vector3f.sub(colLeft.col, colRight.col, null));
} else {
Vector3f.sub(colLeft.col, colRight.col, dest.col);
return dest;
}
}
示例4: 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;
}
示例5: 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;
}
}
示例6: sub
import org.lwjgl.util.vector.Vector3f; //导入方法依赖的package包/类
public static Colour sub(Colour colLeft, Colour colRight, Colour dest) {
if (dest == null) {
return new Colour(Vector3f.sub(colLeft.col, colRight.col, null));
} else {
Vector3f.sub(colLeft.col, colRight.col, dest.col);
return dest;
}
}
示例7: 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;
}
示例8: 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;
}
}
示例9: 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;
}