use of com.ardor3d.scenegraph.extension.BillboardNode in project energy3d by concord-consortium.
the class Human method init.
@Override
protected void init() {
super.init();
final double h;
final double w;
switch(humanType) {
case JANE:
w = 2.5;
h = 8;
break;
case JENI:
w = 3;
h = 9;
break;
case JILL:
w = 3;
h = 8;
break;
case JACK:
w = 2.8;
h = 9;
break;
case JOHN:
w = 4;
h = 10;
break;
case JOSE:
w = 8;
h = 8;
break;
default:
w = 2.5;
h = 8;
}
mesh = new Quad("Human Quad", w, h);
mesh.setModelBound(new BoundingBox());
mesh.updateModelBound();
mesh.setRotation(new Matrix3().fromAngles(Math.PI / 2, 0, 0));
// stand on the ground by default
translate(w, h, feetHeight);
mesh.setUserData(new UserData(this, 0, true));
final BlendState bs = new BlendState();
bs.setEnabled(true);
bs.setBlendEnabled(false);
bs.setTestEnabled(true);
bs.setTestFunction(TestFunction.GreaterThan);
bs.setReference(0.7f);
mesh.setRenderState(bs);
mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
billboard = new BillboardNode("Billboard");
billboard.setAlignment(BillboardAlignment.AxialZ);
billboard.attachChild(mesh);
root.attachChild(billboard);
updateTextureAndColor();
}
use of com.ardor3d.scenegraph.extension.BillboardNode in project energy3d by concord-consortium.
the class Tree method init.
@Override
protected void init() {
super.init();
switch(treeType) {
case COTTONWOOD:
treeWidth = 80;
treeHeight = 100;
break;
case LINDEN:
treeWidth = 90;
treeHeight = 120;
break;
case OAK:
treeWidth = 70;
treeHeight = 80;
break;
case ELM:
treeWidth = 60;
treeHeight = 75;
break;
case MAPLE:
treeWidth = 30;
treeHeight = 60;
break;
case PINE:
treeWidth = 30;
treeHeight = 80;
break;
default:
treeWidth = 30;
treeHeight = 40;
}
mesh = new Quad("Tree Quad", treeWidth, treeHeight);
mesh.setModelBound(new BoundingBox());
mesh.updateModelBound();
mesh.setRotation(new Matrix3().fromAngles(Math.PI / 2, 0, 0));
mesh.setTranslation(0, 0, treeHeight / 2.0);
mesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
final BlendState bs = new BlendState();
bs.setEnabled(true);
bs.setBlendEnabled(false);
bs.setTestEnabled(true);
bs.setTestFunction(TestFunction.GreaterThan);
bs.setReference(0.7f);
mesh.setRenderState(bs);
mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
billboard = new BillboardNode("Billboard");
billboard.setAlignment(BillboardAlignment.AxialZ);
billboard.attachChild(mesh);
root.attachChild(billboard);
switch(treeType) {
case PINE:
// axis samples, radial samples, radius, height, closed
crown = new Cone("Tree Crown", 2, 6, 18, 20, false);
break;
default:
// z samples, radial samples, radius
crown = new Sphere("Tree Crown", 4, 8, 14);
}
crown.setModelBound(new BoundingSphere());
crown.updateModelBound();
final Cylinder trunk = new Cylinder("Tree Trunk", 10, 10, 1, 20);
trunk.setModelBound(new BoundingBox());
trunk.updateModelBound();
switch(treeType) {
case COTTONWOOD:
crown.setScale(3, 3, 3.5);
crown.setTranslation(0, 0, 55);
trunk.setScale(8, 8, 2);
trunk.setTranslation(0, 0, 20);
break;
case LINDEN:
crown.setScale(3.5, 3.5, 4);
crown.setTranslation(0, 0, 65);
trunk.setScale(5, 5, 2);
trunk.setTranslation(0, 0, 20);
break;
case OAK:
crown.setScale(2.5, 2.5, 3);
crown.setTranslation(0, 0, 45);
trunk.setScale(5, 5, 2);
trunk.setTranslation(0, 0, 20);
break;
case ELM:
crown.setScale(2, 2, 2.5);
crown.setTranslation(0, 0, 40);
trunk.setScale(2, 2, 2);
trunk.setTranslation(0, 0, 20);
break;
case MAPLE:
crown.setScale(1, 1, 2.1);
crown.setTranslation(0, 0, 32);
trunk.setTranslation(0, 0, 10);
break;
case PINE:
crown.setScale(1, 1, -4.0);
crown.setTranslation(0, 0, 45);
trunk.setTranslation(0, 0, 10);
break;
default:
crown.setScale(1, 1, 1.2);
crown.setTranslation(0, 0, 24);
trunk.setTranslation(0, 0, 10);
break;
}
collisionRoot = new Node("Tree Collision Root");
collisionRoot.attachChild(crown);
collisionRoot.attachChild(trunk);
if (points.size() > 0) {
collisionRoot.setTranslation(getAbsPoint(0));
}
collisionRoot.updateWorldTransform(true);
collisionRoot.updateWorldBound(true);
collisionRoot.getSceneHints().setCullHint(showPolygons ? CullHint.Never : CullHint.Always);
root.attachChild(collisionRoot);
crown.setUserData(new UserData(this));
trunk.setUserData(new UserData(this));
updateTextureAndColor();
}
Aggregations