[quote]. Firstly, you’ll have to determine if your driver supports it. Run PackageInfo/QueryProperties.java that comes along with the Java3D demo bundle and see if sceneAntialiasingNumPasses has a value > 0. If it is 0, and if you’re running DirectX version then try updating the driver.
If it is > 0, then make sure you’ve also passed in an appropriate “Template” -> GraphicsConfiguration -> Canvas3D like so:
[/quote]
Thank you, I’ll try that out and get back to you.
[quote]Look at View#setFieldOfView(…)
[/quote]
I’m afraid I’m using parallel projection mode, so this has no effect. Screen scale doesn’t seem to do the job either, or modifying the Screen3D’s physical width and physical height.
Perhaps it would be better if you saw the code. The important bits are down toward the end, in the Viewer class and camera() method.
import java.awt.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
public class Engine {
SimpleUniverse universe;
BranchGroup master;
Viewer viewer;
Engine() {
stage();
lights();
camera();
action();
}
void stage() {
viewer = new Viewer();
universe = new SimpleUniverse(viewer);
master = new BranchGroup();
master.setCapability(Group.ALLOW_CHILDREN_EXTEND);
master.setCapability(Group.ALLOW_CHILDREN_READ);
master.setCapability(Group.ALLOW_CHILDREN_WRITE);
}
void lights() {
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 1000.0); // Create a bounds for the light source influence
AmbientLight ambient = new AmbientLight(true, new Color3f(1, 1, 1));
ambient.setInfluencingBounds(bounds);
master.addChild(ambient);
Vector3f direction = new Vector3f(0.35f, -0.5f, -1.0f);
DirectionalLight directional = new DirectionalLight(true, new Color3f(1, 1, 1), direction);
directional.setInfluencingBounds(bounds);
//directional.setCapability(DirectionalLight.ALLOW_DIRECTION_READ);
//directional.setCapability(DirectionalLight.ALLOW_DIRECTION_WRITE);
master.addChild(directional);
}
void camera() {
OrbitBehavior orbit = new OrbitBehavior(viewer);
orbit.setRotXFactor(5);
orbit.setRotYFactor(0);
orbit.setZoomFactor(5);
orbit.setTransXFactor(5);
orbit.setTransYFactor(5);
orbit.setSchedulingBounds(new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 10000.0));
//System.out.println(universe == null);
universe.getViewingPlatform().setViewPlatformBehavior(orbit);
TransformGroup vtg = universe.getViewingPlatform().getViewPlatformTransform();
Transform3D moveback = new Transform3D();
moveback.setTranslation(new Vector3f(0.0f, 0.0f, 100.0f));
vtg.setTransform(moveback);
View view = universe.getViewer().getView();
view.setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY);
view.setDepthBufferFreezeTransparent(false); //aha!
view.setSceneAntialiasingEnable(true);
view.setBackClipDistance(10000.0);
view.setProjectionPolicy(View.PARALLEL_PROJECTION); //Will have to scale the sprites appropriately.
//view.setScreenScale();
//view.setViewPolicy(View.HMD_VIEW);
//view.setWindowEyepointPolicy(View.RELATIVE_TO_FIELD_OF_VIEW);
//System.out.println(view.getFieldOfView());
//view.setFieldOfView(Math.PI);
}
void action() {
master.compile();
universe.addBranchGraph(master);
}
void addSprite(Sprite sprite) {
sprite.update();
sprite.compile();
master.addChild(sprite);
}
static class Viewer extends Canvas3D {
final static GraphicsConfiguration CONFIGURATION = CONFIGURATION();
final static GraphicsConfiguration CONFIGURATION() {
return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(new GraphicsConfigTemplate3D());
}
Viewer() {
super(CONFIGURATION);
Screen3D screen = getScreen3D();
double w = screen.getPhysicalScreenWidth(), h = screen.getPhysicalScreenHeight();
System.out.println(w + " " + h);
screen.setPhysicalScreenWidth(w * 20);
screen.setPhysicalScreenHeight(h * 20);
}
}
}