for(int i=0;i<24;i++)normals[i]=new Vector3f(); Point3f [] pts=new Point3f[24]; for(int i=0;i<24;i++)pts[i]=new Point3f(); light1.setInfluencingBounds(new BoundingSphere(new Point3d(-5.0,0,0),10.0)); light1.setColor(new Color3f(1f,1f,1f)); light1.setDirection(new Vector3f(0,1,0)); objRotate.addChild(light1); DirectionalLight light2=new DirectionalLight(); light2.setInfluencingBounds(new BoundingSphere(new Point3d(5.0,0,0),10.0)); light2.setColor(new Color3f(0.5f,1f,0.5f)); light2.setDirection(new Vector3f(0,-1,0)); objRotate.addChild(light2); MouseRotate f1=new MouseRotate();
Appearance app = new Appearance(); Vector3f [] normals=new Vector3f[24]; for(int i=0;i<24;i++)normals[i]=new Vector3f(); Point3f [] pts=new Point3f[24]; for(int i=0;i<24;i++)pts[i]=new Point3f(); light1.setInfluencingBounds(new BoundingSphere(new Point3d(-5.0,0,0),10.0)); light1.setColor(new Color3f(1f,1f,1f)); light1.setDirection(new Vector3f(0,1,0)); objRotate.addChild(light1); DirectionalLight light2=new DirectionalLight(); light2.setInfluencingBounds(new BoundingSphere(new Point3d(5.0,0,0),10.0)); light2.setColor(new Color3f(0.5f,1f,0.5f)); light2.setDirection(new Vector3f(0,-1,0)); objRotate.addChild(light2); MouseRotate f1=new MouseRotate();
// Simple vector class, created by you. Vector3f vector1 = new Vector3f(); Vector3f vector2 = new Vector3f(); vector1.x = vertices[0] - vertices[3]; vector1.y = vertices[1] - vertices[4]; vector1.z = vertices[2] - vertices[5]; vector2.x = vertices[3] - vertices[6]; vector2.y = vertices[4] - vertices[7]; vector2.z = vertices[5] - vertices[8];
public Vector3f crossProduct(Vector3f vector1, Vector3f vector2) { Vector3f normalVector = new Vector3f(); // Cross product. The normalVector contains the normal for the // surface, which is perpendicular both to vector1 and vector2. normalVector.x = vector1.y * vector2.z - vector1.z * vector2.y; normalVector.y = vector1.z * vector2.x - vector1.x * vector2.z; normalVector.z = vector1.x * vector2.y - vector1.y * vector2.x; return normalVector; }
@Override public void applyTranslations(int uniformLocation) { viewMatrix = new Matrix4f(); Matrix4f.rotate(MatrixUtils.degreesToRadians(pitch), new Vector3f(1, 0, 0), viewMatrix, viewMatrix); Matrix4f.rotate(MatrixUtils.degreesToRadians(yaw), new Vector3f(0, 1, 0), viewMatrix, viewMatrix); Matrix4f.rotate(MatrixUtils.degreesToRadians(roll), new Vector3f(0, 0, 1), viewMatrix, viewMatrix); Matrix4f.translate(new Vector3f(-x, -y, -z), viewMatrix, viewMatrix); viewMatrix.store(matrix44Buffer); matrix44Buffer.flip(); glUniformMatrix4(uniformLocation, false, matrix44Buffer); }
for (int i = 0; i < vertexData.length / vertexDataSize; i++){ int index = Integer.parseInt(allindices2[i * source.size()]); float x = Float.parseFloat(allpositions2[index * 3 + 0]); float y = Float.parseFloat(allpositions2[index * 3 + 1]); float z = Float.parseFloat(allpositions2[index * 3 + 2]); vertices.add(new Vector3f(x,y,z)); }
/** * Sets this light's direction from the three values provided. * @param x the new x direction * @param y the new y direction * @param z the new z direction */ void setDirection(float x, float y, float z) { setDirection(new Vector3f(x, y, z)); }
/** * Sets this light's direction from the three values provided. * @param x the new x direction * @param y the new y direction * @param z the new z direction */ void setDirection(float x, float y, float z) { setDirection(new Vector3f(x, y, z)); }
protected CollisionShape getShape() { //TODO: cleanup size mess.. CapsuleCollisionShape capsuleCollisionShape = new CapsuleCollisionShape(getFinalRadius(), (getFinalHeight() - (2 * getFinalRadius()))); CompoundCollisionShape compoundCollisionShape = new CompoundCollisionShape(); //Vector3f addLocation = new Vector3f(0, (getFinalHeight() / 2.0f), 0); REMOVED LINE Vector3f addLocation = new Vector3f(0, 0, 0); //NEW LINE compoundCollisionShape.addChildShape(capsuleCollisionShape, addLocation); return compoundCollisionShape; }
@Override void setLive(SetLiveState s) { super.doSetLive(s); J3dMessage createMessage = super.initMessage(12); Object[] objs = (Object[])createMessage.args[4]; objs[9] = new Float(spreadAngle); objs[10] = new Float(concentration) ; objs[11] = new Vector3f(direction); VirtualUniverse.mc.processMessage(createMessage); }
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 void applyTranslation(final float dx, final float dy, final float dz) { final Transform3D t = new Transform3D(); t.setTranslation(new Vector3f(dx, dy, dz)); applyTransform(t); }
public void setCenter(final Point3f center) { this.center.set(center); final Vector3f translateV = new Vector3f(center); translate.set(translateV); translateTG.setTransform(translate); }
Vector3f toScreenVector = new Vector3f(0, 0, 1); Transform3D t3d = new Transform3D(); canvas.getImagePlateToVworld(t3d); t3d.transform(toScreenVector); tg.getTransform(t3d); //tg is Transform Group of all objects in a scene t3d.transform(toScreenVector);
@Override public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); out.writeInt( ((Billboard)node).getAlignmentMode() ); Vector3f vec = new Vector3f(); ((Billboard)node).getAlignmentAxis( vec ); Point3f point = new Point3f(); ((Billboard)node).getRotationPoint( point ); control.writeVector3f( out, vec ); control.writePoint3f( out, point ); out.writeInt( target ); }
@Override public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); out.writeInt( ((OrientedShape3D)node).getAlignmentMode() ); Vector3f vec = new Vector3f(); ((OrientedShape3D)node).getAlignmentAxis( vec ); Point3f point = new Point3f(); ((OrientedShape3D)node).getRotationPoint( point ); control.writeVector3f( out, vec ); control.writePoint3f( out, point ); out.writeBoolean( ((OrientedShape3D)node).getConstantScaleEnable() ); out.writeDouble( ((OrientedShape3D)node).getScale() ); }
PlatformGeometry pg = new PlatformGeometry(); TransformGroup objScale = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3f(0f, 0f, -1f)); objScale.setTransform(t3d); Text2D text = new Text2D("Text to display", Cell.BLACK, "Verdana", 18, 1); objScale.addChild(text); pg.addChild(objScale); simpleUniverse.getViewingPlatform().setPlatformGeometry(pg);
public void setLength(final float l) { this.length = l; lineShape.setGeometry(createLineGeometry()); textShape.setGeometry(createTextGeometry()); final Transform3D d = new Transform3D(); d.setTranslation(new Vector3f(length / 2, -length / 2, 0.0f)); textTG.setTransform(d); }