本文整理汇总了Java中javax.media.j3d.BranchGroup.setCapability方法的典型用法代码示例。如果您正苦于以下问题:Java BranchGroup.setCapability方法的具体用法?Java BranchGroup.setCapability怎么用?Java BranchGroup.setCapability使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.media.j3d.BranchGroup
的用法示例。
在下文中一共展示了BranchGroup.setCapability方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSliceGeo
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
@Override
void setSliceGeo()
{
BranchGroup polyGroup = new BranchGroup();
polyGroup.setCapability(BranchGroup.ALLOW_DETACH);
if (numSlicePts > 0)
{
// for each triangle...
for (int i = 0; i < numSlicePts - 2; i++)
{
tesselateTri(polyGroup, slicePts[0], slicePts[i + 1], slicePts[i + 2]);
}
}
sliceGroup.setChild(polyGroup, 0);
}
示例2: addLight
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
*
*/
public void addLight(Color couleur, float x, float y, float z) {
// Lumiere attenuee (ex : source lumineuse en un point)
PointLight pointlight = new PointLight();
pointlight.setEnable(true);
pointlight.setColor(new Color3f(couleur));
System.out.println(this.getTranslate());
pointlight.setPosition(new Point3f(x + this.getTranslate().x, y + +this.getTranslate().y, z
+ +this.getTranslate().z));
pointlight.setAttenuation(1f, 0f, 0f);
pointlight.setInfluencingBounds(new BoundingSphere(new Point3d(), Double.POSITIVE_INFINITY));
pointlight.setCapability(Light.ALLOW_COLOR_READ);
pointlight.setCapability(Light.ALLOW_COLOR_WRITE);
pointlight.setCapability(Light.ALLOW_STATE_READ);
pointlight.setCapability(Light.ALLOW_STATE_WRITE);
pointlight.setCapability(PointLight.ALLOW_ATTENUATION_READ);
pointlight.setCapability(PointLight.ALLOW_ATTENUATION_WRITE);
pointlight.setCapability(PointLight.ALLOW_POSITION_READ);
pointlight.setCapability(PointLight.ALLOW_POSITION_WRITE);
BranchGroup bgTempL = new BranchGroup();
bgTempL.setCapability(Node.ALLOW_PICKABLE_READ);
bgTempL.setCapability(Node.ALLOW_PICKABLE_WRITE);
bgTempL.setCapability(Node.ENABLE_PICK_REPORTING);
bgTempL.setCapability(Group.ALLOW_CHILDREN_EXTEND);
bgTempL.setCapability(Group.ALLOW_CHILDREN_READ);
bgTempL.setCapability(Group.ALLOW_CHILDREN_WRITE);
bgTempL.setCapability(BranchGroup.ALLOW_DETACH);
bgTempL.addChild(pointlight);
this.getLights().add(pointlight);
this.getScene().addChild(bgTempL);
}
示例3: addElementAt
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
public static BranchGroup addElementAt(Node aShape, Vector3f aTranslation, float aScale) {
BranchGroup theGroup = new BranchGroup();
theGroup.setCapability(BranchGroup.ALLOW_DETACH);
Transform3D theTransform = new Transform3D();
theTransform.setTranslation(aTranslation);
theTransform.setScale(aScale);
TransformGroup theTransformGroup = new TransformGroup(theTransform);
theTransformGroup.addChild(aShape);
theGroup.addChild(theTransformGroup);
return theGroup;
}
示例4: createSceneTree
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Returns scene tree root.
*/
private BranchGroup createSceneTree()
{
BranchGroup root = new BranchGroup();
root.setCapability(BranchGroup.ALLOW_DETACH);
root.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
// Build scene tree
root.addChild(createModelTree());
root.addChild(createBackgroundNode());
for (Light light : createLights())
{
root.addChild(light);
}
return root;
}
示例5: SlicePlaneRenderer
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
public SlicePlaneRenderer(View view, Context context, Volume vol)
{
super(view, context, vol);
volRefPtAttr = (CoordAttr) context.getAttr("Vol Ref Pt");
root = new BranchGroup();
// subclasses add the slice geometry to root
borderSwitch = new Switch(Switch.CHILD_ALL);
borderSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);
RenderingAttributes ra = new RenderingAttributes();
ra.setDepthBufferEnable(true);
ColoringAttributes bclr = new ColoringAttributes(0.4f, 0.4f, 0.4f,
ColoringAttributes.SHADE_FLAT);
Appearance ba = new Appearance();
ba.setColoringAttributes(bclr);
ba.setRenderingAttributes(ra);
borderShape = new Shape3D(null, ba);
borderShape.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
borderSwitch.addChild(borderShape);
root.addChild(borderSwitch);
root.setCapability(BranchGroup.ALLOW_DETACH);
root.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
}
示例6: showDebugSphere
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Zeichnet eine Kugel zu Debug-Zwecken, indem sie zu TestBG hinzugefuegt wird
* @param radius Radius der Kugel
* @param transform Transformation, die auf die Box angewendet werden soll
*/
public void showDebugSphere(final double radius, Transform3D transform) {
final Sphere sphare = new Sphere((float) radius);
TransformGroup tg = new TransformGroup();
tg.setTransform(transform);
tg.addChild(sphare);
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ALLOW_DETACH);
bg.addChild(tg);
testBG.addChild(bg);
}
示例7: showDebugBox
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Zeichnet eine Box zu Debug-Zwecken, indem sie zu TestBG hinzugefuegt wird
* @param x Groesse in X-Richtung
* @param y Groesse in Y-Richtung
* @param z Groesse in Z-Richtung
* @param transform Transformation, die auf die Box angewendet werden soll
* @param angle Winkel, um den die Box gedreht werden soll
*/
public void showDebugBox(final double x, final double y, final double z, Transform3D transform, double angle) {
final Box box = new Box((float) x, (float) y, (float) z, null);
transform.setRotation(new AxisAngle4d(0, 0, 1, angle));
TransformGroup tg = new TransformGroup();
tg.setTransform(transform);
tg.addChild(box);
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ALLOW_DETACH);
bg.addChild(tg);
testBG.addChild(bg);
}
示例8: Parcours
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Erzeugt einen neuen, leeren Parcours
* @param parcoursLoader ParcoursLoader, der den Parcours erzeugt hat
*/
public Parcours(ParcoursLoader parcoursLoader) {
super();
this.parcoursLoader = parcoursLoader;
// Die Branchgroup fuer die Hindernisse
ObstBG = new BranchGroup();
ObstBG.setCapability(Node.ALLOW_PICKABLE_WRITE);
ObstBG.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
ObstBG.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
ObstBG.setCapability(BranchGroup.ALLOW_DETACH);
ObstBG.setPickable(true);
// Die Branchgroup fuer die Lichtquellen
lightBG = new BranchGroup();
lightBG.setCapability(Node.ALLOW_PICKABLE_WRITE);
lightBG.setPickable(true);
// Die Branchgroup fuer die BPS-Landmarken
bpsBG = new BranchGroup();
bpsBG.setPickable(true);
// Die Branchgroup fuer den Boden
terrainBG = new BranchGroup();
terrainBG.setCapability(Node.ALLOW_PICKABLE_WRITE);
terrainBG.setPickable(true);
// Standard Startposition
startPositions[0][0] = 0;
startPositions[0][1] = 0;
}
示例9: createDefaultBranchGroup
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
public static BranchGroup createDefaultBranchGroup( )
{
final BranchGroup result = new BranchGroup( );
result.setCapability( BranchGroup.ALLOW_DETACH );
result.setCapability( Group.ALLOW_CHILDREN_READ );
result.setCapability( Group.ALLOW_CHILDREN_WRITE );
result.setCapability( Group.ALLOW_CHILDREN_EXTEND );
return result;
}
示例10: createScene
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Initialize java3D Space
* Construct the globel java3D Tree
* @param simpleU (unknown)
* @return Return the root Branch Group of the scene (after this, compile it).
*/
private BranchGroup createScene(SimpleUniverse simpleU) {
BoundingSphere bounds = new BoundingSphere(new Point3d(), 10000.0);
TransformGroup vpTrans = simpleU.getViewingPlatform().getViewPlatformTransform();
// RAW ROOT
BranchGroup objRoot = new BranchGroup();
objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
// ENABLE MANIPULATION
transformRoot = this.enableMouseNavigation(objRoot, bounds);
// MANIPULABLE ROOT
this.root = new BranchGroup();
this.root.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
transformRoot.addChild(this.root);
// planets Creation
for (int i = 0; i < nbBodies; i++) {
Appearance a = createPlaneteAppareance(i);
Appearance t = new Appearance();
t.setMaterial(a.getMaterial());
this.createPlanete(root, i, a);
this.createPlaneteTraces(root, i, t);
}
// Add the jpg to the Background
this.applyBackgroundImage(objRoot, bounds);
// Add a ambient light
this.addAmbientLight(objRoot, bounds);
return objRoot;
}
示例11: createPlanete
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Create a group componsed of a sphere and different transform group + a hostname label
* @param root where adding the "sphere group" in 3D scene
* @param i body to represent
* @param a appearance of the sphere which represent the body
*/
private void createPlanete(BranchGroup root, int i, Appearance a) {
// Creation of the Root Animation Node of the planet
TransformGroup planeteAnimationGroup = new TransformGroup();
planeteAnimationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
translationsGroup[i] = planeteAnimationGroup;
// Allow to Translate the Node of the planet
Transform3D translationPlanete = new Transform3D();
translations[i] = translationPlanete;
// Creating floating hostname label near the planet
BranchGroup lGroup = new BranchGroup();
lGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
lGroup.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
lGroup.setCapability(TransformGroup.ALLOW_CHILDREN_WRITE);
labels[i] = lGroup;
// Rotation of the planet on itself
TransformGroup planeteRotationGroup = new TransformGroup();
planeteRotationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Alpha planeteRotationAlpha = new Alpha(-1, 4000);
RotationInterpolator rotator = new RotationInterpolator(planeteRotationAlpha, planeteRotationGroup);
rotator.setSchedulingBounds(new BoundingSphere(new Point3d(0, 0, 0), 999999999));
planetesScalingGroup[i] = planeteRotationGroup;
// Allow to change the Scale of the sphere representing the planet
Transform3D planeteScaling = new Transform3D();
planeteRotationGroup.setTransform(planeteScaling);
planetesScaling[i] = planeteScaling;
// Creation of the sphere representing the planete
Sphere planete = new Sphere(0.01f, Sphere.GENERATE_NORMALS, 80, a);
// Assembling java3D nodes
planeteRotationGroup.addChild(planete);
planeteAnimationGroup.addChild(lGroup);
planeteAnimationGroup.addChild(planeteRotationGroup);
root.addChild(planeteAnimationGroup);
}
示例12: writeLabel
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Used to write a text next to the sphere representing a body
* @param i the body identification
* @param label the text to write
*/
private void writeLabel(int i, String label, double diameter) {
labels[i].removeAllChildren();
if (label.compareTo("") != 0) {
// Creating
BranchGroup bg = new BranchGroup();
bg.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);
bg.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
bg.setCapability(BranchGroup.ALLOW_DETACH);
// Translating & scaling
TransformGroup labelGroup = new TransformGroup();
Transform3D scaling = new Transform3D();
scaling.setTranslation(new Vector3d(0.01 + ((0.005 * diameter) / MASS_RATIO),
0.01 + ((0.005 * diameter) / MASS_RATIO), 0.0));
//scaling.setTranslation(new Vector3d(0.15,0.15,0.0));
scaling.setScale(0.5);
labelGroup.setTransform(scaling);
// Assembling and creating the text2D
labelGroup.addChild(new Text2D(label, new Color3f(1.0f, 1.0f, 1.0f), "Arial", 14, Font.PLAIN));
bg.addChild(labelGroup);
bg.compile();
labels[i].addChild(bg);
}
}
示例13: updatePieceOfFurnitureModelNode
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Updates transform group children with <code>modelMode</code>.
*/
private void updatePieceOfFurnitureModelNode(Node modelNode, TransformGroup normalization,
boolean ignoreDrawingMode, boolean waitTextureLoadingEnd)
{
normalization.addChild(modelNode);
setModelCapabilities(normalization);
// Add model node to branch group
BranchGroup modelBranch = new BranchGroup();
modelBranch.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
modelBranch.addChild(normalization);
if (!ignoreDrawingMode)
{
// Add outline model node
modelBranch.addChild(createOutlineModelNode(normalization));
}
TransformGroup transformGroup = (TransformGroup) getChild(0);
// Remove previous nodes
transformGroup.removeAllChildren();
// Add model branch to live scene
transformGroup.addChild(modelBranch);
HomePieceOfFurniture piece = (HomePieceOfFurniture) getUserData();
if (piece instanceof HomeLight)
{
BranchGroup lightBranch = new BranchGroup();
lightBranch.setCapability(ALLOW_CHILDREN_READ);
HomeLight light = (HomeLight) piece;
for (int i = light.getLightSources().length; i > 0; i--)
{
PointLight pointLight = new PointLight(new Color3f(), new Point3f(), new Point3f(0.25f, 0, 0.0000025f));
pointLight.setCapability(PointLight.ALLOW_POSITION_WRITE);
pointLight.setCapability(PointLight.ALLOW_COLOR_WRITE);
pointLight.setCapability(PointLight.ALLOW_STATE_WRITE);
BoundingLeaf bounds = (BoundingLeaf) getChild(1);
pointLight.setInfluencingBoundingLeaf(bounds);
lightBranch.addChild(pointLight);
}
addChild(lightBranch);
}
// Flip normals if back faces of model are shown
if (piece.isBackFaceShown())
{
setBackFaceNormalFlip(getFilledModelNode(), true);
}
// Update piece color, visibility and model mirror in dispatch thread as
// these attributes may be changed in that thread
updatePieceOfFurnitureModelMirrored();
updatePieceOfFurnitureColorAndTexture(waitTextureLoadingEnd);
updateLight();
updatePieceOfFurnitureVisibility();
// Manage light sources visibility
if (this.home != null && getUserData() instanceof Light)
{
this.home.addSelectionListener(new LightSelectionListener(this));
}
}
示例14: createIcon
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/**
* Returns an icon created and scaled from piece model content.
*/
private Icon createIcon(BranchGroup modelNode, float pieceWidth, float pieceDepth, float pieceHeight)
{
// Add piece model scene to a normalized transform group
Transform3D scaleTransform = new Transform3D();
scaleTransform.setScale(new Vector3d(2 / pieceWidth, 2 / pieceHeight, 2 / pieceDepth));
TransformGroup modelTransformGroup = new TransformGroup();
modelTransformGroup.setTransform(scaleTransform);
modelTransformGroup.addChild(modelNode);
// Replace model textures by clones because Java 3D doesn't accept all the time
// to share textures between offscreen and onscreen environments
cloneTexture(modelNode, new IdentityHashMap<Texture, Texture>());
BranchGroup model = new BranchGroup();
model.setCapability(BranchGroup.ALLOW_DETACH);
model.addChild(modelTransformGroup);
sceneRoot.addChild(model);
// Render scene with a white background
Background background = (Background) sceneRoot.getChild(0);
background.setColor(1, 1, 1);
canvas3D.renderOffScreenBuffer();
canvas3D.waitForOffScreenRendering();
BufferedImage imageWithWhiteBackgound = canvas3D.getOffScreenBuffer().getImage();
int[] imageWithWhiteBackgoundPixels = getImagePixels(imageWithWhiteBackgound);
// Render scene with a black background
background.setColor(0, 0, 0);
canvas3D.renderOffScreenBuffer();
canvas3D.waitForOffScreenRendering();
BufferedImage imageWithBlackBackgound = canvas3D.getOffScreenBuffer().getImage();
int[] imageWithBlackBackgoundPixels = getImagePixels(imageWithBlackBackgound);
// Create an image with transparent pixels where model isn't drawn
for (int i = 0; i < imageWithBlackBackgoundPixels.length; i++)
{
if (imageWithBlackBackgoundPixels[i] != imageWithWhiteBackgoundPixels[i]
&& imageWithBlackBackgoundPixels[i] == 0xFF000000
&& imageWithWhiteBackgoundPixels[i] == 0xFFFFFFFF)
{
imageWithWhiteBackgoundPixels[i] = 0;
}
}
sceneRoot.removeChild(model);
return new ImageIcon(Toolkit.getDefaultToolkit()
.createImage(new MemoryImageSource(imageWithWhiteBackgound.getWidth(),
imageWithWhiteBackgound.getHeight(), imageWithWhiteBackgoundPixels, 0,
imageWithWhiteBackgound.getWidth())));
}
示例15: create3D
import javax.media.j3d.BranchGroup; //导入方法依赖的package包/类
/** Create the object geometry. */
void create3D(boolean allowTransformReadWrite) {
// STRUCTURE Branch group->Translation Transform Group -> Rotation
// Transform Group->Group
branchGroup = new BranchGroup();
branchGroup.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
branchGroup.setCapability(BranchGroup.ALLOW_DETACH);
translation = new Transform3D();
translation.setIdentity();
translationGroup = new TransformGroup();
translationGroup.setTransform(translation);
branchGroup.addChild(translationGroup);
if (allowTransformReadWrite) {
translationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
translationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
translationGroup.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
translationGroup.setCapabilityIsFrequent(TransformGroup.ALLOW_TRANSFORM_WRITE);
translationGroup.setCapabilityIsFrequent(TransformGroup.ALLOW_TRANSFORM_READ);
translationGroup.setCapabilityIsFrequent(Node.ALLOW_LOCAL_TO_VWORLD_READ);
}
// rotation transform
rotation = new Transform3D();
rotation.setIdentity();
rotationGroup = new TransformGroup();
rotationGroup.setTransform(rotation);
translationGroup.addChild(rotationGroup);
if (allowTransformReadWrite) {
rotationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
rotationGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
rotationGroup.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
rotationGroup.setCapabilityIsFrequent(TransformGroup.ALLOW_TRANSFORM_READ);
rotationGroup.setCapabilityIsFrequent(TransformGroup.ALLOW_TRANSFORM_WRITE);
rotationGroup.setCapabilityIsFrequent(Node.ALLOW_LOCAL_TO_VWORLD_READ);
}
// Create group to attach all gemotries
group = new Group();
group.setCapability(Node.ALLOW_LOCAL_TO_VWORLD_READ);
// we want to setup the bounds manually
group.setBoundsAutoCompute(false);
// group.setCapability(Group.ALLOW_BOUNDS_READ); // No more needed, use
// localBounds
rotationGroup.addChild(group);
}