当前位置: 首页>>代码示例>>Java>>正文


Java BulletAppState类代码示例

本文整理汇总了Java中com.jme3.bullet.BulletAppState的典型用法代码示例。如果您正苦于以下问题:Java BulletAppState类的具体用法?Java BulletAppState怎么用?Java BulletAppState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BulletAppState类属于com.jme3.bullet包,在下文中一共展示了BulletAppState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PlayerManager

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
/**
 * Constructor for the client.
 * @param app Game application.
 * @param coursePath Course path the players follow.
 * @param bullet Bullet app state with which to create player physics.
 * @param totalPlayers Total number of players in game.
 * @param localPlayerIdx Order of client player starting at 0.
 */
public PlayerManager(SimpleApplication app, CoursePath coursePath,
                     BulletAppState bullet, int totalPlayers,
                     int localPlayerIdx) {
  this.application = app;
  this.coursePath = coursePath;
  this.bullet = bullet;
  this.players = new Spatial[totalPlayers];
  for (int i = 0; i < totalPlayers; ++i) {
    Spatial player = createPlayer(this.application.getRootNode(), i);
    this.players[i] = player;
    if (i == localPlayerIdx) {
      this.localPlayer = player;
    }
  }
  positionPlayers(players);
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:25,代码来源:PlayerManager.java

示例2: simpleInitApp

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
@Override
public void simpleInitApp() {
  /** Set up Physics Game */
  bulletAppState = new BulletAppState();
  stateManager.attach(bulletAppState);
  /** Configure cam to look at scene */
  cam.setLocation(new Vector3f(0, 6f, 6f));
  cam.lookAt(Vector3f.ZERO, new Vector3f(0, 1, 0));
  cam.setFrustumFar(15);
  /** Add InputManager action: Left click triggers shooting. */
  inputManager.addMapping("shoot", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
  inputManager.addListener(actionListener, "shoot");
  /** Initialize the scene, materials, and physics space */
  initMaterials();
  initWall();
  initFloor();
  initCrossHairs();
  initShadows();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:20,代码来源:HelloPhysics.java

示例3: simpleInitApp

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
    stateManager.attach(bulletAppState);
    setupKeys();
    prepareBullet();
    prepareEffect();
    createLight();
    createSky();
    createTerrain();
    createWall();
    createCharacter();
    setupChaseCamera();
    setupAnimationController();
    setupFilter();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:TestWalkingChar.java

示例4: simpleInitApp

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
@Override
public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bullet = new Sphere(32, 32, 0.4f, true, false);
    bullet.setTextureMode(TextureMode.Projected);
    bulletCollisionShape = new SphereCollisionShape(0.4f);
    PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager, bulletAppState.getPhysicsSpace());

    setupKeys();

    // Add a physics character to the world
    physicsCharacter = new CharacterControl(new CapsuleCollisionShape(0.5f,1.8f), .1f);
    physicsCharacter.setPhysicsLocation(new Vector3f(3, 6, 0));

    Spatial model = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
    model.scale(0.25f);
    model.addControl(physicsCharacter);
    getPhysicsSpace().add(physicsCharacter);
    rootNode.attachChild(model);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:TestPhysicsCharacter.java

示例5: makeFloor

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
public static void makeFloor(SimpleApplication app) {    	
      Box box=new Box(160,.2f,160);
      Geometry floor=new Geometry("the Floor",box);
      floor.setLocalTranslation(0,-4f,0);
      Material mat1=new Material(app.getAssetManager(),"Common/MatDefs/Light/Lighting.j3md");
      mat1.setColor("Diffuse",new ColorRGBA(.54f,.68f,.16f,1f));
      mat1.setBoolean("UseMaterialColors",true);
      floor.setMaterial(mat1);
      
      CollisionShape floorcs=new MeshCollisionShape(floor.getMesh());
RigidBodyControl floor_phy=new RigidBodyControl(floorcs,0);
floor.addControl(floor_phy);
floor_phy.setPhysicsLocation(new Vector3f(0,-30,0));		
app.getStateManager().getState(BulletAppState.class).getPhysicsSpace().add(floor_phy);		
app.getRootNode().attachChild(floor);			
  }
 
开发者ID:riccardobl,项目名称:jme3-bullet-vhacd,代码行数:17,代码来源:Commons.java

示例6: initialize

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
/**
 * Creates a new Forester object.
 * 
 * @param rootNode The rootNode of the scene.
 * @param camera The camera.
 * @param terrain A terrain object.
 * @param app The application.
 */
synchronized
public void initialize(Node rootNode, Camera camera, Terrain terrain, Application app)
{
    this.rootNode = rootNode;
    this.camera = camera;
    this.terrain = terrain;
    this.app = app;
    BulletAppState bas = app.getStateManager().getState(BulletAppState.class);
    if(bas == null){
        log.log(Level.INFO,"No BulletAppState found, physics is disabled.");
    } else {
        physicsSpace = bas.getPhysicsSpace();
        physicsEnabled = true;
    }
    list = new ArrayList<TileLoader>(2);
}
 
开发者ID:shamanDevel,项目名称:ProceduralTerrain,代码行数:25,代码来源:Forester.java

示例7: ShipWeaponControl

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
public ShipWeaponControl(SimpleApplication asm, Node ship) {
    
    shipNode = ship;
    this.asm = asm;
    
     shape = new BoxCollisionShape(new Vector3f(0.15f, 0.15f, 0.5f));
     bullets = new Node("bullets");
     bulletTimer = 0f;
     fire = false;
    
    // Setup Bullet
    Box b = new Box(Vector3f.ZERO, 0.15f, 0.15f, 0.5f);
    bullet = new Geometry("Box", b);
    Material mat_bullet = new Material(asm.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat_bullet.setColor("Color", ColorRGBA.Red);
    bullet.setMaterial(mat_bullet);
    
    this.asm.getRootNode().attachChild(bullets);
            // add ourselves as collision listener
    
    bulletApp = asm.getStateManager().getState(BulletAppState.class);
    
    bulletApp.getPhysicsSpace().addCollisionListener(this);
    
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:26,代码来源:ShipWeaponControl.java

示例8: PlayerControl

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
public PlayerControl(Camera cam, Node ship, BulletAppState bulletAppState,
        AssetManager assetManager, SimpleApplication asm) {

    this.cam = cam;
    this.ship = ship;
    this.bulletAppState = bulletAppState;
    this.assetManager = assetManager;
    this.asm = asm;

    setShip();

    shipControl.setMoveSpeed(60f);
    rotateSpeed = 150f;

    weaponControl = new ShipWeaponControl(asm, ship);
    ship.addControl(weaponControl);

}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:19,代码来源:PlayerControl.java

示例9: SimpleCharacterControl

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
public SimpleCharacterControl(Application app, float centerToBottomHeight, CollisionShape colShape, float mass) {
    super(colShape, mass);
    
    this.app = app;

    jumpSpeedY = 40f;
    moveSpeed = 0.5f;
    moveSpeedMultiplier = 1;
    moveSlopeSpeed = 0.3f;
    slopeLimitAngle = FastMath.DEG_TO_RAD * 45f;
    stopDamping = 0.8f;
    
    stopTimer = 0;
    jumpTimer = 0;
    maxStopTimer = 30;
    maxJumpTimer = 20;
    
    frictionWalk = 0.1f;
    frictionStop = 7f;
    mainWalkInterpolation = 0.7f;
    otherWalkInterpolation = 0.9f;
    
    this.centerToBottomHeight = centerToBottomHeight;

    this.app.getStateManager().getState(BulletAppState.class).getPhysicsSpace().addTickListener(this);
}
 
开发者ID:mifth,项目名称:JME-Simple-Examples,代码行数:27,代码来源:SimpleCharacterControl.java

示例10: testConstraints

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
@Test
	@Ignore
	public void testConstraints(){
//		boolean headless=false;
		SimpleApplication app=TestHelpers.buildApp(headless);
		BulletAppState bullet=TestHelpers.buildBullet(app,true);

		TestHelpers.hijackUpdateThread(app);
		XbufKey key=new XbufKey("unit_tests/xbuf/constraints.xbuf").usePhysics(true).useEnhancedRigidbodies(true);
		Spatial scene=app.getAssetManager().loadModel(key);
		app.getRootNode().attachChild(scene);
		scene.setLocalTranslation(0,-10,0);
		XbufPhysicsLoader.load(key,scene,bullet.getPhysicsSpace());

		int i=0;
		Collection<PhysicsJoint> joints=bullet.getPhysicsSpace().getJointList();
		for(PhysicsJoint joint:joints){
			System.out.println(joint);
			i++;
		}
		assertTrue("Found "+i+" constraints, 1 expected",i==1);

		TestHelpers.releaseUpdateThread(app);
		if(!headless)TestHelpers.waitFor(app);
		TestHelpers.closeApp(app);
	}
 
开发者ID:xbuf,项目名称:jme3_xbuf,代码行数:27,代码来源:UnitTests.java

示例11: initialize

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
@Override
public void initialize(AppStateManager stateManager, Application app) {
    super.initialize(stateManager, app);
    this.app = (SimpleApplication) app;
    // multiplayer, so, it should not pause on lost focus
    this.app.setPauseOnLostFocus(false);
    // use physics
    BulletAppState bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    this.app.getRootNode().attachChild(app.getAssetManager().loadModel("Scenes/Scene01.j3o"));
    for(Spatial spatial : this.app.getRootNode().getChildren()) {
        System.out.println("Root children: " + spatial.getName());
    }
    // disable flycam
    this.app.getFlyByCamera().setEnabled(false);
    scene = (Node) this.app.getRootNode().getChild("Scene01");
    terrainNode = (Node) ((Node) scene).getChild("terrainNode");
    terrainNode.addControl(new RigidBodyControl(0.0f));
    bulletAppState.getPhysicsSpace().add(terrainNode);
    // PlayerAppState to initialize player
    stateManager.attach(new PlayerAppState());
    // NpcAppState to initialize npc
    stateManager.attach(new NpcAppState());
}
 
开发者ID:duodecimo,项目名称:magicallyous,代码行数:25,代码来源:MagicallyousAppState.java

示例12: simpleInitApp

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
public void simpleInitApp() {
    // Clear the debug display info
    setDisplayStatView(false); setDisplayFps(false);
    
    // Set up all app states and attach them
    startAppState = new GuiAppState();     //gui menu
    stateManager.attach(startAppState);
    
    bulletAppState = new BulletAppState(); //physics
    stateManager.attach(bulletAppState);
    
    playAppState = new PlayAppState();     //game play
    stateManager.attach(playAppState);
    
    viewPort.setBackgroundColor(new ColorRGBA(0.7f,0.8f,1f,1f));
}
 
开发者ID:utsav2601,项目名称:MinionVsAlien-3D-game,代码行数:17,代码来源:MinionVsAlienProject.java

示例13: levelShown

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
/**
 * Notification that the level has been added to the viewport.
 *
 * @param manager the manager to use for loading .
 * @param state the physics simulation object.
 */
public void levelShown(AssetManager manager, BulletAppState state) {
    this.manager = manager;

    if (this.createDefaultLights) {
        this.createLights(manager);
        createDefaultLights = false;
    }

    physicsLayer.setBulletAppState(state);

    // find lights that have shadow enabled and activate
    // them.
    List<DirectionalLightPrefab> dirLights = this.descendantMatches(DirectionalLightPrefab.class);
    for (DirectionalLightPrefab dl : dirLights) {
        if (dl.getCastShadow()) {
            ShadowEvent se = new ShadowEvent(dl);
            GlobalObjects.getInstance().postEvent(se);
        }
    }
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:27,代码来源:Level.java

示例14: addToScene

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
public void addToScene() {
    clearSelection();

    for (Spatial p : insertionElements.getChildren()) {
        addToSelection((Node) p);
        sceneElements.attachChild(p);
        if (p instanceof Prefab) {
            Prefab prefab = (Prefab) p;
            //prefab.connect(sceneElements);
            BulletAppState bas = this.stateManager.getState(BulletAppState.class);
            prefab.addPhysics(bas.getPhysicsSpace());
        }

        AddPrefabEdit edit = new AddPrefabEdit((Node) p);
        GlobalObjects.getInstance().addEdit(edit);

        LevelEvent le = new LevelEvent(this.level, LevelEvent.EventType.NODEADDED, (Node) p);
        GlobalObjects.getInstance().postEvent(le);

    }
    insertionElements.detachAllChildren();
    editorState = EditorState.IDLE;
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:24,代码来源:SandboxViewport.java

示例15: removeNode

import com.jme3.bullet.BulletAppState; //导入依赖的package包/类
private void removeNode(dae.project.Level level, Node n) {
    if (n instanceof Prefab) {
        Prefab p = (Prefab) n;
        // remove the physics
        BulletAppState bas = this.stateManager.getState(BulletAppState.class);
        bas.getPhysicsSpace().removeAll(p);
        ProjectTreeNode parent = p.getProjectParent();
        if (parent != null) {
            int childIndex = parent.getIndexOfChild(p);
            GlobalObjects.getInstance().addEdit(new DeletePrefabEdit(this.level, n));
            n.removeFromParent();
            LevelEvent le = LevelEvent.createNodeRemovedEvent(level, n, parent, childIndex);
            GlobalObjects.getInstance().postEvent(le);

        }

    }
}
 
开发者ID:samynk,项目名称:DArtE,代码行数:19,代码来源:SandboxViewport.java


注:本文中的com.jme3.bullet.BulletAppState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。