본문 바로가기
Three.js

Three.js-collision and bullet engine, ammo -part1

by ses jeon 2019. 10. 15.

The bullet engine is known a lot as the c ++ physics engine. It's a fairly well known engine and there's a wrapper around java, and there's also a porting of this engine to javascript. Ammo.js.

bullet engine은 c++ 물리 엔진으로 많이 알려졌습니다. 꽤나 많이 알려진 엔진이고 java로의 wrapper도 존재하는데, 이 엔진을 javascript로 porting한것도 존재합니다. 바로 ammo.js 입니다.

https://github.com/kripken/ammo.js/

 

kripken/ammo.js

Direct port of the Bullet physics engine to JavaScript using Emscripten - kripken/ammo.js

github.com

This engine enables a dynamic world implementation. Basic is like that. Not all bullet engine functions are available, but porting is most common.

이 엔진으로 dynamic world 구현이 가능합니다. 기본이 그렇습니다. 모든 bullet engine 기능을 다 할수 있는건 아니고, 가장 많이 쓰는 형태로 porting 되어 있습니다.

 

add ammo.js,

If you use ammo.js as it is large, you will get an error. So we use jQuery's then to start the beginning.

ammo.js를 추가하고,

 

ammo.js가 사이즈가 커서인지 바로 사용을 하면 에러가 난다. 그래서 jQuery의 then을 써서 시작부를 시작한다.

launcher

Now let's see if we can use the bullet engine.
Put your test code in mainPage.

자 이제 우리가 bullet engine을 이용할수 있는지 확인해봅시다.

mainPage에 테스트 코드를 넣습니다.

The output is as follows:

다음같이 출력됩니다.

The console in javascript is very powerful. If you take a variable, you can take a picture inside.
You will see that you write testV1.x () instead of expressing testV1.x. You can see that by looking at the contents of the above variable. You know what's going on. When coding for the first time, I hope you print it like this and judge.

The javascript implementation of the bullet engine, originally C ++, may look a bit different. An overview of how this is expressed can be found by looking at the ammo.idl file in the ammo.js-mater file downloaded from the Ammo site.

javascript의 console은 굉장히 강력합니다. 변수를 찍으면 바로 안의 내용을 찍을수 있죠.

testV1.x 라고 표현하지 않고, testV1.x() 라고 쓴걸 보실겁니다. 그걸 위의 변수 내용을 보고 알수 있죠. 구현이 어떻게 된지 알수 있다는 겁니다. 앞으로 코딩을 하실때 처음 접하실 때는 이런 식으로 출력해보고 판단을 하시길 바랍니다.

 

원래 C++인 bullet engine의 javascript 구현은 조금 다르게 보일수도 있습니다. 어떤식으로 표현되었는지 전체적인 개략은 Ammo 사이트에서 다운받으신 ammo.js-mater 파일에서 ammo.idl 파일을 보면 감을 잡을수 있습니다.

Like this

이런식으로 

You can see it is implemented as btVector3.

btVector3 이라는 이름으로 구현된걸 보실수 있습니다.

 

===========================================================================

 

 

About Bullet Physics Engine
If you are new to the bullet engine, you will need to explain the bullet physics engine itself and find a reference.

Bullet Physics Engine에 대해서

불릿 엔진을 처음 접하실때는, 불릿 물리 엔진 자체에 대한 내용도 설명을 들어야하고, 레퍼런스도 찾아야할 겁니다.

https://pybullet.org/Bullet/BulletFull/

 

Bullet Collision Detection & Physics Library: Bullet Documentation

Introduction Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ). The main documentation is Bullet_User_Manual.p

pybullet.org

This is the homepage of the bullet engine implemented in C ++. Let's look at the content as a whole or find out if there is a related method.

And the textbook I did not find a good javascript textbook. However, there is a step by step tutorial on the bullet engine ported to java.

C++로 구현된 bullet engine의 홈페이지입니다. 내용을 전체적으로 보거나, 관련 메서드가 있는지 찾을때 확인해봅시다.

 

그리고 교재는 제가 javascript 좋은 교재는 찾지는 못했습니다. 하지만 java에 포팅된 bullet engine에 대한 step by step 교재는 있습니다.

https://xoppa.github.io/blog/using-the-libgdx-3d-physics-bullet-wrapper-part1/

 

Using the libGDX 3D physics Bullet wrapper - part1 | blog.xoppa.com

Many 3D games require some sort of collision detection between 3D objects. Sometimes it's possible to do this with some basic math and bounding boxes and...

xoppa.github.io

LibGdx is a java language based game engine that supports Android / iOS multiplatform. The bullet engine implementation in LibGdx is explained in great detail, step by step. Simply install and follow LibGdx and we recommend you go to the next chapter. Please see my blog LibGdx part about LibGdx.

If you are unfamiliar with the engine, I recommend taking a look at the first part of this blog. The content is really good. You will also know the implementation algorithm for mouse picking.

LibGdx는 Android/iOS 멀티 플렛폼을 지원해주는 java 언어 기반의 게임엔진입니다. LibGdx에서의 bullet engine 구현을 step by step으로 아주 상세히 설명되어있습니다. 간단히 LibGdx를 설치하고 따라해보시고, 다음 장으로 가길 추천해드립니다. LibGdx에 대해서는 저의 블로그 LibGdx 파트를 봐주세요.

 

엔진에 대해 너무 생소하다면 이 블로그의 1번장부터 천천히 보시길을 추천드립니다. 글 내용이 정말 좋습니다. 마우스 픽킹에 대한 구현 알고리즘도 아실수 있습니다. 

basicStructure3.zip
4.95MB

 

 

 

 

 

 

'Three.js' 카테고리의 다른 글

Three.js-collision, bullet engine, ammo -part3  (0) 2019.10.22
Three.js-collision, bullet engine, ammo -part2  (0) 2019.10.22
Three.js - Animation system  (0) 2019.10.15
Three.js-key event  (0) 2019.10.10
Three.js-move page, loading  (0) 2019.10.01

댓글