Home | Flex examples | 3d engines | PaperVision | PaperVision getting started. Рисуем примитив куб.

PaperVision getting started. Рисуем примитив куб.

Font size: Decrease font Enlarge font
image

Делаем примитив на papervision, cube

Papervision - 3d движок.
Несколько сайтов - http://blog.papervision3d.org/ (здесь можно скачать исходники и много всякой полезной информации)
http://pv3d.org/ - интересный сайт с примерами и уроками.

Класс, который рисует вращающийся куб:

package
{
    import flash.display.Bitmap;
    import flash.events.Event;
   
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.materials.utils.MaterialsList;
    import org.papervision3d.objects.primitives.Cube;
    import org.papervision3d.view.BasicView;
 
    [SWF(width="300", height="300", backgroundColor="#000000", frameRate="60")]
    public class index extends BasicView
    {
        private var cube:Cube;
 
        public function index()  
        {
            var materials:MaterialsList = new MaterialsList(
            {
            front: new ColorMaterial(0xc71dd6, 1),
            back: new ColorMaterial(0x1d8ad6, 1),
            right: new ColorMaterial(0xd63c1d, 1),
            left: new ColorMaterial(0x63d61d, 1),
            top: new ColorMaterial(0x1d40d6, 1),
            bottom: new ColorMaterial(0xFFFFFF, 1)
            } );
           
            cube = new Cube(materials, 200, 400, 200);
            scene.addChild(cube);
            startRendering();
        }
 
        override protected function onRenderTick(event:Event=null):void
        {
            if(this.mouseX > 150)
            {
                cube.rotationX += 1;
                cube.rotationY += 0.5;
            }else{
                cube.rotationX -= 1;
                cube.rotationY -= 0.5;
            }

            if(this.mouseY > 150)
            {
                cube.rotationX -= 1;
                cube.rotationY += 0.5;
            }else{
                cube.rotationX += 1;
                cube.rotationY -= 0.5;
            }
            renderer.renderScene(scene, camera, viewport);
        }
    }
}

Исходники - source, приложение - application

Comments ( posted):

Post your comment comment

Please enter the code you see in the image:

  • email Email to a friend
  • print Print version
  • Plain text Plain text
Tags
No tags for this article
Rate this article
0