本文整理汇总了Java中com.jme3.scene.shape.Cylinder类的典型用法代码示例。如果您正苦于以下问题:Java Cylinder类的具体用法?Java Cylinder怎么用?Java Cylinder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cylinder类属于com.jme3.scene.shape包,在下文中一共展示了Cylinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: simpleInitApp
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
@Override
public void simpleInitApp() {
Cylinder t = new Cylinder(20, 50, 1, 2, true);
Geometry geom = new Geometry("Cylinder", t);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
TextureKey key = new TextureKey("Interface/Logo/Monkey.jpg", true);
key.setGenerateMips(true);
Texture tex = assetManager.loadTexture(key);
tex.setMinFilter(Texture.MinFilter.Trilinear);
mat.setTexture("ColorMap", tex);
geom.setMaterial(mat);
rootNode.attachChild(geom);
}
示例2: initialize
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
@Override
public void initialize() {
super.initialize();
Material mat = MaterialUtils.createTransparent(texture);
mat.setColor("Color", color);
Cylinder cylinder = new Cylinder(2, 16, radius, height);
cylinderNode = new Geometry("TextureCylinderEffect_root", cylinder);
cylinderNode.setMaterial(mat);
// 默认贴图在xy平面上,当指定了其它方向时需要进行旋转,默认以逆时针旋转到指定平面
if ("x".equals(axis)) {
cylinderNode.rotate(0, FastMath.HALF_PI, 0);
} else if ("y".equals(axis)) {
cylinderNode.rotate(FastMath.HALF_PI, FastMath.HALF_PI, 0);
} else if ("z".equals(axis)) {
cylinderNode.rotate(0, 0, -FastMath.HALF_PI);
}
if (offset != null) {
cylinderNode.setLocalTranslation(offset);
}
animNode.attachChild(cylinderNode);
}
示例3: createArrow
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
private Node createArrow(float coneRatio, float axisHeight, float axisRadius, Material mat, String transform) {
float omConeRatio = 1 - coneRatio;
Node xAxisNode = new Node();
Cylinder cyl = new Cylinder(6, 12, axisRadius, axisHeight * coneRatio, true, false);
Geometry xAxis1 = new Geometry("xCyl", cyl);
xAxis1.setMaterial(mat);
xAxis1.setLocalTranslation(0, 0, axisHeight * coneRatio / 2.0f);
Cylinder cyl2 = new Cylinder(6, 24, 0.0f, axisRadius * 1.5f, axisHeight * omConeRatio, true, false);
Geometry xAxis2 = new Geometry("xCone", cyl2);
xAxis2.setMaterial(mat);
xAxis2.setLocalTranslation(0, 0, axisHeight * (coneRatio + omConeRatio / 2));
xAxis1.setUserData("Transform", transform);
xAxis2.setUserData("Transform", transform);
xAxisNode.attachChild(xAxis1);
xAxisNode.attachChild(xAxis2);
return xAxisNode;
}
示例4: createArrow
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
private Node createArrow(float coneRatio, float axisHeight, float axisRadius, Material mat) {
float omConeRatio = 1 - coneRatio;
Node xAxisNode = new Node();
Cylinder cyl = new Cylinder(6, 12, axisRadius, axisHeight * coneRatio, true, false);
Vector2f scale = new Vector2f(1,5*(axisHeight* coneRatio));
cyl.scaleTextureCoordinates( scale );
Geometry xAxis1 = new Geometry("xCyl", cyl);
xAxis1.setMaterial(mat);
xAxis1.setLocalTranslation(0, 0, axisHeight * coneRatio / 2.0f);
Cylinder cyl2 = new Cylinder(6, 24, 0.0f, axisRadius * 1.5f, axisHeight * omConeRatio, true, false);
Vector2f scale2 = new Vector2f(5*(axisHeight* omConeRatio),5*(axisHeight* omConeRatio));
cyl2.scaleTextureCoordinates(scale2);
Geometry xAxis2 = new Geometry("xCone", cyl2);
xAxis2.setMaterial(mat);
xAxis2.setLocalTranslation(0, 0, axisHeight * (coneRatio + omConeRatio / 2));
xAxisNode.attachChild(xAxis1);
xAxisNode.attachChild(xAxis2);
return xAxisNode;
}
示例5: initialize
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
/**
* Initializes the tool.
*
* @param manager the AssetManager to load objects and materials from.
* @param inputManager can be used to register keypresses that can be used
* with this tool.
*/
public void initialize(AssetManager manager, InputManager inputManager) {
ObjectType objectType = GlobalObjects.getInstance().getObjectsTypeCategory().getObjectType("Terrain", "Brush");
defaultBrush = (TerrainBrush)objectType.create(manager, "defaultbrush");
defaultBrush.setLayerName("terrain");
brushShape = new Cylinder(2, 12, defaultBrush.getRadius(), 1.0f);
brushGizmo = new Geometry("terrainBrush", brushShape);
Quaternion q = new Quaternion();
q.fromAngles(FastMath.HALF_PI, 0, 0);
brushGizmo.setLocalRotation(q);
brushGizmo.setMaterial(manager.loadMaterial("Materials/BrushGizmoMaterial.j3m"));
inputManager.addListener(shiftListener, new String[]{"DOBRUSH"});
GlobalObjects.getInstance().registerListener(this);
}
示例6: execute
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
@Override
public EffectHandle execute(Node root, Vector3f loc, String param) {
CCharacterPhysics phys = root.getControl(CCharacterPhysics.class);
float height = phys.getCapsuleShape().getHeight();
float radius = phys.getCapsuleShape().getRadius();
Mesh mesh = new Cylinder(2, 32, 1f, 0.1f, true);
Geometry geom = new Geometry("backlash-action", mesh);
geom.scale(radius * 1.75f, height, radius * 1.75f);
geom.setLocalTranslation(0f, 1f, 0f);
Material mat = new Material(Globals.assets,
"MatDefs/Backlash/Backlash.j3md");
mat.getAdditionalRenderState()
.setBlendMode(RenderState.BlendMode.AlphaAdditive);
mat.getAdditionalRenderState().setFaceCullMode(RenderState.FaceCullMode.Off);
geom.setQueueBucket(RenderQueue.Bucket.Transparent);
geom.setMaterial(mat);
root.attachChild(geom);
return () -> {
geom.removeFromParent();
};
}
示例7: refreshMesh
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
private void refreshMesh(Node node, Entity e){
float r = e.get(CapsuleView.class).getRadius();
float h = e.get(CapsuleView.class).getHeight();
Geometry cylinder = new Geometry("cylinder", new Cylinder(16, 16, r, h));
Geometry top = new Geometry("top sphere", new Sphere(16,16, r));
Geometry bottom = new Geometry("bottom sphere", new Sphere(16, 16, r));
cylinder.rotate(FastMath.HALF_PI, 0, 0);
bottom.setLocalTranslation(0, -h/2, 0);
top.setLocalTranslation(0, h/2,0);
node.attachChild(cylinder);
node.attachChild(bottom);
node.attachChild(top);
}
示例8: createMesh
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
@Override
@FXThread
protected @NotNull Mesh createMesh(@NotNull final VarTable vars) {
final int axisSamples = vars.getInteger(PROPERTY_AXIS_SAMPLES);
final int radialSamples = vars.getInteger(PROPERTY_RADIAL_SAMPLES);
final float radius = vars.getFloat(PROPERTY_RADIUS);
final float height = vars.getFloat(PROPERTY_HEIGHT);
return new Cylinder(axisSamples, radialSamples, radius, height);
}
示例9: simpleInitApp
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
createMaterial();
Node node = new Node("node1");
attachRandomGeometry(node, mat1);
randomizeTransform(node);
Node node2 = new Node("node2");
attachRandomGeometry(node2, mat2);
randomizeTransform(node2);
node.attachChild(node2);
rootNode.attachChild(node);
RigidBodyControl control = new RigidBodyControl(0);
node.addControl(control);
getPhysicsSpace().add(control);
//test single geometry too
Geometry myGeom = new Geometry("cylinder", new Cylinder(16, 16, 0.5f, 1));
myGeom.setMaterial(mat3);
randomizeTransform(myGeom);
rootNode.attachChild(myGeom);
RigidBodyControl control3 = new RigidBodyControl(0);
myGeom.addControl(control3);
getPhysicsSpace().add(control3);
}
示例10: makeCylinder
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
public Geometry makeCylinder(String name, float radius, float height, int sides,
ColorRGBA color) {
Material mat = new Material(assetManager,
"Common/MatDefs/Light/Lighting.j3md");
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Ambient", color.mult(0.8f));
mat.setColor("Diffuse", color);
mat.setColor("Specular", ColorRGBA.White);
// mat.setBoolean("HighQuality", false);
Geometry cylinder = new Geometry(name, new Cylinder(32, sides, radius, height, true));
cylinder.setMaterial(mat);
return cylinder;
}
示例11: setupShip
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
private void setupShip() {
Cylinder n = new Cylinder(30, 30, 0.25f, 1f);
Geometry nose = new Geometry("Nose", n);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Ambient", ColorRGBA.Gray);
mat.setColor("Diffuse", ColorRGBA.Blue);
mat.setColor("Specular", ColorRGBA.White);
mat.setFloat("Shininess", 1);
nose.setMaterial(mat);
Sphere b = new Sphere(30, 30, 1f, true, false);
Geometry body = new Geometry("Body", b);
body.setMaterial(mat);
body.setLocalTranslation(0, -0.5f, 0);
ship = new Node("Ship");
ship.attachChild(nose);
ship.attachChild(body);
ship.getChild("Nose").setLocalTranslation(0, 0, 1);
ship.getChild("Body").setLocalTranslation(0, 0, 0);
System.out.println("setting radius to: 1.0");
ship.setUserData("radius", new Float(1f));
rootNode.attachChild(ship);
vel = new Vector3f(0, 0, 0);
accel = new Vector3f(0, 0, 0);
}
示例12: createShape
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
private void createShape(Prefab parent) {
Cylinder cyl = new Cylinder(axialSegments, radialSegments, radius, getHeight(), true);
cylinderGeo = new Geometry("cylinder", cyl);
AssetManager am = GlobalObjects.getInstance().getAssetManager();
cylinderMat = am.loadMaterial("Materials/RigMaterial.j3m");
cylinderGeo.setMaterial(cylinderMat);
resetColor();
cylinderGeo.setLocalRotation(getRotation());
parent.attachChild(cylinderGeo);
}
示例13: getMesh
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
@Override
protected Mesh getMesh(Entity e) {
CylinderView cylinder = e.get(CylinderView.class);
return new Cylinder(16, 16, cylinder.getRadius(), cylinder.getHeight(), true);
}
示例14: showMarkers
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
private void showMarkers() {
tweed.enqueue( new Runnable() { // run after toAlign's local transofrm has been updated!
@Override
public void run() {
for ( Spatial s : markers.getChildren() )
s.removeFromParent();
Vector3f[] targetMarkers;
if ( toAlign != null ) {
Transform toTarget = toAlign.gNode.getLocalTransform();
targetMarkers = new Vector3f[alignMarkers.length];
for ( int i = 0; i < alignMarkers.length; i++ ) {
if ( alignMarkers[ i ] != null ) {
targetMarkers[ i ] = new Vector3f();
toTarget.transformVector( alignMarkers[ i ], targetMarkers[ i ] );
}
}
} else
targetMarkers = new Vector3f[2];
int cc = 4;
for ( Vector3f[] a : new Vector3f[][] { otherMarkers, targetMarkers } ) {
Color c = Rainbow.getColour( cc++ );
for ( Vector3f v : a ) {
if ( v != null ) {
Cylinder handleOne = new Cylinder( 2, 3, 0.05f, 500f, true );
handleOne.setMode( Mode.Lines );
Geometry g1 = new Geometry( "h1", handleOne );
Material mat1 = new Material( tweed.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md" );
mat1.setColor( "Color", new ColorRGBA (c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 1f ) ) ;
g1.setMaterial( mat1 );
Vector3f pos = new Vector3f( v );
pos = pos.add( 0, 250, 0 );
g1.setLocalTranslation( pos );
g1.setLocalRotation( new Quaternion( new float[] {FastMath.PI/2, 0, 0} ) );
markers.attachChild(g1);
}
}
}
}
});
}
示例15: buildPlayer
import com.jme3.scene.shape.Cylinder; //导入依赖的package包/类
private void buildPlayer() {
Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.getAdditionalRenderState().setWireframe(true);
mat.setColor("Color", ColorRGBA.Red);
//create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
//this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0
CompoundCollisionShape compoundShape = new CompoundCollisionShape();
BoxCollisionShape box = new BoxCollisionShape(new Vector3f(1.2f, 0.5f, 2.4f));
compoundShape.addChildShape(box, new Vector3f(0, 1, 0));
//create vehicle node
Node vehicleNode=new Node("vehicleNode");
vehicle = new VehicleControl(compoundShape, 400);
vehicleNode.addControl(vehicle);
//setting suspension values for wheels, this can be a bit tricky
//see also https://docs.google.com/Doc?docid=0AXVUZ5xw6XpKZGNuZG56a3FfMzU0Z2NyZnF4Zmo&hl=en
float stiffness = 60.0f;//200=f1 car
float compValue = .3f; //(should be lower than damp)
float dampValue = .4f;
vehicle.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
vehicle.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
vehicle.setSuspensionStiffness(stiffness);
vehicle.setMaxSuspensionForce(10000.0f);
//Create four wheels and add them at their locations
Vector3f wheelDirection = new Vector3f(0, -1, 0); // was 0, -1, 0
Vector3f wheelAxle = new Vector3f(-1, 0, 0); // was -1, 0, 0
float radius = 0.5f;
float restLength = 0.3f;
float yOff = 0.5f;
float xOff = 1f;
float zOff = 2f;
Cylinder wheelMesh = new Cylinder(16, 16, radius, radius * 0.6f, true);
Node node1 = new Node("wheel 1 node");
Geometry wheels1 = new Geometry("wheel 1", wheelMesh);
node1.attachChild(wheels1);
wheels1.rotate(0, FastMath.HALF_PI, 0);
wheels1.setMaterial(mat);
vehicle.addWheel(node1, new Vector3f(-xOff, yOff, zOff),
wheelDirection, wheelAxle, restLength, radius, true);
Node node2 = new Node("wheel 2 node");
Geometry wheels2 = new Geometry("wheel 2", wheelMesh);
node2.attachChild(wheels2);
wheels2.rotate(0, FastMath.HALF_PI, 0);
wheels2.setMaterial(mat);
vehicle.addWheel(node2, new Vector3f(xOff, yOff, zOff),
wheelDirection, wheelAxle, restLength, radius, true);
Node node3 = new Node("wheel 3 node");
Geometry wheels3 = new Geometry("wheel 3", wheelMesh);
node3.attachChild(wheels3);
wheels3.rotate(0, FastMath.HALF_PI, 0);
wheels3.setMaterial(mat);
vehicle.addWheel(node3, new Vector3f(-xOff, yOff, -zOff),
wheelDirection, wheelAxle, restLength, radius, false);
Node node4 = new Node("wheel 4 node");
Geometry wheels4 = new Geometry("wheel 4", wheelMesh);
node4.attachChild(wheels4);
wheels4.rotate(0, FastMath.HALF_PI, 0);
wheels4.setMaterial(mat);
vehicle.addWheel(node4, new Vector3f(xOff, yOff, -zOff),
wheelDirection, wheelAxle, restLength, radius, false);
vehicleNode.attachChild(node1);
vehicleNode.attachChild(node2);
vehicleNode.attachChild(node3);
vehicleNode.attachChild(node4);
rootNode.attachChild(vehicleNode);
getPhysicsSpace().add(vehicle);
}