本文整理汇总了Java中processing.core.PMatrix3D类的典型用法代码示例。如果您正苦于以下问题:Java PMatrix3D类的具体用法?Java PMatrix3D怎么用?Java PMatrix3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PMatrix3D类属于processing.core包,在下文中一共展示了PMatrix3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scaleMat
import processing.core.PMatrix3D; //导入依赖的package包/类
/**
* Multiply each element of a PMatrix3D by the scale. mat.m00 *= scale and
* so on...
*
* @param mat
* @param scale
*/
public static void scaleMat(PMatrix3D mat, float scale) {
mat.m00 *= scale;
mat.m01 *= scale;
mat.m02 *= scale;
mat.m03 *= scale;
mat.m10 *= scale;
mat.m11 *= scale;
mat.m12 *= scale;
mat.m13 *= scale;
mat.m20 *= scale;
mat.m21 *= scale;
mat.m22 *= scale;
mat.m23 *= scale;
mat.m30 *= scale;
mat.m31 *= scale;
mat.m32 *= scale;
mat.m33 *= scale;
}
示例2: getBuffer
import processing.core.PMatrix3D; //导入依赖的package包/类
public void getBuffer(float[] matv, PMatrix3D mat, boolean use3x3){
if (use3x3) {
matv[0]=mat.m00; matv[1]=mat.m01; matv[2]=mat.m02;
matv[3]=mat.m10; matv[4]=mat.m11; matv[5]=mat.m12;
matv[6]=mat.m20; matv[7]=mat.m21; matv[8]=mat.m22;
} else {
matv[ 0]=mat.m00; matv[ 1]=mat.m01; matv[ 2]=mat.m02; matv[ 3]=mat.m03;
matv[ 4]=mat.m10; matv[ 5]=mat.m11; matv[ 6]=mat.m12; matv[ 7]=mat.m13;
matv[ 8]=mat.m20; matv[ 9]=mat.m21; matv[10]=mat.m22; matv[11]=mat.m23;
matv[12]=mat.m30; matv[13]=mat.m31; matv[14]=mat.m32; matv[15]=mat.m33;
}
// if (use3x3) {
// matv[0]=mat.m00; matv[1]=mat.m10; matv[2]=mat.m20;
// matv[3]=mat.m01; matv[4]=mat.m11; matv[5]=mat.m21;
// matv[6]=mat.m02; matv[7]=mat.m12; matv[8]=mat.m22;
// } else {
// matv[ 0]=mat.m00; matv[ 1]=mat.m10; matv[ 2]=mat.m20; matv[ 3]=mat.m30;
// matv[ 4]=mat.m01; matv[ 5]=mat.m11; matv[ 6]=mat.m21; matv[ 7]=mat.m31;
// matv[ 8]=mat.m02; matv[ 9]=mat.m12; matv[10]=mat.m22; matv[11]=mat.m32;
// matv[12]=mat.m03; matv[13]=mat.m13; matv[14]=mat.m23; matv[15]=mat.m33;
// }
}
示例3: getProjection
import processing.core.PMatrix3D; //导入依赖的package包/类
public PMatrix3D getProjection(){
pg_shadowmap.updateProjmodelview();
// 1) create shadowmap matrix,
// to transform positions from camera-space to the shadowmap-space (light-space)
PMatrix3D mat_shadow = new PMatrix3D();
// ndc (shadowmap) -> normalized (shadowmap)
// [-1,+1] -> [0,1]
mat_shadow.scale(0.5f);
mat_shadow.translate(1,1,1);
// model (world) -> modelview (shadowmap) -> ndc (shadowmap)
mat_shadow.apply(pg_shadowmap.projection);
return mat_shadow;
}
示例4: setXmlTo
import processing.core.PMatrix3D; //导入依赖的package包/类
private void setXmlTo(XML xml, PMatrix3D matrix) {
xml.setFloat("m00", matrix.m00);
xml.setFloat("m01", matrix.m01);
xml.setFloat("m02", matrix.m02);
xml.setFloat("m03", matrix.m03);
xml.setFloat("m10", matrix.m10);
xml.setFloat("m11", matrix.m11);
xml.setFloat("m12", matrix.m12);
xml.setFloat("m13", matrix.m13);
xml.setFloat("m20", matrix.m20);
xml.setFloat("m21", matrix.m21);
xml.setFloat("m22", matrix.m22);
xml.setFloat("m23", matrix.m23);
xml.setFloat("m30", matrix.m30);
xml.setFloat("m31", matrix.m31);
xml.setFloat("m32", matrix.m32);
xml.setFloat("m33", matrix.m33);
}
示例5: getMatFrom
import processing.core.PMatrix3D; //导入依赖的package包/类
private void getMatFrom(XML node, PMatrix3D matrix) {
matrix.m00 = node.getFloat("m00");
matrix.m01 = node.getFloat("m01");
matrix.m02 = node.getFloat("m02");
matrix.m03 = node.getFloat("m03");
matrix.m10 = node.getFloat("m10");
matrix.m11 = node.getFloat("m11");
matrix.m12 = node.getFloat("m12");
matrix.m13 = node.getFloat("m13");
matrix.m20 = node.getFloat("m20");
matrix.m21 = node.getFloat("m21");
matrix.m22 = node.getFloat("m22");
matrix.m23 = node.getFloat("m23");
matrix.m30 = node.getFloat("m30");
matrix.m31 = node.getFloat("m31");
matrix.m32 = node.getFloat("m32");
matrix.m33 = node.getFloat("m33");
}
示例6: goTo
import processing.core.PMatrix3D; //导入依赖的package包/类
/**
* *
* Works only in 3D mode with beginDraw3D().
*
* @param paperScreen PaperScreen to go to.
*/
public void goTo(PaperScreen paperScreen) {
if (this.isDrawingOnScreen == true) {
throw new RuntimeException("Impossible to draw on another board. You need to draw using beginDraw3D() to do so.");
}
// if (this.currentGraphics != graphics) {
// throw new RuntimeException("The given graphics context is not valid. Use the one given by beginDraw3D().");
// }
// get the location of this board...
PMatrix3D loc = this.getLocation().get();
loc.invert();
loc.apply(paperScreen.getLocation());
applyMatrix(loc);
}
示例7: calibrateProjectorDepthCam
import processing.core.PMatrix3D; //导入依赖的package包/类
protected void calibrateProjectorDepthCam(ArrayList<CalibrationSnapshot> snapshots) {
PMatrix3D kinectExtr = depthCameraDevice.getStereoCalibration().get();
kinectExtr.invert();
PlaneCalibration planeCalibCam = computeAveragePlaneCam(snapshots);
planeCalibCam.flipNormal();
// identity - no external camera for ProCam calibration
PMatrix3D kinectCameraExtrinsics = new PMatrix3D();
// Depth -> Color calibration.
kinectCameraExtrinsics.set(kinectExtr);
HomographyCalibration homography = CalibrationExtrinsic.computeScreenPaperIntersection(projector, planeCalibCam, kinectCameraExtrinsics);
if (homography == HomographyCalibration.INVALID) {
System.err.println("No intersection");
return;
}
// TODO: not sure here... ?
movePlaneAlongOffset(planeCalibCam);
saveKinectPlaneCalibration(planeCalibCam, homography);
saveKinectCameraExtrinsics(kinectCameraExtrinsics);
}
示例8: calibrateDepthToExternalExtr
import processing.core.PMatrix3D; //导入依赖的package包/类
protected void calibrateDepthToExternalExtr(ArrayList<CalibrationSnapshot> snapshots) {
// Depth -> color extrinsics
PMatrix3D kinectExtr = depthCameraDevice.getStereoCalibration().get();
// color -> depth extrinsics
kinectExtr.invert();
// depth -> tracking
PMatrix3D kinectCameraExtr = computeKinectCamExtrinsics(snapshots, kinectExtr);
// // tracking -> depth
kinectCameraExtr.invert();
this.kinectCameraExtrinsics.set(kinectCameraExtr);
saveKinectCameraExtrinsics(kinectCameraExtr);
}
示例9: addPMatrix3D
import processing.core.PMatrix3D; //导入依赖的package包/类
/**
* Add two matrices, src += toAdd
*
* @param src
* @param toAdd
*/
public static void addPMatrix3D(PMatrix3D src, PMatrix3D toAdd) {
src.m00 += toAdd.m00;
src.m01 += toAdd.m01;
src.m02 += toAdd.m02;
src.m03 += toAdd.m03;
src.m10 += toAdd.m10;
src.m11 += toAdd.m11;
src.m12 += toAdd.m12;
src.m13 += toAdd.m13;
src.m20 += toAdd.m20;
src.m21 += toAdd.m21;
src.m22 += toAdd.m22;
src.m23 += toAdd.m23;
src.m30 += toAdd.m30;
src.m31 += toAdd.m31;
src.m32 += toAdd.m32;
src.m33 += toAdd.m33;
}
示例10: loadFrom
import processing.core.PMatrix3D; //导入依赖的package包/类
@Override
public void loadFrom(PApplet parent, String fileName) {
XML root = parent.loadXML(fileName);
XML homographyNode = root.getChild(HOMOGRAPHY_XML_NAME);
pmatrix = new PMatrix3D();
pmatrix.m00 = homographyNode.getFloat("m00");
pmatrix.m01 = homographyNode.getFloat("m01");
pmatrix.m02 = homographyNode.getFloat("m02");
pmatrix.m03 = homographyNode.getFloat("m03");
pmatrix.m10 = homographyNode.getFloat("m10");
pmatrix.m11 = homographyNode.getFloat("m11");
pmatrix.m12 = homographyNode.getFloat("m12");
pmatrix.m13 = homographyNode.getFloat("m13");
pmatrix.m20 = homographyNode.getFloat("m20");
pmatrix.m21 = homographyNode.getFloat("m21");
pmatrix.m22 = homographyNode.getFloat("m22");
pmatrix.m23 = homographyNode.getFloat("m23");
pmatrix.m30 = homographyNode.getFloat("m30");
pmatrix.m31 = homographyNode.getFloat("m31");
pmatrix.m32 = homographyNode.getFloat("m32");
pmatrix.m33 = homographyNode.getFloat("m33");
initMat();
}
示例11: CreatePlaneCalibrationFrom
import processing.core.PMatrix3D; //导入依赖的package包/类
/**
* Get a plane from a 3D matrix.
* Here the size is not that important, might be removed.
* @param mat
* @param size
* @return
*/
public static PlaneCalibration CreatePlaneCalibrationFrom(PMatrix3D mat, PVector size) {
PMatrix3D matrix = mat.get();
PlaneCreator planeCreator = new PlaneCreator();
planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23));
matrix.translate(size.x, 0, 0);
planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23));
matrix.translate(0, size.y, 0);
planeCreator.addPoint(new Vec3D(matrix.m03, matrix.m13, matrix.m23));
planeCreator.setHeight(DEFAULT_PLANE_HEIGHT);
assert (planeCreator.isComputed());
PlaneCalibration planeCalibration = planeCreator.getPlaneCalibration();
planeCalibration.flipNormal();
// planeCalibration.moveAlongNormal(DEFAULT_PLANE_SHIFT);
assert (planeCalibration.isValid());
return planeCalibration;
}
示例12: savePMatrix3D
import processing.core.PMatrix3D; //导入依赖的package包/类
/**
* Save a PMatrix3D to a file. Really simple file format, using saveStrings.
*
* @param pa
* @param mat
* @param filename
*/
public static void savePMatrix3D(PApplet pa, PMatrix3D mat, String filename) {
String[] lines = new String[16];
lines[0] = Float.toString(mat.m00);
lines[1] = Float.toString(mat.m01);
lines[2] = Float.toString(mat.m02);
lines[3] = Float.toString(mat.m03);
lines[4] = Float.toString(mat.m10);
lines[5] = Float.toString(mat.m11);
lines[6] = Float.toString(mat.m12);
lines[7] = Float.toString(mat.m13);
lines[8] = Float.toString(mat.m20);
lines[9] = Float.toString(mat.m21);
lines[10] = Float.toString(mat.m22);
lines[11] = Float.toString(mat.m23);
lines[12] = Float.toString(mat.m30);
lines[13] = Float.toString(mat.m31);
lines[14] = Float.toString(mat.m32);
lines[15] = Float.toString(mat.m33);
pa.saveStrings(filename, lines);
}
示例13: addMatrices
import processing.core.PMatrix3D; //导入依赖的package包/类
public static void addMatrices(PMatrix3D sum, PMatrix3D addedElement) {
sum.m00 += addedElement.m00;
sum.m01 += addedElement.m01;
sum.m02 += addedElement.m02;
sum.m03 += addedElement.m03;
sum.m10 += addedElement.m10;
sum.m11 += addedElement.m11;
sum.m12 += addedElement.m12;
sum.m13 += addedElement.m13;
sum.m20 += addedElement.m20;
sum.m21 += addedElement.m21;
sum.m22 += addedElement.m22;
sum.m23 += addedElement.m23;
sum.m30 += addedElement.m30;
sum.m31 += addedElement.m31;
sum.m32 += addedElement.m32;
sum.m33 += addedElement.m33;
}
示例14: getCoordFrom
import processing.core.PMatrix3D; //导入依赖的package包/类
public PVector getCoordFrom(PaperScreen paperScreen, PVector point) {
// get a copy
PMatrix3D thisLocationInv = this.getLocation().get();
thisLocationInv.invert();
PMatrix3D otherLocation = paperScreen.getLocation();
PVector cameraViewOfPoint = new PVector();
otherLocation.mult(point, cameraViewOfPoint);
PVector thisViewOfPoint = new PVector();
thisLocationInv.mult(cameraViewOfPoint, thisViewOfPoint);
if (Float.isNaN(thisViewOfPoint.x)) {
return INVALID_VECTOR;
}
return thisViewOfPoint;
}
示例15: computeScreenPosTransform
import processing.core.PMatrix3D; //导入依赖的package包/类
public void computeScreenPosTransform(Camera camera) {
///////////////////// PLANE COMPUTATION //////////////////
PMatrix3D mat = this.getLocation(camera);
paperPosCorners3D[0] = new PVector(mat.m03, mat.m13, mat.m23);
mat.translate(size.x, 0, 0);
paperPosCorners3D[1] = new PVector(mat.m03, mat.m13, mat.m23);
mat.translate(0, size.y, 0);
paperPosCorners3D[2] = new PVector(mat.m03, mat.m13, mat.m23);
mat.translate(-size.x, 0, 0);
paperPosCorners3D[3] = new PVector(mat.m03, mat.m13, mat.m23);
plane = new Plane(new Triangle3D(MathUtils.toVec(paperPosCorners3D[0]), MathUtils.toVec(paperPosCorners3D[1]), MathUtils.toVec(paperPosCorners3D[2])));
homography.addPoint(paperPosCorners3D[0], new PVector(0, 0));
homography.addPoint(paperPosCorners3D[1], new PVector(1, 0));
homography.addPoint(paperPosCorners3D[2], new PVector(1, 1));
homography.addPoint(paperPosCorners3D[3], new PVector(0, 1));
worldToScreen = homography.getHomography();
}