2 명이 함께 싸우는 jMonkeyEngine에서 게임을 만들고 있습니다. 이 프로그램이 단순한 신체 부위와의 충돌에 대한 정보를 가져 오길 원합니다. 예를 들어, 캐릭터에게 펀치를 주면 본문 부분에 대한 지식이 프로그램에 있습니다. jMonkey가 skeleton에 대한 정보를 줄 수는 있지만 충돌은 geometry 사이에 있음을 알고 있습니다. 제 아이디어는 객체의 그룹을 문자로 생성하고 jME에서 도형을 얻는 것입니다. 좋은 생각입니까? Blender에서 객체를 만듭니다.jMonkeyEngine - 충돌 한 본문 부분을 얻는 방법
1
A
답변
0
모양이 더 단순한 지오메트리로 대략적인 시도를하고 충돌을 위해 사용할 수 있습니다. 캐릭터의 경우 실린더와 도우미 클래스 BetterCharacterControl
을 사용합니다.
private BetterCharacterControl characterControl;
@Override
public void simpleUpdate(float tpf) {
characterControl.setGravity(planetAppState.getGravity());
// Get current forward and left vectors of model by using its rotation
// to rotate the unit vectors
Vector3f modelForwardDir = characterNode.getWorldRotation().mult(Vector3f.UNIT_Z);
Vector3f modelLeftDir = characterNode.getWorldRotation().mult(Vector3f.UNIT_X);
// WalkDirection is global!
// You *can* make your character fly with this.
walkDirection.set(0, 0, 0);
if (leftStrafe) {
walkDirection.addLocal(modelLeftDir.mult(5));
} else if (rightStrafe) {
walkDirection.addLocal(modelLeftDir.negate().multLocal(5));
}
if (forward) {
walkDirection.addLocal(modelForwardDir.mult(5));
} else if (backward) {
walkDirection.addLocal(modelForwardDir.negate().multLocal(5));
}
characterControl.setWalkDirection(walkDirection);
// ViewDirection is local to characters physics system!
// The final world rotation depends on the gravity and on the state of
// setApplyPhysicsLocal()
if (leftRotate) {
Quaternion rotateL = new Quaternion().fromAngleAxis(FastMath.PI * tpf, Vector3f.UNIT_Y);
rotateL.multLocal(viewDirection);
} else if (rightRotate) {
Quaternion rotateR = new Quaternion().fromAngleAxis(-FastMath.PI * tpf, Vector3f.UNIT_Y);
rotateR.multLocal(viewDirection);
}
characterControl.setViewDirection(viewDirection);
if (walkDirection.length() == 0) {
if (!"Idle".equals(animationChannel.getAnimationName())) {
animationChannel.setAnim("Idle", 1f);
}
} else {
if (!"Walk".equals(animationChannel.getAnimationName())) {
animationChannel.setAnim("Walk", 0.7f);
}
}
}
당신은 collisionshape
private CylinderCollisionShape shape;
를 사용하여 충돌 데이터를 얻을 수 jme3의 도우미 클래스를 사용할 수 있습니다
CollisionResults results = new CollisionResults();
// System.out.println("1 #Collisions between" + ufoNode.getName()
// + " and " + jumpgateSpatial.getName() + ": " + results.size());
ufoNode.collideWith((BoundingBox) jumpgateSpatial.getWorldBound(),
results);
// System.out.println("2 #Collisions between" + ufoNode.getName()
// + " and " + jumpgateSpatial.getName() + ": " + results.size());
CollisionResults results2 = new CollisionResults();
// Use the results
if (results.size() > 0 && playtime > 50000) {
System.out.println("playtime" + playtime);
System.out.println("#Collisions between" + ufoNode.getName()
+ " and " + jumpgateSpatial.getName() + ": "
+ results.size());
// how to react when a collision was detected
CollisionResult closest = results.getClosestCollision();
System.out.println("What was hit? "
+ closest.getGeometry().getName());
System.out
.println("Where was it hit? " + closest.getContactPoint());
System.out.println("Distance? " + closest.getDistance());
ufoControl
.setPhysicsLocation(jumpGateControl2.getPhysicsLocation());
System.out.println("Warped");
} else {
// how to react when no collision occured
}
if (results2.size() > 0) {
System.out.println("Number of Collisions between"
+ ufoNode.getName() + " and " + moon.getName() + ": "
+ results2.size());
// how to react when a collision was detected
CollisionResult closest2 = results2.getClosestCollision();
System.out.println("What was hit? "
+ closest2.getGeometry().getName());
System.out.println("Where was it hit? "
+ closest2.getContactPoint());
System.out.println("Distance? " + closest2.getDistance());
}
관련 문제
- 1. js, location.hash에서 한 부분을 얻는 방법
- 2. jMonkeyEngine 단일 충돌을위한 다중 충돌 이벤트
- 3. jmonkeyengine 움직임이 너무 빨라서 충돌 감지가 발생했습니다.
- 4. 정수 부분을 얻는 방법
- 5. 문자열 부분을 얻는 방법
- 6. BeautifulSoup - 본문 내용을 얻는 방법
- 7. URI의 특정 부분을 얻는 방법
- 8. URL에서 C의 부분을 얻는 방법 #
- 9. NSDate의 초초 부분을 얻는 방법
- 10. JMonkeyEngine- 기하학 교차점 NullPointerException
- 11. 본문 그리기 및 충돌 영역 이동 됨
- 12. SBT를 사용하여 jMonkeyEngine 다운로드
- 13. box2d에서 충돌 위치를 얻는 방법
- 14. Symfony2 경로에서 경로 부분을 얻는 방법
- 15. 일부 게시물의 발췌 부분을 얻는 방법
- 16. 데이터 세트의 나머지 부분을 얻는 방법
- 17. Intellij IDEA에서 JMonkeyEngine 설정
- 18. jMonkeyEngine : 항상 튀는 BetterCharacterControl
- 19. jMonkeyEngine : lwjgl.dll (액세스가 거부되었습니다.)
- 20. JMonkeyEngine with JDK 8
- 21. JmonkeyEngine (JME)에서 스윙하기
- 22. jMonkeyEngine camera follow
- 23. Intellij IDEA의 JMonkeyEngine
- 24. Windows CMD에서 문자열 부분을 얻는 방법
- 25. 문자열의 다른 부분을 확인하고 얻는 방법
- 26. 아약스 응답 첫 부분을 얻는 방법
- 27. perl 해시의 특정 부분을 얻는 방법
- 28. RewriteCond에서 사용할 쿼리의 부분을 얻는 방법
- 29. Java - 문자열의 변경된 부분을 얻는 방법
- 30. 명령 출력의 작은 부분을 얻는 방법