Vector3f vector3 = new Vector3f(x,y,z); Vector4f vector4 = new Vector4f((Tuple3f)vector3);
public Vector4f readVector4f( DataInput in ) throws IOException { return (Vector4f)readTuple4f( in, new Vector4f() ); }
Vector4f vpos = new Vector4f(0, 0, 0, 1); // (0,0,0,1) because it's relative to the cam float mv[]=new float[16]; ByteBuffer temp = ByteBuffer.allocateDirect(64); temp.order(ByteOrder.nativeOrder()); GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, (FloatBuffer)temp.asFloatBuffer()); temp.asFloatBuffer().get(mv); Matrix4f m4 = new Matrix4f(); m4.load((FloatBuffer)temp.asFloatBuffer()); m4.invert(); vpos = Matrix4f.transform(m4, vpos, vpos);
/** * Sets the R coordinate plane equation. This plane equation * is used to generate the R coordinate in OBJECT_LINEAR and EYE_LINEAR * texture generation modes. * @param planeR plane equation for the R coordinate */ final void setPlaneR(Vector4f planeR) { initPlaneR(planeR); sendMessage(PLANE_R_CHANGED, new Vector4f(planeR)); }
/** * Sets the S coordinate plane equation. This plane equation * is used to generate the S coordinate in OBJECT_LINEAR and EYE_LINEAR * texture generation modes. * @param planeS plane equation for the S coordinate */ final void setPlaneS(Vector4f planeS) { initPlaneS(planeS); sendMessage(PLANE_S_CHANGED, new Vector4f(planeS)); }
/** * Sets the T coordinate plane equation. This plane equation * is used to generate the T coordinate in OBJECT_LINEAR and EYE_LINEAR * texture generation modes. * @param planeT plane equation for the T coordinate */ final void setPlaneT(Vector4f planeT) { initPlaneT(planeT); sendMessage(PLANE_T_CHANGED, new Vector4f(planeT)); }
/** * Sets the Q coordinate plane equation. This plane equation * is used to generate the Q coordinate in OBJECT_LINEAR and EYE_LINEAR * texture generation modes. * @param planeQ plane equation for the Q coordinate */ final void setPlaneQ(Vector4f planeQ) { initPlaneQ(planeQ); sendMessage(PLANE_Q_CHANGED, new Vector4f(planeQ)); }
float rotY = (float) Math.toRadians(180); Matrix4f transMat = new Matrix4f(); transMat.rotate(rotY, new Vector3f(0.0f, 1.0f, 0.0f)); Vector4f vecPosMod = new Vector4f(1.0f, 0.0f, 0.0f, 1.0f); Matrix4f.transform(transMat, vecPosMod, vecPosMod);
public CubeData(final Cube c) { this.cube = c; readCalibration(c.dir + c.name + ".info", cal); min[0] = c.x * c.octree.pw; min[1] = c.y * c.octree.ph; min[2] = c.z * c.octree.pd; max[0] = min[0] + SIZE * cal[0]; max[1] = min[1] + SIZE * cal[1]; max[2] = min[2] + SIZE * cal[2]; final float xTexGenScale = (float) (1.0 / (cal[0] * SIZE)); final float yTexGenScale = (float) (1.0 / (cal[1] * SIZE)); final float zTexGenScale = (float) (1.0 / (cal[2] * SIZE)); tgz = new TexCoordGeneration(); tgz.setPlaneS(new Vector4f(xTexGenScale, 0f, 0f, -(xTexGenScale * min[0]))); tgz.setPlaneT(new Vector4f(0f, yTexGenScale, 0f, -(yTexGenScale * min[1]))); tgx = new TexCoordGeneration(); tgx.setPlaneS(new Vector4f(0f, yTexGenScale, 0f, -(yTexGenScale * min[1]))); tgx.setPlaneT(new Vector4f(0f, 0f, zTexGenScale, -(zTexGenScale * min[2]))); tgy = new TexCoordGeneration(); tgy.setPlaneS(new Vector4f(xTexGenScale, 0f, 0f, -(xTexGenScale * min[0]))); tgy.setPlaneT(new Vector4f(0f, 0f, zTexGenScale, -(zTexGenScale * min[2]))); shapes = new ShapeGroup[SIZE]; for (int i = 0; i < SIZE; i++) shapes[i] = new ShapeGroup(); images = new BufferedImage[SIZE]; }
this.volume = v; zTg = new TexCoordGeneration(); zTg.setPlaneS(new Vector4f(v.xTexGenScale, 0f, 0f, zTg.setPlaneT(new Vector4f(0f, v.yTexGenScale, 0f, (float) (0.5f * v.ph * v.yTexGenScale) - (float) (v.yTexGenScale * v.minCoord.y))); yTg = new TexCoordGeneration(); yTg.setPlaneS(new Vector4f(v.xTexGenScale, 0f, 0f, (float) (0.5f * v.pw * v.xTexGenScale) - (float) (v.xTexGenScale * v.minCoord.x))); yTg.setPlaneT(new Vector4f(0f, 0f, v.zTexGenScale, (float) (0.5f * v.pd * v.zTexGenScale) - (float) (v.zTexGenScale * v.minCoord.z))); xTg = new TexCoordGeneration(); xTg.setPlaneS(new Vector4f(0f, v.yTexGenScale, 0f, (float) (0.5f * v.ph * v.yTexGenScale) - (float) (v.yTexGenScale * v.minCoord.y))); xTg.setPlaneT(new Vector4f(0f, 0f, v.zTexGenScale, (float) (0.5f * v.pd * v.zTexGenScale) - (float) (v.zTexGenScale * v.minCoord.z)));
private TexCoordGeneration generateTexCoord(Shape3D shape) { BoundingBox bb = new BoundingBox(shape.getBounds()); Point3d lower = new Point3d(); Point3d upper = new Point3d(); bb.getLower(lower); bb.getUpper(upper); double width = upper.x - lower.x; double height = upper.y - lower.y; double deep = upper.z - lower.z; Vector4f planeX = new Vector4f((float)(1.0/width), 0.0f, 0.0f, (float)(-lower.x/width)); Vector4f planeY = new Vector4f(0.0f, (float)(1.0/height), 0.0f, (float)(-lower.y/height)); Vector4f planeZ = new Vector4f(0.0f, 0.0f, (float)(1.0/deep), (float)(-lower.z/deep)); TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, TexCoordGeneration.TEXTURE_COORDINATE_2); if(width == 0) { // RIGHT, LEFT: YZ tcg.setPlaneS(planeZ); tcg.setPlaneT(planeY); } else if(height == 0) { // TOP, BOTTOM: XZ tcg.setPlaneS(planeX); tcg.setPlaneT(planeZ); } else { // FRONT, BACK: XY tcg.setPlaneS(planeX); tcg.setPlaneT(planeY); } return tcg; }
// Given xAxis and zAxis. Vector3f xAxis = new Vector3f(1, 0, 0); Vector3f zAxis = new Vector3f(0, 0, 1); // Create yAxis. Vector3f yAxis = new Vector3f(); yAxis.cross(zAxis, xAxis); // Create rotation matrix from axes. Matrix4f rotationMatrix = new Matrix4f(); rotationMatrix.setRow(0, new Vector4f(xAxis)); rotationMatrix.setRow(1, new Vector4f(yAxis)); rotationMatrix.setRow(2, new Vector4f(zAxis)); rotationMatrix.setRow(3, new Vector4f(0, 0, 0, 1)); // Create transform. Transform3D transform = new Transform3D(rotationMatrix); // Transform points. Vector3f vector = new Vector3f(0, 1, 0); transform.transform(vector); System.out.println(vector);
@Override public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); TexCoordGeneration attr = (TexCoordGeneration)node; Vector4f vec = new Vector4f(); out.writeBoolean( attr.getEnable() ); out.writeInt( attr.getFormat() ); out.writeInt( attr.getGenMode() ); attr.getPlaneR( vec ); control.writeVector4f( out, vec ); attr.getPlaneS( vec ); control.writeVector4f( out, vec ); attr.getPlaneT( vec ); control.writeVector4f( out, vec ); attr.getPlaneQ( vec ); control.writeVector4f( out, vec ); }
Vector4f vertex = new Vector4f(0, 1, 0, 1);
TexCoordGenerationRetained rt = (TexCoordGenerationRetained) retained; Vector4f v = new Vector4f();