com.sun.j3d.utils.geometry.Sphere Java Examples
The following examples show how to use
com.sun.j3d.utils.geometry.Sphere.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Ball.java From javagame with MIT License | 6 votes |
public Ball(double x, double y, double z, double vx, double vy, double vz) { position = new Vector3d(x, y, z); speed = new Vector3d(vx, vy, vz); // �ړ��\ this.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); this.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); app = new Appearance(); app.setTexture(loadTexture("carpet.jpg")); // �{�[����lj� this.addChild(new Sphere(radius, Sphere.GENERATE_TEXTURE_COORDS, 100, app)); move(); }
Example #2
Source File: Ball.java From javagame with MIT License | 6 votes |
public Ball(double x, double y, double z) { position = new Vector3d(x, y, z); velocity = new Vector3d(0, 0, 0); acceleration = new Vector3d(0, -0.01, 0); // �����x�͈�� // �ړ��\ this.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); this.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); app = new Appearance(); Material mat = new Material(); mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f)); mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f)); app.setMaterial(mat); TransparencyAttributes transAttr = new TransparencyAttributes( TransparencyAttributes.BLENDED, 0.2f); app.setTransparencyAttributes(transAttr); // �{�[����lj� this.addChild(new Sphere(radius, Sphere.GENERATE_NORMALS, 100, app)); move(); }
Example #3
Source File: Java3DWindow.java From GpsPrune with GNU General Public License v2.0 | 5 votes |
/** * Create a waypoint sphere * @param inPointPos position of point * @return Group object containing sphere */ private static Group createWaypoint(Point3d inPointPos) { Material mat = getWaypointMaterial(); // MAYBE: sort symbol scaling Sphere dot = new Sphere(0.35f); // * symbolScaling / 100f); return createBall(inPointPos, dot, mat); }
Example #4
Source File: Java3DWindow.java From GpsPrune with GNU General Public License v2.0 | 5 votes |
/** * @return track point object */ private static Group createTrackpoint(Point3d inPointPos, byte inHeightCode) { Material mat = getTrackpointMaterial(inHeightCode); // MAYBE: sort symbol scaling Sphere dot = new Sphere(0.2f); return createBall(inPointPos, dot, mat); }
Example #5
Source File: Java3DWindow.java From GpsPrune with GNU General Public License v2.0 | 5 votes |
/** * Create a ball at the given point * @param inPosition scaled position of point * @param inSphere sphere object * @param inMaterial material object * @return Group containing sphere */ private static Group createBall(Point3d inPosition, Sphere inSphere, Material inMaterial) { Group group = new Group(); // Create ball and add to group Transform3D ballShift = new Transform3D(); ballShift.setTranslation(new Vector3d(inPosition)); TransformGroup ballShiftTrans = new TransformGroup(ballShift); inMaterial.setLightingEnable(true); Appearance ballApp = new Appearance(); ballApp.setMaterial(inMaterial); inSphere.setAppearance(ballApp); ballShiftTrans.addChild(inSphere); group.addChild(ballShiftTrans); // Also create rod for ball to sit on Cylinder rod = new Cylinder(0.1f, (float) inPosition.y); Material rodMat = new Material(new Color3f(0.2f, 0.2f, 0.2f), new Color3f(0.0f, 0.0f, 0.0f), new Color3f(0.2f, 0.2f, 0.2f), new Color3f(0.05f, 0.05f, 0.05f), 0.4f); rodMat.setLightingEnable(true); Appearance rodApp = new Appearance(); rodApp.setMaterial(rodMat); rod.setAppearance(rodApp); Transform3D rodShift = new Transform3D(); rodShift.setTranslation(new Vector3d(inPosition.x, inPosition.y/2.0, inPosition.z)); TransformGroup rodShiftTrans = new TransformGroup(rodShift); rodShiftTrans.addChild(rod); group.addChild(rodShiftTrans); // return the pair return group; }
Example #6
Source File: MainPanel.java From javagame with MIT License | 5 votes |
/** * ����sceneBG�ɒlj� */ private void addSphere() { Color3f black = new Color3f(0.0f, 0.0f, 0.0f); // �� Color3f red = new Color3f(1.0f, 0.0f, 0.0f); // �� Color3f specular = new Color3f(0.9f, 0.9f, 0.9f); // �قڔ� // ���̍ގ��iMaterial�j Material blueMat = new Material(red, black, red, specular, 25.0f); blueMat.setLightingEnable(true); // ���̌����ځiAppearance�j Appearance blueApp = new Appearance(); blueApp.setMaterial(blueMat); // ���̈ړ� Transform3D t3d = new Transform3D(); t3d.set(new Vector3f(0, 0, 0)); // ���_�ֈړ�����T3D // �ړ����]�p�̃m�[�h��TG�iT3D���Z�b�g���Ďg���j TransformGroup tg = new TransformGroup(t3d); // �����쐬 Sphere sphere = new Sphere(2.0f, Sphere.GENERATE_NORMALS, 100, blueApp); tg.addChild(sphere); // �ړ��pTG�ɋ���ڑ�����I // sceneBG�ɋ����܂�TG��lj� sceneBG.addChild(tg); }
Example #7
Source File: CrystalBall.java From javagame with MIT License | 4 votes |
/** * �V�[�����\�z���� * * @return BG */ public BranchGroup createSceneGraph() { BranchGroup bg = new BranchGroup(); // �O�~ Appearance app = new Appearance(); app.setTexture(loadTexture("carpet.jpg")); // �O�~�̃e�N�X�`�� Box floor = new Box(0.8f, 0.01f, 0.8f, Box.GENERATE_TEXTURE_COORDS, app); // ������ app = new Appearance(); Material mat = new Material(); mat.setAmbientColor(new Color3f(0.0f, 0.0f, 1.0f)); mat.setSpecularColor(new Color3f(1.0f, 1.0f, 1.0f)); app.setMaterial(mat); TransparencyAttributes transAttr = new TransparencyAttributes( TransparencyAttributes.BLENDED, 0.5f); app.setTransparencyAttributes(transAttr); Sphere sphere = new Sphere(0.3f, Sphere.GENERATE_NORMALS, 100, app); // �������ړ��p Transform3D t3d = new Transform3D(); t3d.set(new Vector3f(0.0f, 0.3f, 0.0f)); TransformGroup tg = new TransformGroup(t3d); tg.addChild(sphere); bg.addChild(floor); bg.addChild(tg); // ���� BoundingSphere bounds = new BoundingSphere(); Light light = new AmbientLight(); light.setInfluencingBounds(bounds); bg.addChild(light); light = new DirectionalLight(new Color3f(1.0f, 1.0f, 1.0f), new Vector3f(1.0f, -1.0f, -1.0f)); light.setInfluencingBounds(bounds); bg.addChild(light); return bg; }
Example #8
Source File: Target.java From jMAVSim with BSD 3-Clause "New" or "Revised" License | 4 votes |
public Target(World world, double size) throws FileNotFoundException { super(world); Sphere sphere = new Sphere((float) size); transformGroup.addChild(sphere); gpsProjector.init(world.getGlobalReference()); }
Example #9
Source File: Visualizer3D.java From jMAVSim with BSD 3-Clause "New" or "Revised" License | 4 votes |
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); }