本文整理汇总了Java中org.rajawali3d.math.vector.Vector3.add方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3.add方法的具体用法?Java Vector3.add怎么用?Java Vector3.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rajawali3d.math.vector.Vector3
的用法示例。
在下文中一共展示了Vector3.add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: p
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
private void p(Vector3 result, double t) {
double u = 1 - t;
double tt = t * t;
double uu = u * u;
double ttt = tt * t;
double uuu = uu * u;
result.scaleAndSet(mPoint1, uuu);
mTempPoint.scaleAndSet(mControlPoint1, 3 * uu * t);
result.add(mTempPoint);
mTempPoint.scaleAndSet(mControlPoint2, 3 * u * tt);
result.add(mTempPoint);
mTempPoint.scaleAndSet(mPoint2, ttt);
result.add(mTempPoint);
}
示例2: buildMeshes
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
private void buildMeshes() {
for (int i = 0; i < mNumMeshes; ++i) {
int boneIndex = 0;
SkeletonMeshData mesh = mMeshes[i];
mesh.vertices = new float[mesh.numVertices * 3];
mesh.indices = new int[mesh.numWeights];
mesh.weights = new float[mesh.numWeights];
mesh.textureCoordinates = new float[mesh.numVertices * 2];
int numVerts = mesh.numVertices;
for (int j = 0; j < numVerts; ++j) {
BoneVertex vert = mesh.boneVertices[j];
Vector3 position = new Vector3();
for (int k = 0; k < vert.numWeights; ++k) {
BoneWeight weight = mesh.boneWeights[vert.weightIndex + k];
SkeletonJoint joint = mJoints[weight.jointIndex];
Vector3 rotPos = joint.getOrientation().multiply(weight.position);
//We don't clone here because nothing will be able to use the quaternion scratch before we do
Vector3 pos = Vector3.addAndCreate(joint.getPosition(), rotPos);
pos.multiply(weight.weightValue);
position.add(pos);
mesh.indices[boneIndex] = weight.jointIndex;
mesh.weights[boneIndex++] = weight.weightValue;
}
int vertIndex = j * 3;
mesh.vertices[vertIndex] = (float) position.x;
mesh.vertices[vertIndex + 1] = (float) position.y;
mesh.vertices[vertIndex + 2] = (float) position.z;
int uvIndex = j * 2;
mesh.textureCoordinates[uvIndex] = (float) vert.textureCoordinate.getX();
mesh.textureCoordinates[uvIndex + 1] = (float) vert.textureCoordinate.getY();
}
}
}
示例3: 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;
}
示例4: readFaces
import org.rajawali3d.math.vector.Vector3; //导入方法依赖的package包/类
protected void readFaces(InputStream buffer) throws IOException {
int triangles = readShort(buffer);
Vector3[] normals = new Vector3[triangles];
ArrayList<Integer> indices = new ArrayList<Integer>();
for (int i = 0; i < triangles; i++) {
int[] vertexIDs = new int[3];
vertexIDs[0] = readShort(buffer);
vertexIDs[1] = readShort(buffer);
vertexIDs[2] = readShort(buffer);
readShort(buffer);
indices.add(vertexIDs[0]);
indices.add(vertexIDs[1]);
indices.add(vertexIDs[2]);
Vector3 normal = calculateFaceNormal(vertexIDs);
normals[i] = normal;
}
mNormals.add(new Vector3[triangles]);
mIndices.add(indices);
int numVertices = mVertices.get(mObjects).size();
int numIndices = indices.size();
ArrayList<Vector3> vertNormals = new ArrayList<Vector3>();
for (int i = 0; i < numVertices; i++) {
Vector3 vertexNormal = new Vector3();
for (int j = 0; j < numIndices; j += 3) {
int id1 = indices.get(j);
int id2 = indices.get(j + 1);
int id3 = indices.get(j + 2);
if (id1 == i || id2 == i || id3 == i) {
vertexNormal.add(normals[j / 3]);
}
}
vertexNormal.normalize();
vertNormals.add(vertexNormal);
}
mVertNormals.add(vertNormals);
}