2011-03-23 3 views
0

나는 flartoolkit으로 일부 증강 현실 프로젝트를 수행하려고합니다. 이제는 간단한 3D 개체를 내 마커에 넣을 수는 있지만 잘 작동하지만 사용자가 상호 작용할 수있는 몇 가지 이벤트를 프로젝트에 제공하고 싶습니다. 마커의 회전을 추적하려고합니다. 컨테이너가 있습니다 : DisplayObject3D 내 응용 프로그램에서 3D 객체를 추가하는 데 사용하는 DisplayObject3D는 "trace (container.rotationZ)"를 추적했지만 단지 0을 반환합니다. 다른 AR 응용 프로그램의 소스 코드를 연구했고 문제없이 컨테이너 객체를 회전 시켰습니다. lynda.com에서 seb lee delisle papervision3d 과정의 연습 파일을 사용하고 있다고 언급해야합니다. 누구나 flartoolkit에 대한 경험이 있습니까? 내 내 코드의 주요 기능은 다음과 같습니다 :
증강 현실 flartoolkit 순환

public function AR_AlchemyBase() 
{ 
    super(640,480, false); 
    cameraParams = FLARParam.getDefaultParam(WIDTH * 0.5, HEIGHT * 0.5); 

    marker = new FLARCode(16, 16); 
    marker.loadARPattFromFile(new MarkerPattern()); 

    init(); 
} 

public function init():void 
{   
    video = new Video(WIDTH, HEIGHT); 
    webCam = Camera.getCamera(); 
    webCam.setMode(WIDTH, HEIGHT, 30); 
    video.attachCamera(webCam); 
    video.smoothing = true; 

    camBitmapData = new BitmapData(WIDTH *0.5, HEIGHT * 0.5,false, 0x000000); 

    camBitmap = new Bitmap(camBitmapData); 
    camBitmap.scaleX = camBitmap.scaleY = 2; 
    addChildAt(camBitmap,0); 

    raster = new FLARRgbRaster(WIDTH *0.5, HEIGHT * 0.5); 
    detector = new FLARSingleMarkerDetector(cameraParams, marker, 80); 
    result = new FLARTransMatResult(); 

    viewport.x = -4; 

    _camera = new FLARCamera3D(cameraParams); 
    container = new FLARMarkerNode(); 
    scene.addChild(container); 

    addSceneObjects(); 

    stage.addEventListener(Event.ENTER_FRAME, enterFrame); 
} 

//the function to put our objects in 
public function addSceneObjects() : void 
{ 

    var wmat:WireframeMaterial = new WireframeMaterial(0xff0000, 1, 2); 
    wmat.doubleSided = true; 

    var plane : Plane = new Plane(wmat, 80, 80); 
    container.addChild(plane); 

    var light:PointLight3D = new PointLight3D(); 
    light.x = 1000; 
    light.y = 1000; 
    light.z = -1000; 

    var fmat:FlatShadeMaterial = new FlatShadeMaterial(light, 0xff22aa, 0x0); 
    var cube : Cube = new Cube(new MaterialsList({all: fmat}), 40, 40, 40); 
    cube.z = -20; 
    container.addChild(cube);   
} 

public function enterFrame(e:Event):void 
{ 
    var scaleMatrix:Matrix = new Matrix(); 
    scaleMatrix.scale(0.5, 0.5); 
    camBitmapData.draw(video, scaleMatrix); 

    raster.setBitmapData(camBitmapData); 

    counter++; 

    if(counter == 3) counter = 0; 

    var imageFound : Boolean = false 

    currentThreshold = threshold+ (((counter%3)-1)*thresholdVariance); 
    currentThreshold = (currentThreshold>255) ? 255 : (currentThreshold<0) ? 0 : currentThreshold; 

    imageFound = (detector.detectMarkerLite(raster, currentThreshold) && detector.getConfidence() > 0.5) ; 

    if(imageFound) 
    { 
     detector.getTransformMatrix(result); 
     container.setTransformMatrix(result); 
     container.visible = true; 

     threshold = currentThreshold; 
     thresholdVariance = 0; 

     if(onImageFound!=null) onImageFound(); 
    } 
    else 
    { 
     if(counter==2) thresholdVariance +=2; 

     if(thresholdVariance>128) thresholdVariance = 1; 

     if(onImageLost!=null) onImageLost(); 

    } 

    singleRender(); 
} 

답변

1

내가 주요 문제에 도움이되지 않을 수 있습니다하지만 당신은 사용자가 대화 형으로 자신의 자료를 설정하는 데 필요한 모델과 상호 작용하려면, 그렇지 않으면 마우스 이벤트를받지 못합니다. 회전에 관해서 ... 나는 뭔가를 놓치고 있을지 모르지만 그것은 컨테이너 자체가 아닌 회전을 적용하는 컨테이너 내부의 인스턴스입니까? PV3D Tutorial for basic interactivity

:

실행 간단한 PV3D 예를지고 나를 도와