A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Papervision, restrict camera movment and zoom

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    260

    Post Papervision, restrict camera movment and zoom

    Hello,

    I've started my first AS3 project today and erm.........woah! It's giving me a complete nervous breakdown.

    I've got to do a project with with 3d so have turned to papervision. Basically, I have 5 planes that I want the camera to rotate around but only to a point. When the camera reaches an x value of either -1000 of 1000 the camera movement should stop and not go past that value (but obviously the other way).
    Also, I need to add a function to click one of the planes and it comes to the front and fills the stage (it's aspect ratio will be the same as the stage). The code I'm using the standard Lee Brimlow tutorial code:

    PHP Code:
    import org.papervision3d.scenes.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.cameras.*;
    import org.papervision3d.materials.*;

    // Create the container Sprite
    var container:Sprite = new Sprite();
    container.stage.stageWidth 0.5;
    container.stage.stageHeight 0.5;
    addChild(container);

    // Setup the 3D scene
    var scene:Scene3D = new Scene3D(container);
    var 
    camera:Camera3D = new Camera3D();
    camera.zoom 10;

    // Create the material
    var bam:BitmapAssetMaterial = new BitmapAssetMaterial("cover");
    bam.oneSide false;
    bam.smooth true;

    var 
    bam2:BitmapAssetMaterial = new BitmapAssetMaterial("orange");
    bam2.oneSide false;
    bam2.smooth true;

    var 
    bam3:BitmapAssetMaterial = new BitmapAssetMaterial("blue");
    bam3.oneSide false;
    bam3.smooth true;

    var 
    bam4:BitmapAssetMaterial = new BitmapAssetMaterial("green");
    bam4.oneSide false;
    bam4.smooth true;

    var 
    bam5:BitmapAssetMaterial = new BitmapAssetMaterial("pink");
    bam5.oneSide false;
    bam5.smooth true;

    var 
    p1:Plane = new Plane(bam23430022);
    scene.addChild(p1);
    p1.200;

    var 
    p2:Plane = new Plane(bam223423622);
    scene.addChild(p2);
    p2.= -100;
    p2.500;

    var 
    p3:Plane = new Plane(bam323423622);
    scene.addChild(p3);
    p3.= -500;
    p3.1000;

    var 
    p4:Plane = new Plane(bam423423622);
    scene.addChild(p4);
    p4.= -500;
    p4.100;

    var 
    p5:Plane = new Plane(bam523423622);
    scene.addChild(p5);
    p5.500;
    p5.= -100;

    this.addEventListener(Event.ENTER_FRAMErender);

    function 
    render(e:Event):void
    {
    //psuedocode...
    //if camera.x>-1000 && camera.x <1000
        
    camera.+= (stage.mouseX - (stage.stageWidth*0.5))/50;
        
    scene.renderCamera(camera);

    So basically, the cameras movement is restricted to between -1000 and 1000 and you can click on the planes and zoom into them so they fill the screen.
    Can anyone help me here because I am going into meltdown trying to do this.

    Cheers
    Matt

  2. #2
    Member
    Join Date
    Jan 2007
    Posts
    74
    were you able to get this working? I am trying to do something very similar. Anyone willing to help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center