Discussions
Categories
- 385.5K All Categories
- 4.9K Data
- 2.5K Big Data Appliance
- 2.4K Data Science
- 453.4K Databases
- 223.2K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 47 Multilingual Engine
- 606 MySQL Community Space
- 486 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.2K ORDS, SODA & JSON in the Database
- 585 SQLcl
- 4K SQL Developer Data Modeler
- 188K SQL & PL/SQL
- 21.5K SQL Developer
- 46 Data Integration
- 46 GoldenGate
- 298.4K Development
- 4 Application Development
- 20 Developer Projects
- 166 Programming Languages
- 295K Development Tools
- 150 DevOps
- 3.1K QA/Testing
- 646.7K Java
- 37 Java Learning Subscription
- 37.1K Database Connectivity
- 201 Java Community Process
- 108 Java 25
- 22.2K Java APIs
- 138.3K Java Development Tools
- 165.4K Java EE (Java Enterprise Edition)
- 22 Java Essentials
- 176 Java 8 Questions
- 86K Java Programming
- 82 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 208 Java User Groups
- 25 JavaScript - Nashorn
- Programs
- 667 LiveLabs
- 41 Workshops
- 10.3K Software
- 6.7K Berkeley DB Family
- 3.6K JHeadstart
- 6K Other Languages
- 2.3K Chinese
- 207 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 474 Portuguese
Moving view point
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:
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(); scene.compile(); SimpleUniverse simpleU = new SimpleUniverse(canvas3D); simpleU.getViewingPlatform().setNominalViewingTransform(); simpleU.addBranchGraph(scene); } 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(); rotate.rotX(Math.PI/20.0d); tempRotate.rotY(Math.PI/6.0d); rotate.mul(tempRotate); 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); cc.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); cc.setCapability(Shape3D.ALLOW_GEOMETRY_READ); cg.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); cg.setCapability(Shape3D.ALLOW_GEOMETRY_READ); 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)); objRotate.addChild(ax1); objRotate.addChild(ax2); objRotate.addChild(ax3); objRotate.addChild(cc); objRotate.addChild(cg); uBehavior = new UpdateBehavior(cc,cg); uBehavior.setSchedulingBounds(new BoundingSphere()); objRoot.addChild(objRotate); objRoot.addChild(uBehavior); return objRoot; } public Canvas3D getCanvas3D() { return canvas3D; } public void updatePoints(Point3d[] p) { points = p; uBehavior.setNewPoints(points); } }
Comments
-
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.Are there any experienced java3d users here to answer our pathetic questions.Warning the above information may be complete crap<< -
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(); viewTransform.getTransform(currentTransform); currentTransform.mul(addTransform); viewTransform.setTransform(currentTransform);
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. -
See my comments under the "setting the view" topic.
This discussion has been closed.