本文整理汇总了Java中com.sun.j3d.utils.geometry.Sphere.GENERATE_NORMALS_INWARD属性的典型用法代码示例。如果您正苦于以下问题:Java Sphere.GENERATE_NORMALS_INWARD属性的具体用法?Java Sphere.GENERATE_NORMALS_INWARD怎么用?Java Sphere.GENERATE_NORMALS_INWARD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.j3d.utils.geometry.Sphere
的用法示例。
在下文中一共展示了Sphere.GENERATE_NORMALS_INWARD属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rebuildAuxillarySwitch
void rebuildAuxillarySwitch()
{
auxillarySwitch = new Switch(Switch.CHILD_MASK);
auxillarySwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
auxillarySwitch.setCapability(Switch.ALLOW_CHILDREN_READ);
auxillarySwitch.setCapability(Switch.ALLOW_CHILDREN_EXTEND);
auxillarySwitch.setChildMask(auxillarySwitchMask);
// Add Axes to position 0 of switch
AxesPortrayal3D x = new AxesPortrayal3D(0.01f, true);
x.setCurrentDisplay(this);
auxillarySwitch.insertChild(x.getModel(null, null), AXES_AUX_INDEX);
// Add Backdrop Sphere to position 1 of switch
if (backdropAppearance != null || backdropColor != null || backdropImage !=null) // make a backdrop!
{
Background background = new Background();
background.setApplicationBounds(new BoundingSphere(
new Point3d(0,0,0), Double.MAX_VALUE));
if (backdropAppearance!=null)
{
BranchGroup backgroundBG = new BranchGroup();
Sphere sphere = new Sphere(1.0f,
Sphere.GENERATE_TEXTURE_COORDS |
Sphere.GENERATE_NORMALS |
Sphere.GENERATE_NORMALS_INWARD, 45, backdropAppearance);
// sphere lies along y axis. Move it to Z axis
Transform3D strans = new Transform3D();
strans.rotX(-Math.PI/2);
TransformGroup tg = new TransformGroup(strans);
tg.addChild(sphere);
// We want to auto-spin the spherical background with our autospinner.
// unfortunately it only spins elements in the scene. Our trick
// here is to put the sphere in a transform group and spin that
// transform group when we spin the rest of the scene. Ick. But
// it works!
autoSpinBackgroundTransformGroup.addChild(tg);
backgroundBG.addChild(autoSpinBackgroundTransformGroup);
background.setGeometry(backgroundBG);
}
else if (backdropColor!=null)
background.setColor(new Color3f(backdropColor));
else // flat background image
{ // ensure it's a buffered image
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(
backdropImage.getWidth(null),
backdropImage.getHeight(null));
Graphics g = img.getGraphics();
g.drawImage(backdropImage,0,0,null);
background.setImage(new ImageComponent2D(ImageComponent2D.FORMAT_RGB,img));
background.setImageScaleMode(Background.SCALE_FIT_MAX);
img.flush(); // just in case -- bug in OS X
}
auxillarySwitch.addChild(background);
}
else auxillarySwitch.addChild(new Group()); // empty
// Add Floor to position 2 of switch
// auxillarySwitch.addChild(new Group()); // empty stub
// auxillarySwitch.setChildMask(auxillarySwitchMask);
bogusMover = new PointArray(1, PointArray.COORDINATES);
bogusMover.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
moveBogusMover();
auxillarySwitch.addChild(new Shape3D(bogusMover));
}
示例2: createEnvironment
private void createEnvironment() {
BranchGroup group = new BranchGroup();
// Sky
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 1000.0);
Background bg = new Background();
bg.setApplicationBounds(bounds);
BranchGroup backGeoBranch = new BranchGroup();
Sphere skySphere = new Sphere(1.0f,
Sphere.GENERATE_NORMALS | Sphere.GENERATE_NORMALS_INWARD | Sphere.GENERATE_TEXTURE_COORDS, 32);
// Sphere.GENERATE_NORMALS | Sphere.GENERATE_NORMALS_INWARD | Sphere.GENERATE_TEXTURE_COORDS, 32);
Texture texSky = new TextureLoader("environment/sky.jpg", null).getTexture();
skySphere.getAppearance().setTexture(texSky);
Transform3D transformSky = new Transform3D();
//transformSky.setTranslation(new Vector3d(0.0, 0.0, -0.5));
Matrix3d rot = new Matrix3d();
rot.rotX(Math.PI / 2);
transformSky.setRotation(rot);
TransformGroup tgSky = new TransformGroup(transformSky);
tgSky.addChild(skySphere);
backGeoBranch.addChild(tgSky);
bg.setGeometry(backGeoBranch);
group.addChild(bg);
//group.addChild(tgSky);
// Ground
QuadArray polygon1 = new QuadArray(4, QuadArray.COORDINATES | GeometryArray.TEXTURE_COORDINATE_2);
polygon1.setCoordinate(0, new Point3f(-1000f, 1000f, 0f));
polygon1.setCoordinate(1, new Point3f(1000f, 1000f, 0f));
polygon1.setCoordinate(2, new Point3f(1000f, -1000f, 0f));
polygon1.setCoordinate(3, new Point3f(-1000f, -1000f, 0f));
polygon1.setTextureCoordinate(0, 0, new TexCoord2f(0.0f, 0.0f));
polygon1.setTextureCoordinate(0, 1, new TexCoord2f(10.0f, 0.0f));
polygon1.setTextureCoordinate(0, 2, new TexCoord2f(10.0f, 10.0f));
polygon1.setTextureCoordinate(0, 3, new TexCoord2f(0.0f, 10.0f));
Texture texGround = new TextureLoader("environment/grass2.jpg", null).getTexture();
Appearance apGround = new Appearance();
apGround.setTexture(texGround);
Shape3D ground = new Shape3D(polygon1, apGround);
Transform3D transformGround = new Transform3D();
transformGround.setTranslation(
new Vector3d(0.0, 0.0, 0.005 + world.getEnvironment().getGroundLevel(new Vector3d(0.0, 0.0, 0.0))));
TransformGroup tgGround = new TransformGroup(transformGround);
tgGround.addChild(ground);
group.addChild(tgGround);
// Light
DirectionalLight light1 = new DirectionalLight(white, new Vector3f(4.0f, 7.0f, 12.0f));
light1.setInfluencingBounds(sceneBounds);
group.addChild(light1);
AmbientLight light2 = new AmbientLight(new Color3f(0.5f, 0.5f, 0.5f));
light2.setInfluencingBounds(sceneBounds);
group.addChild(light2);
// Update behavior
Behavior b = new UpdateBehavior();
b.setSchedulingBounds(bounds);
group.addChild(b);
universe.addBranchGraph(group);
}