本文整理匯總了Java中org.lwjgl.util.vector.Vector4f.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector4f.set方法的具體用法?Java Vector4f.set怎麽用?Java Vector4f.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.lwjgl.util.vector.Vector4f
的用法示例。
在下文中一共展示了Vector4f.set方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TRIANGLE_INTERSECT
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
public boolean TRIANGLE_INTERSECT(Vector4f orig, Vector4f dir, Vertex vert0, Vertex vert1, Vertex vert2, Vector4f intersection_point, double[] dist) {
double[] orig_arr = new double[] { orig.x, orig.y, orig.z };
double[] dir_arr = new double[] { dir.x, dir.y, dir.z };
double[] vert0_arr = new double[] { vert0.x, vert0.y, vert0.z };
double[] vert1_arr = new double[] { vert1.x, vert1.y, vert1.z };
double[] vert2_arr = new double[] { vert2.x, vert2.y, vert2.z };
if (TRIANGLE_INTERSECT2(orig_arr, dir_arr, vert0_arr, vert1_arr, vert2_arr)) {
intersection_point.set((float) (orig_arr[0] + dir_arr[0] * t), (float) (orig_arr[1] + dir_arr[1] * t), (float) (orig_arr[2] + dir_arr[2] * t), 1f);
dist[0] = t;
return true;
}
return false;
}
示例2: BARYCENTRIC
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
public double[] BARYCENTRIC(double[] point, double[] normal, double[] vert0, double[] vert1, double[] vert2, Vector4f intersection_point) {
double[] orig = new double[] { 100.0 * normal[0] + point[0], 100.0 * normal[1] + point[1], 100.0 * normal[2] + point[2] };
double diskr = 0;
double inv_diskr = 0;
corner1[0] = vert1[0] - vert0[0];
corner1[1] = vert1[1] - vert0[1];
corner1[2] = vert1[2] - vert0[2];
corner2[0] = vert2[0] - vert0[0];
corner2[1] = vert2[1] - vert0[1];
corner2[2] = vert2[2] - vert0[2];
pvec[0] = normal[1] * corner2[2] - normal[2] * corner2[1];
pvec[1] = normal[2] * corner2[0] - normal[0] * corner2[2];
pvec[2] = normal[0] * corner2[1] - normal[1] * corner2[0];
diskr = corner1[0] * pvec[0] + corner1[1] * pvec[1] + corner1[2] * pvec[2];
if (diskr > -TOLERANCE && diskr < TOLERANCE)
return null;
inv_diskr = 1d / diskr;
tvec[0] = orig[0] - vert0[0];
tvec[1] = orig[1] - vert0[1];
tvec[2] = orig[2] - vert0[2];
u = (tvec[0] * pvec[0] + tvec[1] * pvec[1] + tvec[2] * pvec[2]) * inv_diskr;
if (u < 0 || u > 1d)
return null;
qvec[0] = tvec[1] * corner1[2] - tvec[2] * corner1[1];
qvec[1] = tvec[2] * corner1[0] - tvec[0] * corner1[2];
qvec[2] = tvec[0] * corner1[1] - tvec[1] * corner1[0];
v = (normal[0] * qvec[0] + normal[1] * qvec[1] + normal[2] * qvec[2]) * inv_diskr;
if (v < 0 || u + v > 1d)
return null;
double w = 1.0 - u - v;
intersection_point.set((float) (vert0[0] * w + vert1[0] * u + vert2[0] * v), (float) (vert0[1] * w + vert1[1] * u + vert2[1] * v), (float) (vert0[2] * w + vert1[2] * u + vert2[2] * v), 1f);
return new double[] { u, v, w };
}
示例3: getVertexNormal
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
public Vector4f getVertexNormal(Vertex min) {
Vector4f result = new Vector4f(0f, 0f, 0f, 0f);
Set<VertexManifestation> linked = vertexLinkedToPositionInFile.get(min);
for (VertexManifestation m : linked) {
GData g = m.getGdata();
Vector3f n = null;
switch (g.type()) {
case 3:
GData3 g3 = (GData3) g;
n = new Vector3f(g3.xn, g3.yn, g3.zn);
break;
case 4:
GData4 g4 = (GData4) g;
n = new Vector3f(g4.xn, g4.yn, g4.zn);
break;
}
if (n != null) {
if (n.lengthSquared() != 0) {
n.normalise();
result.set(n.x + result.x, n.y + result.y, n.z + result.z);
}
}
}
if (result.lengthSquared() == 0)
return new Vector4f(0f, 0f, 1f, 1f);
result.normalise();
result.setW(1f);
return result;
}
示例4: Particle
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
public Particle(float angle) {
Matrix4f rot_matrix = new Matrix4f();
Vector3f axis = new Vector3f();
Vector4f uv_vector = new Vector4f();
Vector4f transform_uv_vector = new Vector4f();
rot_matrix.setIdentity();
axis.set(0f, 0f, 1f);
rot_matrix.rotate(angle, axis);
uv_vector.set(-.5f, -.5f, 0f, 0f);
Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector);
u1 = transform_uv_vector.getX() + .5f;
v1 = transform_uv_vector.getY() + .5f;
uv_vector.set(.5f, -.5f, 0f, 0f);
Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector);
u2 = transform_uv_vector.getX() + .5f;
v2 = transform_uv_vector.getY() + .5f;
uv_vector.set(.5f, .5f, 0f, 0f);
Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector);
u3 = transform_uv_vector.getX() + .5f;
v3 = transform_uv_vector.getY() + .5f;
uv_vector.set(-.5f, .5f, 0f, 0f);
Matrix4f.transform(rot_matrix, uv_vector, transform_uv_vector);
u4 = transform_uv_vector.getX() + .5f;
v4 = transform_uv_vector.getY() + .5f;
}
示例5: add
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
/**
* Add a vector to another vector and place the result in a destination
* vector.
* @param left The LHS vector
* @param right The RHS vector
* @param dest The destination vector, or null if a new vector is to be created
* @return the sum of left and right in dest
*/
public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) {
if (dest == null)
return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w);
else {
dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w);
return dest;
}
}
示例6: sub
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
/**
* Subtract a vector from another vector and place the result in a destination
* vector.
* @param left The LHS vector
* @param right The RHS vector
* @param dest The destination vector, or null if a new vector is to be created
* @return left minus right in dest
*/
public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) {
if (dest == null)
return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w);
else {
dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w);
return dest;
}
}
示例7: transformArray
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
private float[] transformArray(float[] points, Matrix4f transformation) {
float[] transformedPoints = new float[points.length];
Vector4f result = new Vector4f();
Vector4f vec = new Vector4f();
for(int i = 0; i < transformedPoints.length; i+=3) {
vec.set(points[i], points[i+1], points[i+2], 1f);
Matrix4f.transform(transformation, vec, result);
transformedPoints[i] = result.x;
transformedPoints[i+1] = result.y;
transformedPoints[i+2] = result.z;
}
return transformedPoints;
}
示例8: getScreenCoordinatesFrom3D
import org.lwjgl.util.vector.Vector4f; //導入方法依賴的package包/類
/**
* Transforms 3D space coordinates to screen coordinates
*
* @param x
* x-screen coordinate
* @param y
* y-screen coordinate
* @param z
* z-screen coordinate
* @return vector position on screen
*/
public Vector4f getScreenCoordinatesFrom3D(float x, float y, float z) {
Point cSize = c3d.getSize();
Vector4f relPos = new Vector4f(x, y, z, 1f);
Matrix4f.transform(c3d.getViewport(), relPos, relPos);
float cursor_x = 0.5f * cSize.x - relPos.x * View.PIXEL_PER_LDU;
float cursor_y = 0.5f * cSize.y + relPos.y * View.PIXEL_PER_LDU;
relPos.set(cursor_x, cursor_y, 0f, 1f);
return relPos;
}