-
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.x = stage.stageWidth * 0.5;
container.y = 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(bam, 234, 300, 2, 2);
scene.addChild(p1);
p1.x = 200;
var p2:Plane = new Plane(bam2, 234, 236, 2, 2);
scene.addChild(p2);
p2.x = -100;
p2.z = 500;
var p3:Plane = new Plane(bam3, 234, 236, 2, 2);
scene.addChild(p3);
p3.x = -500;
p3.z = 1000;
var p4:Plane = new Plane(bam4, 234, 236, 2, 2);
scene.addChild(p4);
p4.x = -500;
p4.z = 100;
var p5:Plane = new Plane(bam5, 234, 236, 2, 2);
scene.addChild(p5);
p5.x = 500;
p5.z = -100;
this.addEventListener(Event.ENTER_FRAME, render);
function render(e:Event):void
{
//psuedocode...
//if camera.x>-1000 && camera.x <1000
camera.x += (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
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|