本文整理汇总了Java中org.rajawali3d.math.vector.Vector3.setAll方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3.setAll方法的具体用法?Java Vector3.setAll怎么用?Java Vector3.setAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rajawali3d.math.vector.Vector3
的用法示例。
在下文中一共展示了Vector3.setAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transform
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
public void transform(final Matrix4 matrix) {
mTransformedMin.setAll(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
mTransformedMax.setAll(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
for(mI=0; mI<8; ++mI) {
Vector3 o = mPoints[mI];
Vector3 d = mTmp[mI];
d.setAll(o);
d.multiply(matrix);
if(d.x < mTransformedMin.x) mTransformedMin.x = d.x;
if(d.y < mTransformedMin.y) mTransformedMin.y = d.y;
if(d.z < mTransformedMin.z) mTransformedMin.z = d.z;
if(d.x > mTransformedMax.x) mTransformedMax.x = d.x;
if(d.y > mTransformedMax.y) mTransformedMax.y = d.y;
if(d.z > mTransformedMax.z) mTransformedMax.z = d.z;
}
}
示例2: intersectRayPlane
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
/**
* Intersects a ray defined by a start and end point and a {@link Plane}.
* @param rayStart Startpoint of the ray
* @param rayEnd Endpoint of the ray
* @param plane The plane
* @param hitPoint The intersection point (optional)
* @return True if there is an intersection, false otherwise.
*/
public static boolean intersectRayPlane(Vector3 rayStart, Vector3 rayEnd, Plane plane, Vector3 hitPoint) {
Vector3 rayDir = Vector3.subtractAndCreate(rayEnd, rayStart);
double denorm = rayDir.dot(plane.getNormal());
if (denorm != 0) {
double t = -(rayStart.dot(plane.getNormal()) + plane.getD()) / denorm;
if (t < 0) return false;
if (hitPoint != null) hitPoint.addAndSet(rayStart, Vector3.scaleAndCreate(rayDir, t));
return true;
} else if (plane.getPointSide(rayStart) == Plane.PlaneSide.ONPLANE) {
if (hitPoint != null) hitPoint.setAll(rayStart);
return true;
} else {
return false;
}
}
示例3: calculatePoint
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
/**
* Calculates the position on the spiral for the specified polar angle. This takes an additional
* parameter of a {@link Vector3} which will be set to the calculated position.
*
* @param result {@link Vector3} to set with the updated position.
* @param theta {@code double} the polar angle to calculate for, in degrees.
*/
@Override
public void calculatePoint(Vector3 result, double theta) {
final double angle = mSpiralIn ? mThetaOffset + theta : theta - mThetaOffset;
final double r = a * Math.exp(mDensity * angle);
// Update the rotation
mRotation.fromAngleAxis(mUp, Math.toDegrees(angle)); //.inverse();
// Rotate the start-end vector based on the angle
mScratch.setAll(mRotation.multiply(mStart)).normalize();
// Set the correct length
result.setAll(mScratch.multiply(r));
if (mCalculateTangents) {
mCurrentTangent.crossAndSet(mUp, mScratch);
}
}
示例4: calculatePoint
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
/**
* Calculates the position on the spiral for the specified polar angle. This takes an additional
* parameter of a {@link Vector3} which will be set to the calculated position.
*
* @param result {@link Vector3} to set with the updated position.
* @param theta {@code double} the polar angle to calculate for, in degrees.
*/
@Override
public void calculatePoint(Vector3 result, double theta) {
double angle = mSpiralIn ? mThetaOffset - theta : theta + mThetaOffset;
if (angle == 0.0) angle = 1e-9; //Prevent a divide by zero for negative densities.
final double r = a * Math.pow(angle, mInvDensity);
// Update the rotation
mRotation.fromAngleAxis(mUp, Math.toDegrees(angle));
// Rotate the start-end vector based on the angle
mScratch.setAll(mRotation.multiply(mStart)).normalize();
// Set the correct length
result.setAll(mScratch.multiply(r));
if (mCalculateTangents) {
mCurrentTangent.crossAndSet(mUp, mScratch);
}
}
示例5: mapToSphere
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
private void mapToSphere(final float x, final float y, Vector3 out)
{
float lengthSquared = x * x + y * y;
if (lengthSquared > 1)
{
out.setAll(x, y, 0);
out.normalize();
}
else
{
out.setAll(x, y, Math.sqrt(1 - lengthSquared));
}
}
示例6: intersectRayTriangle
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
/**
* Intersects a ray defined by a start and end point and a triangle.
* @param rayStart Startpoint of the ray
* @param rayEnd Endpoint of the ray
* @param t1 The first vertex of the triangle
* @param t2 The second vertex of the triangle
* @param t3 The third vertex of the triangle
* @param hitPoint The intersection point (optional)
* @return True if there is an intersection, false otherwise.
*/
public static boolean intersectRayTriangle(Vector3 rayStart, Vector3 rayEnd, Vector3 t1, Vector3 t2, Vector3 t3, Vector3 hitPoint) {
Vector3 rayDir = Vector3.subtractAndCreate(rayEnd, rayStart);
rayDir.normalize();
p.set(t1, t2, t3);
if (!intersectRayPlane(rayStart, rayEnd, p, i)) return false;
v0.subtractAndSet(t3, t1);
v1.subtractAndSet(t2, t1);
v2.subtractAndSet(i, t1);
double dot00 = v0.dot(v0);
double dot01 = v0.dot(v1);
double dot02 = v0.dot(v2);
double dot11 = v1.dot(v1);
double dot12 = v1.dot(v2);
double denom = dot00 * dot11 - dot01 * dot01;
if (denom == 0) return false;
double u = (dot11 * dot02 - dot01 * dot12) / denom;
double v = (dot00 * dot12 - dot01 * dot02) / denom;
if (u >= 0 && v >= 0 && u + v <= 1) {
if (hitPoint != null) hitPoint.setAll(i);
return true;
} else
return false;
}
示例7: getTranslation
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
public Vector3 getTranslation(Vector3 vec) {
return vec.setAll(m[M03], m[M13], m[M23]);
}
示例8: calculateNormals
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
public float[] calculateNormals(int[] indices) {
float[] vertices = new float[mGeometry.getVertices().capacity()];
mGeometry.getVertices().get(vertices).position(0);
float[] faceNormals = new float[indices.length];
float[] vertNormals = new float[vertices.length];
int numIndices = indices.length;
int numVertices = vertices.length;
int id1, id2, id3, vid1, vid2, vid3;
Vector3 v1 = new Vector3();
Vector3 v2 = new Vector3();
Vector3 v3 = new Vector3();
Vector3 normal = new Vector3();
// -- calculate face normals
for(int i=0; i<numIndices; i+=3) {
id1 = indices[i];
id2 = indices[i+1];
id3 = indices[i+2];
vid1 = id1 * 3;
vid2 = id2 * 3;
vid3 = id3 * 3;
v1.setAll(vertices[vid1], vertices[vid1+1], vertices[vid1+2]);
v2.setAll(vertices[vid2], vertices[vid2+1], vertices[vid2+2]);
v3.setAll(vertices[vid3], vertices[vid3+1], vertices[vid3+2]);
Vector3 vector1 = Vector3.subtractAndCreate(v2, v1);
Vector3 vector2 = Vector3.subtractAndCreate(v3, v1);
normal = Vector3.crossAndCreate(vector1, vector2);
normal.normalize();
faceNormals[i] = (float) normal.x;
faceNormals[i+1] = (float) normal.y;
faceNormals[i+2] = (float) normal.z;
}
// -- calculate vertex normals
Vector3 vertexNormal = new Vector3();
for(int i=0; i<numVertices; i+=3) {
int vIndex = i / 3;
vertexNormal.setAll(0, 0, 0);
for(int j=0; j<numIndices; j+=3)
{
id1 = indices[j];
id2 = indices[j+1];
id3 = indices[j+2];
if(id1 == vIndex || id2 == vIndex || id3 == vIndex) {
vertexNormal.add(faceNormals[j], faceNormals[j+1], faceNormals[j+2]);
}
}
vertexNormal.normalize();
vertNormals[i] = (float) vertexNormal.x;
vertNormals[i+1] = (float) vertexNormal.y;
vertNormals[i+2] = (float) vertexNormal.z;
}
//mGeometry.setNormals(vertNormals);
faceNormals = null;
v1 = null;
v2 = null;
v3 = null;
return vertNormals;
}
示例9: grow
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
/**
* Grows the tree.
*/
protected void grow() {
RajLog.d("[" + this.getClass().getName() + "] Growing tree: " + this);
Vector3 min = new Vector3(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
Vector3 max = new Vector3(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);
//Get a full list of all the members, including members in the children
ArrayList<IGraphNodeMember> members = getAllMembersRecursively(true);
int members_count = members.size();
for (int i = 0; i < members_count; ++i) {
IBoundingVolume volume = members.get(i).getTransformedBoundingVolume();
Vector3 test_against_min = null;
Vector3 test_against_max = null;
if (volume == null) {
ATransformable3D object = (ATransformable3D) members.get(i);
test_against_min = object.getPosition();
test_against_max = test_against_min;
} else {
if (volume instanceof BoundingBox) {
BoundingBox bb = (BoundingBox) volume;
test_against_min = bb.getTransformedMin();
test_against_max = bb.getTransformedMax();
} else if (volume instanceof BoundingSphere) {
BoundingSphere bs = (BoundingSphere) volume;
Vector3 bs_position = bs.getPosition();
double radius = bs.getScaledRadius();
Vector3 rad = new Vector3();
rad.setAll(radius, radius, radius);
test_against_min = Vector3.subtractAndCreate(bs_position, rad);
test_against_max = Vector3.addAndCreate(bs_position, rad);
} else {
RajLog.e("[" + this.getClass().getName() + "] Received a bounding box of unknown type.");
throw new IllegalArgumentException("Received a bounding box of unknown type.");
}
}
if (test_against_min != null && test_against_max != null) {
if(test_against_min.x < min.x) min.x = test_against_min.x;
if(test_against_min.y < min.y) min.y = test_against_min.y;
if(test_against_min.z < min.z) min.z = test_against_min.z;
if(test_against_max.x > max.x) max.x = test_against_max.x;
if(test_against_max.y > max.y) max.y = test_against_max.y;
if(test_against_max.z > max.z) max.z = test_against_max.z;
}
}
mMin.setAll(min);
mMax.setAll(max);
mTransformedMin.setAll(min);
mTransformedMax.setAll(max);
calculatePoints();
calculateChildSideLengths();
if (mSplit) {
for (int i = 0; i < CHILD_COUNT; ++i) {
((Octree) mChildren[i]).setChildRegion(i, mChildLengths);
}
}
for (int i = 0; i < members_count; ++i) {
internalAddObject(members.get(i));
}
}
示例10: getScaling
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
/**
* Sets the components of the provided {@link Vector3} representing the scaling component
* of this {@link Matrix4}.
*
* @param vec {@link Vector3} to store the result in.
* @return {@link Vector3} representing the scaling.
*/
public Vector3 getScaling(final Vector3 vec) {
final double x = Math.sqrt(m[M00]*m[M00] + m[M01]*m[M01] + m[M02]*m[M02]);
final double y = Math.sqrt(m[M10]*m[M10] + m[M11]*m[M11] + m[M12]*m[M12]);
final double z = Math.sqrt(m[M20]*m[M20] + m[M21]*m[M21] + m[M22]*m[M22]);
return vec.setAll(x, y, z);
}