增强现实中的 3D 模型操作

发布于 2024-10-16 06:01:16 字数 2400 浏览 1 评论 0原文

我正在使用 FLARManager 和 papervision3d 来实现一个小型的增强现实黑客。

我的要求是单击按钮即可偏转模型。

这就是我到目前为止所做的:

public class AugmentedReality extends Sprite
{
    private var flarManager:FLARManager;        
    private var scene:Scene3D;
    private var camera:FLARCamera3D;
    private var viewport:Viewport3D;
    private var renderEngine:LazyRenderEngine;
    private var pointLight:PointLight3D;        
    private var activeMarker:FLARMarker;
    private var model:DAE;
    private var modelContainer:DisplayObject3D;

    public function AugmentedReality()
    {           
        start();
    }

    private function start():void
    {
        flarManager = new FLARManager("../resources/flar/flarConfig.xml");
        addChild(Sprite(flarManager.flarSource));
        flarManager.addEventListener(FLARMarkerEvent.MARKER_ADDED, onMarkerAdded);
        flarManager.addEventListener(FLARMarkerEvent.MARKER_UPDATED, onMarkerUpdated);
        flarManager.addEventListener(FLARMarkerEvent.MARKER_REMOVED, onMarkerRemoved);          
        flarManager.addEventListener(Event.INIT, onFlarManagerInited);
    }

    private function onFlarManagerInited(evt:Event):void
    {
        flarManager.removeEventListener(Event.INIT, onFlarManagerInited);           
        scene = new Scene3D();          
        camera = new FLARCamera3D(flarManager.cameraParams);            
        viewport = new Viewport3D(stage.stageWidth, stage.stageHeight);
        addChild(viewport);
        renderEngine = new LazyRenderEngine(scene, camera, viewport);
        model = new DAE(true, "model", true);
        model.load("../resources/assets/geom.dae");
        model.scale = 30;
        modelContainer = new DisplayObject3D();
        modelContainer.addChild(model);
        modelContainer.visible = false;
        scene.addChild(modelContainer);
        addEventListener(Event.ENTER_FRAME, loop);
    }

循环事件处理程序如下:

    private function loop(evt:Event):void
    {       
        if (activeMarker) {
            modelContainer.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(activeMarker.transformMatrix);
        }
        renderEngine.render();
    }

我有一个按钮的处理程序,如下:

    public function onButtonClicked(event:Event):void
    {
        model.yaw(1);
    }

它似乎根本没有对模型做任何事情...:(

请帮忙!!!! !!!!!!!!!!!!

I'm using FLARManager and papervision3d to implement a small augmented reality hack.

my requirement is to yaw the model upon a button click.

This is what i have done so far:

public class AugmentedReality extends Sprite
{
    private var flarManager:FLARManager;        
    private var scene:Scene3D;
    private var camera:FLARCamera3D;
    private var viewport:Viewport3D;
    private var renderEngine:LazyRenderEngine;
    private var pointLight:PointLight3D;        
    private var activeMarker:FLARMarker;
    private var model:DAE;
    private var modelContainer:DisplayObject3D;

    public function AugmentedReality()
    {           
        start();
    }

    private function start():void
    {
        flarManager = new FLARManager("../resources/flar/flarConfig.xml");
        addChild(Sprite(flarManager.flarSource));
        flarManager.addEventListener(FLARMarkerEvent.MARKER_ADDED, onMarkerAdded);
        flarManager.addEventListener(FLARMarkerEvent.MARKER_UPDATED, onMarkerUpdated);
        flarManager.addEventListener(FLARMarkerEvent.MARKER_REMOVED, onMarkerRemoved);          
        flarManager.addEventListener(Event.INIT, onFlarManagerInited);
    }

    private function onFlarManagerInited(evt:Event):void
    {
        flarManager.removeEventListener(Event.INIT, onFlarManagerInited);           
        scene = new Scene3D();          
        camera = new FLARCamera3D(flarManager.cameraParams);            
        viewport = new Viewport3D(stage.stageWidth, stage.stageHeight);
        addChild(viewport);
        renderEngine = new LazyRenderEngine(scene, camera, viewport);
        model = new DAE(true, "model", true);
        model.load("../resources/assets/geom.dae");
        model.scale = 30;
        modelContainer = new DisplayObject3D();
        modelContainer.addChild(model);
        modelContainer.visible = false;
        scene.addChild(modelContainer);
        addEventListener(Event.ENTER_FRAME, loop);
    }

Loop event handler as follows:

    private function loop(evt:Event):void
    {       
        if (activeMarker) {
            modelContainer.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(activeMarker.transformMatrix);
        }
        renderEngine.render();
    }

I have a handler for a button as follows:

    public function onButtonClicked(event:Event):void
    {
        model.yaw(1);
    }

It doesn't seem to be doing anything to the model at all... :(

PLEASE HELP!!!!!!!!!!!!!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

塔塔猫 2024-10-23 06:01:16

尝试在“循环”或任何内部循环的一侧调用“偏航”。然后您将能够确保“偏航”按预期工作。如果它工作正常,则“onButtonClicked”的签名可能是错误的,或者它没有正确连接。

Try calling 'yaw' in side of 'loop' or whatever your inner loop is. Then you'll be able to make sure 'yaw' is working as expected. If it is working, perhaps the signature of 'onButtonClicked' is wrong or it isn't hooked up properly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文