[Papervision3D] depth / z rendering not working properly on grid of cubes

Seb Lee-Delisle sebstar55 at gmail.com
Fri May 23 01:29:46 PDT 2008


> Do you have a quick pointer to what I should be looking at in great white
> regarding interactivity?

Of course John Lindquist comes to the rescue...

http://pv3d.org/2008/01/06/7-basic-interactivity/

Seb


>
> Seb Lee-Delisle-2 wrote:
>>
>> Hi Craig,
>> I haven't used MovieScene3D much but I think your problem is that each
>> cube
>> is in its own container, and the average z position of each cube is pretty
>> much going to be identical. A better way to do it would be to use the
>> interactivity built into GreatWhite.
>>
>> Hope this helps!
>>
>> Seb
>>
>>
>> On Thu, May 22, 2008 at 2:00 AM, craig kincaid
>> <craig.kincaid at citrus.com.au>
>> wrote:
>>
>>>
>>> Sorry to bump but does anyone have any ideas, do I have to add all the
>>> cubes
>>> to another object and then rotate that? If so is this a plane or a
>>> sprite.
>>>
>>> Thanks for any help.
>>>
>>>
>>>
>>> craig kincaid wrote:
>>> >
>>> > Hi All,
>>> >
>>> > Trying to learn papervision and building a grid of cubes that you can
>>> > rotate and move the grid (by rotating the camera) the problem lies with
>>> > the cubes 'overlapping' each other in the wrong way.
>>> >
>>> > The easiest way is to view the attached swf
>>> > http://www.nabble.com/file/p17310318/web_eg.swf web_eg.swf . my code is
>>> as
>>> > follows;
>>> >
>>> > [code]
>>> > import org.papervision3d.scenes.*;
>>> > import org.papervision3d.cameras.*;
>>> > import org.papervision3d.objects.*;
>>> > import org.papervision3d.materials.*;
>>> > import caurina.transitions.Tweener;
>>> >
>>> > //container
>>> > var container:Sprite=new Sprite();
>>> > container.x= 800 *0.5
>>> > container.y= 600*0.5;
>>> > addChild(container);
>>> >
>>> > var scene:Scene3D=new MovieScene3D(container);
>>> >
>>> > //camera
>>> > var camera:Camera3D=new Camera3D();
>>> > camera.zoom=2;
>>> > camera.x=camera.y=camera.z=0;
>>> > camera.yaw(180);
>>> > camera.roll(180);
>>> > camera.moveBackward(500);
>>> >
>>> > //dictionary
>>> > var myCubeDictionary:Dictionary=new Dictionary();
>>> > var numOfThumbs:uint = 25
>>> > var thumbWidth:uint = 301
>>> > var thumbHeight:uint = 301
>>> > var thumbDepth = 50
>>> > var numOfRows:uint = 5
>>> > var numOfCols:uint = 5
>>> > var row:uint = 0
>>> > var col:uint = 0
>>> > var Hgap:uint = 20;
>>> > var Vgap:uint = 20;
>>> > var contWidth:uint = (numOfCols*thumbWidth)+((numOfCols)*Hgap)
>>> > var contHeight:uint = (numOfRows*thumbHeight)+((numOfRows)*Vgap)
>>> >
>>> >
>>> > var frontMaterial:ColorMaterial = new ColorMaterial(0xFFFFFF);
>>> > var backMaterial:WireframeMaterial = new WireframeMaterial();
>>> > var leftMaterial:WireframeMaterial = new WireframeMaterial();
>>> > var rightMaterial:WireframeMaterial = new WireframeMaterial();
>>> > var topMaterial:WireframeMaterial = new WireframeMaterial();
>>> > var bottomMaterial:WireframeMaterial = new WireframeMaterial();
>>> >
>>> > var materialsList:MaterialsList = new MaterialsList();
>>> >
>>> > materialsList.addMaterial(frontMaterial, "front");
>>> > materialsList.addMaterial(backMaterial, "back");
>>> > materialsList.addMaterial(leftMaterial, "left");
>>> > materialsList.addMaterial(rightMaterial, "right");
>>> > materialsList.addMaterial(topMaterial, "top");
>>> > materialsList.addMaterial(bottomMaterial, "bottom");
>>> >
>>> > var cube:Cube;
>>> > var globalContainer = [];
>>> > for (var i:uint=0; i<numOfThumbs; i++) {
>>> >       //constructor
>>> >       var p:Cube = new Cube(materialsList, thumbWidth, thumbDepth,
>>> > thumbHeight,4, 4, 4);
>>> >       p.x =
>>> >
>>> (thumbWidth*0.5)-((contWidth*0.5)-((thumbWidth*col)+(Hgap*col)))+(Hgap*0.5)
>>> >       p.y =
>>> >
>>> (thumbHeight*0.5)-((contHeight*0.5)-((thumbHeight*row)+(Vgap*row)))+(Vgap*0.5)
>>> >       p.z = -70
>>> >
>>> >       if(col <=(numOfCols-2)){
>>> >               col += 1
>>> >       }else{
>>> >               col = 0
>>> >               row += 1
>>> >       }
>>> >
>>> >       scene.addChild(p);
>>> >       globalContainer[globalContainer.length] = p;
>>> >       var myCubeContainer:Sprite = p.container;//we use the container
>>> sprite
>>> > property of the Cube
>>> >       myCubeDictionary[myCubeContainer]=p;//here we have container as
>>> key
>>> and
>>> > Cube as value
>>> >       myCubeContainer.buttonMode = true;//we configure a button mode
>>> >       myCubeContainer.addEventListener( MouseEvent.ROLL_OVER,
>>> doRollOver
>>> );
>>> >       myCubeContainer.addEventListener( MouseEvent.ROLL_OUT, doRollOut
>>> );
>>> > }
>>> >
>>> >
>>> > function doRollOver(evt:MouseEvent) {
>>> >       var sprit:Sprite=evt.target as Sprite;
>>> >       sprit.alpha = 0.5;
>>> >       //we use the container sprite to do an alpha change
>>> >       var p:Cube=myCubeDictionary[sprit];
>>> > }
>>> > function doRollOut(evt:MouseEvent) {
>>> >       var sprit:Sprite=evt.target as Sprite;
>>> >       sprit.alpha = 1;
>>> >       //we use the container sprite to do an alpha change
>>> >       var p:Cube=myCubeDictionary[sprit];
>>> > }
>>> >
>>> > this.addEventListener(Event.ENTER_FRAME,render);
>>> > function render(e:Event):void {
>>> >
>>> >       if(container.mouseX > -100 && container.mouseX < 100){
>>> >
>>> >
>>> Tweener.addTween(camera,{x:-container.mouseX,time:2,transition:"easeoutquint"});
>>> >       }
>>> >       if(container.mouseY > -100 && container.mouseY < 100){
>>> >
>>> >
>>> Tweener.addTween(camera,{y:-container.mouseY,time:2,transition:"easeoutquint"});
>>> >       }
>>> >       scene.renderCamera(camera);
>>> > }
>>> > [/code]
>>> >
>>> > The above code is on a frame in a fla and the classpath I am using is
>>> > C:\Papervision3D\as3\trunk\src (doesnt work on greatwhite)
>>> >
>>> > any help would be greatly appreciated.
>>> >
>>> > Cheers
>>> >
>>> > Craig
>>> >
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/depth---z-rendering-not-working-properly-on-grid-of-cubes-tp17310318p17395360.html
>>> Sent from the Papervision3D mailing list archive at Nabble.com.
>>>
>>>
>>> _______________________________________________
>>> Papervision3D mailing list
>>> Papervision3D at osflash.org
>>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>>
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>>
>
> --
> View this message in context: http://www.nabble.com/depth---z-rendering-not-working-properly-on-grid-of-cubes-tp17310318p17415131.html
> Sent from the Papervision3D mailing list archive at Nabble.com.
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>



More information about the Papervision3D mailing list