PV3D and WOW Physics Engine basics (papervision3d 와 WOWengine 동력학 의 결합 연구 중 하나)
궁금 한 점 이 있 으 면 QQ: 363596350 로 연락 주세요.
이것 은 제 가 처음으로 WOWengine 동력학 에 대한 학습 입 니 다. 여기 서 정리 하고 결 과 를 먼저 보 겠 습 니 다.
papervision3d 는 WOWengine 와 잘 결합 되 었 습 니 다.
코드 보기:
package {
import flash.events.Event;
import fr.seraf.wow.core.WOWEngine;
import fr.seraf.wow.core.data.WVector;
import fr.seraf.wow.primitive.WBoundArea;
import fr.seraf.wow.primitive.WSphere;
import org.papervision3d.cameras.*;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.view.BasicView;
[SWF(width="640", height="480", frameRate="30", backgroundColor="#333333")]
public class Wow extends BasicView {
private var wow:WOWEngine;
private var wSphere1:WSphere;
private var wSphere2:WSphere;
private var bound:WBoundArea;
private var ball1:Sphere;
private var ball2:Sphere;
private var box:Cube;
public function Wow() {
super(0, 0, true, true, CameraType.TARGET);
init();
}
private function init():void {
camera.x = 0;
camera.y = 0;
camera.z = -400;
camera.focus = 400;
camera.zoom = 1;
createBox();
createBall();
initWow();
startRendering();
}
private function initWow():void {
wow = new WOWEngine(.4);
wow.collisionResponseMode = wow.SELECTIVE;
wow.addMasslessForce(new WVector(1,3,1));
wow.damping=0.98;
wSphere1 = new WSphere(0,0,0,10, false, 1.2, 0.4);
wSphere2 = new WSphere(0,10,0,10, false, 1, 0.3);
wow.addParticle(wSphere1);
wow.addParticle(wSphere2);
bound = new WBoundArea(200,200,200);
bound.setPosition(0,0,0);
bound.elasticity=0.1;
bound.friction=0.01;
wow.setBoundArea(bound);
}
private function createBox():void {
var materials:MaterialsList = new MaterialsList({
all: new WireframeMaterial(0xffffff, 1)
} );
box = new Cube(materials, 200, 200, 200, 2, 2, 2, Cube.ALL, Cube.NONE);
scene.addChild(box);
}
private function createBall():void {
ball1 = new Sphere(new WireframeMaterial(0xff00ff, 1), 10);
ball2 = new Sphere(new WireframeMaterial(0xff00ff, 1), 10);
scene.addChild(ball1);
scene.addChild(ball2);
}
override protected function onRenderTick(event:Event=null):void {
var wVec:WVector = bound.getRotation();
var rx:Number = wVec.x + 1;
var ry:Number = wVec.y + 1;
bound.setRotation(rx,ry,0);
wow.step();
// Set pos ref to wow
box.rotationX = wVec.x;
box.rotationY = wVec.y;
box.rotationZ = 0;
ball1.x = wSphere1.px;
ball1.y = -wSphere1.py;
ball1.z = wSphere1.pz;
ball2.x = wSphere2.px;
ball2.y = -wSphere2.py;
ball2.z = wSphere2.pz;
super.onRenderTick(event);
}
}
}
코드 분석:
근본 적 인 의미 에서 볼 때 WOWengine 는 포 함 된 방식 으로 Papervision3d 에 들 어 갔 을 뿐 자신의 연산 규칙, 자신의 물건 이 고 Papervision3d 의 물 체 를 그 위 에 묶 었 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
lua 해석 url 매개 변수--테스트 url = 'http://192.168.1.113:8080/openG3/m/appPanel.vm?appId=1&appkey=111111&sid=12345,game/js/' res = parseUrl('ht...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.