This site is currently read-only as we are migrating to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 31st, when you will be able to use this site as normal.

    Forum Stats

  • 3,890,899 Users
  • 2,269,649 Discussions


Moving view point

843799 Member Posts: 49,999
edited Dec 14, 2001 10:55PM in Java 3D
I'm developing a simple application which displays a set of x,y,z axes where the x axis is a line from (0,0,0) to (1,0,0), the y axis is a line from (0,0,0) to (0,1,0) and the z axis is a line from (0,0,0) to (0,0,1).
When I draw this on the Canvas, it only draw in the top right quarter (because 0,0 is the middle of the canvas)
How can I move my view position so that 0,0 will be the bottom left corner of the canvas?

The code so far is:
public class Graph3D {

	private Canvas3D canvas3D;
	private Point3d[] points = new Point3d[4];
	private UpdateBehavior uBehavior;
	private CubicCurve3D cc;
	private CurveGuides cg;

	public Graph3D(Point3d[] p){

		points = p;

		GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
		canvas3D = new Canvas3D(config);

		BranchGroup scene = createSceneGraph();

		SimpleUniverse simpleU = new SimpleUniverse(canvas3D);



	public BranchGroup createSceneGraph() {
		// Create the root of the branch group
		BranchGroup objRoot = new BranchGroup();

		// rotate object has composite transformation matrix
		Transform3D rotate = new Transform3D();
		Transform3D tempRotate = new Transform3D();


		TransformGroup objRotate = new TransformGroup(rotate);

		cc = new CubicCurve3D(points[0],points[1],points[2],points[3]);
		Point3d[] ps = {points[0],points[1],points[2],points[3]};
		cg = new CurveGuides(ps);



		Line3D ax1 = new Line3D(new Point3d(0,0,0), new Point3d(1,0,0));
		Line3D ax2 = new Line3D(new Point3d(0,0,0), new Point3d(0,1,0));
		Line3D ax3 = new Line3D(new Point3d(0,0,0), new Point3d(0,0,1));


		uBehavior = new UpdateBehavior(cc,cg);
		uBehavior.setSchedulingBounds(new BoundingSphere());


		return objRoot;

	public Canvas3D getCanvas3D() {
		return canvas3D;

	public void updatePoints(Point3d[] p)
		points = p;


  • 843799
    843799 Member Posts: 49,999
    There are two options, move the graph which is altering the world view, but a better option would be to move the view of the scene, which becomes very abstract the moment that you start using SimpleUniverse, and i am having difficulty with this myself.

    I am trying to get collision detection working, so when you hit a wall, you don't go through it. I can not find any example java3d code of this anywhere, but what i have found out is that you need to alter the TransformGroup above the ViewPlatform. There is something called a getMultiTransformGroup() which stores all of your transforms performed above viewplatform and merges them all into one. How you go about adding to getMultiTransformGroup object you might ask, well i haven't found that out yet.
    Warning the above information may be complete crap<<
    Are there any experienced java3d users here to answer our pathetic questions.
  • 843799
    843799 Member Posts: 49,999
    If i've got this correct, the view is set via a transform group before the view object. Something like:
    viewTransform = simpleU.getViewingPlatform().getViewPlatformTransform();
    Transform3D currentTransform = new Transform3D();
    Basically you get the transform group, copy the transform into another transform group, alter this and copy it back. I think if you want to just set the view to a particular view you can skip the retrival and just set the viewing transform straight away. And if you're using multiple view transforms its probably best to merge them into one before setting that as the view then you only ever have one view transform.
  • 843799
    843799 Member Posts: 49,999
    See my comments under the "setting the view" topic.
This discussion has been closed.