Skip to content
This repository was archived by the owner on Dec 27, 2024. It is now read-only.

update lib in view Graph #830

Merged
merged 3 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
public class Object3D {
protected float[] vert;
protected float[] normal;
protected int[] index;

protected short[] index;

protected float[] tVert; // the vertices transformed into screen space
protected float mMinX, mMaxX, mMinY, mMaxY, mMinZ, mMaxZ; // bounds in x,y & z
protected int mType = 4;
Expand All @@ -46,7 +48,7 @@ public void makeVert(int n) {
}

public void makeIndexes(int n) {
index = new int[n * 3];
index = new short[n * 3];
}

public void transform(Matrix m) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,19 @@ public void setLookPoint(double[] mLookPoint) {
this.mLookPoint = mLookPoint;
}

/**
* return the distance from the look point to the eye point
* @return
*/
public double calCameraDistance() {
double[] zv = {
mEyePoint[0] - mLookPoint[0],
mEyePoint[1] - mLookPoint[1],
mEyePoint[2] - mLookPoint[2]
};
return VectorUtil.norm(zv);
}

public double[] getEyePoint() {
return mEyePoint;
}
Expand Down Expand Up @@ -271,13 +284,15 @@ public void lookAt(Object3D tri, float[] voxelDim, int w, int h) {
double[] mMoveToV = new double[3];
double[] mStartEyePoint;
double[] mStartUpVector;
double dist = 0;
Quaternion mQ = new Quaternion(0, 0, 0, 0);

public void trackBallUP(float x, float y) {

}

public void trackBallDown(float x, float y) {
dist = calCameraDistance();
mStartx = x;
mStarty = y;
ballToVec(x, y, mStartV);
Expand All @@ -304,7 +319,8 @@ public void trackBallMove(float x, float y) {

mEyePoint = mQ.rotateVec(mEyePoint);
mUpVector = mQ.rotateVec(mStartUpVector);

VectorUtil.normalize(mEyePoint);
VectorUtil.mult(mEyePoint,dist,mEyePoint);
VectorUtil.sub(mLookPoint, mEyePoint, mEyePoint);
calcMatrix();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,19 @@ void buildBox() {
vert[i * 3 + 2] = (((i >> 2) & 1) == 0) ? mMinZ : mMaxZ; // Z
}

index = new int[6 * 2* 3]; // 6 sides x 2 triangles x 3 points per triangle
int []sides = { // pattern of clockwise triangles around cube

index = new short[6 * 2 * 3]; // 6 sides x 2 triangles x 3 points per triangle
short []sides = { // pattern of clockwise triangles around cube
0, 2, 1, 3, 1, 2,
0, 1, 4, 5, 4, 1,
0, 4, 2, 6, 2, 4,
7, 6, 5, 4, 5, 6,
7, 3, 6, 2, 6, 3,
7, 5, 3, 1, 3, 5
};
index = new int[sides.length];
index = new short[sides.length];
for (int i = 0; i < sides.length; i++) {
index[i] = sides[i]*3;
index[i] = (short) (3*sides[i]);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,14 @@ public void calcSurface(float t, boolean resetZ) {
int p2 = 3 * (1 + ix + iy * (mSize + 1));
int p3 = 3 * (ix + (iy + 1) * (mSize + 1));
int p4 = 3 * (1 + ix + (iy + 1) * (mSize + 1));
index[count++] = p1;
index[count++] = p2;
index[count++] = p3;
index[count++] = (short)p1;
index[count++] = (short)p2;
index[count++] = (short)p3;

index[count++] = (short)p4;
index[count++] = (short)p3;
index[count++] = (short)p2;

index[count++] = p4;
index[count++] = p3;
index[count++] = p2;
}
}
}
Expand Down