views:

35

answers:

1

I need to develop a cube that contain 10 little cubes and manipulate everyone like an object..Somebody have any idea or some tutorial for do this on PaperVision3d and Flash CS4..Thanks Folks!!

+1  A: 

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;
    }
}

}
James Fassett
Sorry James Fassett, i wanna say PaperViewer... i don't know why i said that..
Rbn
Thanks man..! But, i can't manipulate the size of each cube inside..i need to put just 10 boxes and fill the big cube...
Rbn
You can either set the scale of the cube when you create it (the 100 is the size) of manipulate the scale, scaleX, scaleY or scaleZ properties. What do you mean you need 10 boxes to fill the big cube? Where are they positioned relative to the cube?
James Fassett
It will be a matrix of ten x ten cubes, of this way will be a big cube of 100 little cubes...10 rows of ten cubes and 10 columns of ten cubes for each side..like this: http://3.bp.blogspot.com/_sE6R9uEBwnA/R4Zc3ZpBLWI/AAAAAAAAAEE/FDLJRVlXlvI/s320/cubo_rubik.jpg BUT with ten cubes for each side.
Rbn
My code should get you 90% of the way there. You need to increase the number of cubes and calculate the positions of the cubes on each wall. If you want me to write the whole thing for you I can send you my company details and we can work out a price.
James Fassett