开发者

PaperVision3D and Flash CS4

I need to develop a cube that contain 10 little cubes and manipulate everyone l开发者_高级运维ike an object..Somebody have any idea or some tutorial for do this on PaperVision3d and Flash CS4..Thanks Folks!!


I think what you actually want is Papervision3d as I know of nothing called "PaperViewer". If that is the case, please update your question.

This should give you an idea of how to start. It creates 10 cubes and stores them in an array. You can access them using boxes[index] to alter their scale, postion and rotation.

package
{
import flash.display.Sprite;
import flash.events.Event;

import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.view.BasicView;

public class Boxes3d extends Sprite
{
    private static const NUM_BOXES:int = 10;

    private var world:BasicView;

    private var boxes:Array;

    public function Boxes3d()
    {
        addEventListener(Event.ADDED_TO_STAGE, addedToStage);
    }

    private function addedToStage(event:Event):void
    {
        // create the world and add it to the stage
        world = new BasicView();
        addChild(world);

        // create a set of boxes
        boxes = [];
        var box:Cube;
        var materials:MaterialsList;
        for(var boxIndex:int = 0; boxIndex < NUM_BOXES; boxIndex++)
        {
            // create a material to cover the cube
            materials = new MaterialsList({
                all: new ColorMaterial(Math.random()*0xFFFFFF) });
            // make a cube
            box = new Cube(materials, 100, 100, 100);
            // spread it out in space
            box.x = Math.random()*500 - 250;
            box.y = Math.random()*500 - 250;
            box.z = Math.random()*500 - 250;
            // add it to the scene
            world.scene.addChild(box);
        }

        // get the world to render each frame
        world.startRendering();

        addEventListener(Event.ENTER_FRAME, positionCamera);
    }

    private function positionCamera(event:Event):void
    {
        var camera:Camera3D = world.cameraAsCamera3D;
        camera.x = -(stage.width/2 - mouseX) * 2;
        camera.y = (stage.height/2 - mouseY) * 2;
    }
}

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜