[Papervision3D] how to make cube rotate to right selected area?
Quang Dang
qpixelz at gmail.com
Fri Feb 15 12:02:35 PST 2008
Hi,
I have that error saying "draw" is not a function: TypeError: Error #1006:
draw is not a function.It looks like I can't convert a bitmapFileMaterial
into movieclip type.
Here's my code:
private function _initXML():void
{
this.loader = new LoadXML("xml/images.xml", _onDisplayCube);
}
public function _onDisplayCube(evt:Event):void
{
var bitmapFile:BitmapFileMaterial;
for each(var xmlnode:XML in new XML(evt.target.data).images)
{
bitmapFile = new BitmapFileMaterial(xmlnode.item);
for each (var item:Object in this.tabCubeArea)
{
item.mc = new MovieClip();
item.mc.draw(bitmapFile.bitmap);
var movieMaterial:MovieMaterial = new MovieMaterial(item.mc, false,
true, false);
movieMaterial.interactive = true;
// Add material
this.material.addMaterial(movieMaterial, item.view);
}
}
this.cube = new Cube(this.material, CUBE_SIZE, CUBE_SIZE, CUBE_SIZE,
CUBE_QUALITY, CUBE_QUALITY, CUBE_QUALITY);
this.scene.addChild(this.cube, 'myCube');
}
On Sat, Feb 9, 2008 at 5:26 PM, Justin Lawerance Mills <JLM at justinfront.net>
wrote:
> something like
>
> // loop this every frame
> function grabLoadedMaterial(){
> if( myBitmapFileMaterial.loaded){mc.draw( myBitmapFileMaterial.bitmap );
> _root.addChild(mc);
> removeEventListener(event.ENTER_FRAME, 'grabLoadedMaterial');
> }
> }
> ?
>
> On 9 Feb 2008, at 16:39, Quang Dang wrote:
>
> Does anyone is there a way to convert a bitmapFileMaterial into movieclip?
>
>
> On Feb 8, 2008 10:58 PM, Quang Dang <qpixelz at gmail.com> wrote:
>
> > Hi Francisco,
> > this is a great example.
> >
> > Instead of using: (which are movieclips)
> >
> > o.mc.graphics.beginFill( Math.random() * 0xFFFFFF );
> > o.mc.graphics.drawRect( 0, 0, 100, 100 );
> > o.mc.graphics.endFill();
> >
> > Is that way to add some BitmapFileMaterial external (.jpg)?
> >
> > For example:
> > var bitmapFile:BitmapFileMaterial = new
> > BitmapFileMaterial("images/img_01.jpg");
> >
> > how to make it recognize as movieclip?
> >
> >
> > On Feb 8, 2008 5:37 PM, Francisco Murillo <fmurillo at gmail.com> wrote:
> >
> > > try this, just have to know the camera positions... and download
> > > Tweener..
> > >
> > > sorry this is not completely what you said..... but you can get the
> > > idea..
> > >
> > > package {
> > > import flash.display.MovieClip;
> > > import flash.display.Sprite;
> > > import flash.events.Event;
> > > import flash.events.MouseEvent;
> > > import flash.text.TextField;
> > >
> > > import org.papervision3d.cameras.FreeCamera3D;
> > > import org.papervision3d.core.render.data.RenderHitData;
> > > import org.papervision3d.materials.MovieMaterial;
> > > import org.papervision3d.materials.utils.MaterialsList;
> > > import org.papervision3d.objects.primitives.Cube;
> > > import org.papervision3d.render.BasicRenderEngine;
> > > import org.papervision3d.scenes.Scene3D;
> > > import org.papervision3d.view.Viewport3D;
> > > import caurina.transitions.Tweener;
> > >
> > > //[SWF(width = "60", height = "480")];
> > > public class InteractiveCube extends Sprite {
> > > private var viewport:Viewport3D;
> > > private var scene:Scene3D;
> > > private var camera:FreeCamera3D;
> > >
> > > private var renderer:BasicRenderEngine;
> > >
> > > private var cube:Cube;
> > >
> > > private var frontMovieClip:MovieClip;
> > > private var backMovieClip:MovieClip;
> > > private var leftMovieClip:MovieClip;
> > > private var rightMovieClip:MovieClip;
> > > private var topMovieClip:MovieClip;
> > > private var bottomMovieClip:MovieClip;
> > >
> > > private var movieClips:Array = [
> > > { name: "front", mc: frontMovieClip },
> > > { name: "back", mc: backMovieClip },
> > > { name: "left", mc: leftMovieClip },
> > > { name: "right", mc: rightMovieClip },
> > > { name: "top", mc: topMovieClip },
> > > { name: "bottom", mc: bottomMovieClip }
> > > ];
> > >
> > > private var materialsList:MaterialsList;
> > >
> > > public function InteractiveCube() {
> > > init();
> > > }
> > > private function init():void {
> > > initPv3d();
> > > createMaterials();
> > > createObjects();
> > > addListeners();
> > > }
> > > private function initPv3d():void {
> > > viewport = new Viewport3D( 640, 480, false, true );
> > > addChild( viewport );
> > >
> > > scene = new Scene3D();
> > > camera = new FreeCamera3D();
> > >
> > > renderer = new BasicRenderEngine();
> > > }
> > > private function createMaterials():void {
> > > materialsList = new MaterialsList();
> > >
> > > for each (var o:Object in movieClips) {
> > > o.mc = new MovieClip();
> > > o.mc.name = o.name;
> > >
> > > o.mc.graphics.beginFill( Math.random() * 0xFFFFFF );
> > > o.mc.graphics.drawRect( 0, 0, 100, 100 );
> > > o.mc.graphics.endFill();
> > >
> > > //var t:TextField = new TextField();
> > > //t.text = o.name;
> > >
> > > //o.mc.addChild( t );
> > >
> > > var movieMaterial:MovieMaterial = new MovieMaterial(
> > > o.mc, false, true, false );
> > > movieMaterial.interactive = true;
> > >
> > > materialsList.addMaterial( movieMaterial, o.name );
> > > }
> > > }
> > > private function createObjects():void {
> > > cube = new Cube( materialsList, 700, 700, 700, 4, 4, 4 );
> > >
> > > scene.addChild( cube, "cube" );
> > >
> > > }
> > > private function addListeners():void {
> > > for each (var o:Object in movieClips) {
> > > o.mc.addEventListener( MouseEvent.MOUSE_DOWN,
> > > onMouseDown );
> > > }
> > > addEventListener( Event.ENTER_FRAME, onEnterFrame );
> > > }
> > > private function onMouseDown( e:MouseEvent ):void {
> > > var mc:MovieClip = e.currentTarget as MovieClip;
> > > trace( mc.name );
> > > trace( camera );
> > > //_level0.onEnterFrame = _level0.loop2;
> > > //Tweener.addTween(camera,{x:0, y:0, z:-4000, time:1,
> > > transition:"easeOutCirc"});
> > > Tweener.addTween(cube,{rotationX:80, rotationY:180,
> > > rotationZ:300, z:500, x:200, y, time:1, transition:"easeOutCirc"});
> > >
> > > }
> > > private function onEnterFrame( e:Event ):void {
> > > //cube.yaw( 4 );
> > > ///cube.pitch( 6 );
> > > cube.rotationY += (275 - stage.mouseX) / 100;
> > > cube.rotationZ += (275 - stage.mouseY) / 100;
> > > //-
> > > camera.x -= (camera.x-(stage.mouseX*2))/8;
> > > camera.y -= (camera.y-(stage.mouseY*2))/8;
> > >
> > > //camera.z -= ((camera.x/camera.y))/8;
> > > //-
> > > renderer.renderScene( scene, camera, viewport );
> > > }
> > > function centerCube() {
> > >
> > > // Render
> > >
> > > renderer.renderScene( scene, camera, viewport );
> > > }
> > > }
> > > }
> > >
> > >
> > >
> > >
> > >
> > >
> > > 2008/2/7, john noad <tosinner at yahoo.co.uk>:
> > >
> > > > yes, use planes.
> > > >
> > > > Connect them all together with a controler object, but with seperate
> > > > planes you will have six seperate targets. So when you click, you know which
> > > > "face" it is.
> > > >
> > > > Perhaps I'm not explaining what I mean well enough, but that's my
> > > > throughts.
> > > >
> > > > *Quang Dang <qpixelz at gmail.com>* wrote:
> > > >
> > > > I don't use planes, I simply use cube class. For each view of the
> > > > cube I applied material, using bitmapFileMaterial.
> > > > For initialise rotation, onEnterFrame:
> > > > cube.rotationY += (250 - stage.mouseX) / 100;
> > > > cube.rotationZ += (250 - stage.mouseY) / 100;
> > > >
> > > >
> > > > What I want to archive is:
> > > > When the mouse is over a selected face of the cube that it stops
> > > > rotating and the current face is "square" or "flat", meaning that you can
> > > > not see any other sides of the cube.
> > > >
> > > > Any ideas or examples of how to do that?
> > > >
> > > > thanks,
> > > > Quy
> > > >
> > > >
> > > > On Feb 7, 2008 4:24 PM, Maxamillion <tosinner at yahoo.co.uk> wrote:
> > > >
> > > > >
> > > > > Well, one way you could try would be to build the cube out of
> > > > > planes, so that
> > > > > each plane is a seperate hit target.
> > > > >
> > > > > I'm unsure if this is how it was done for that site, but it's an
> > > > > approach
> > > > > that I'd consider.
> > > > >
> > > > >
> > > > > qpixo wrote:
> > > > > >
> > > > > > Hi John,
> > > > > > On that site, I'd like to know when a user has clicked on one of
> > > > > cube area
> > > > > > view, let's say 'right' view. It should rotate and display only
> > > > > this
> > > > > > selected view that user clicked.
> > > > > >
> > > > > > how you do that?
> > > > > >
> > > > > > thanks,
> > > > > > Quy
> > > > > >
> > > > > > On Feb 7, 2008 12:53 AM, john noad <tosinner at yahoo.co.uk> wrote:
> > > > > >
> > > > > >> Can you give more details of hat you're after? I *think* I see
> > > > > what you
> > > > > >> want... but I'm not sure.
> > > > > >>
> > > > > >>
> > > > > >> *Quang Dang <qpixelz at gmail.com>* wrote:
> > > > > >>
> > > > > >> Hi Patrick,
> > > > > >>
> > > > > >> Congratulation for this great site
> > > > > >>
> > > > > http://www.pioneer.nl/nl/flash/products/kuro2007/experience.html
> > > > > >> I'm very impressed of your cube work.
> > > > > >>
> > > > > >> By the way, I have a question. I'd like to how to make a cube
> > > > > rotate to
> > > > > >> the right selected area while clicking on one of six view.
> > > > > >> I can't figure out how to do that.
> > > > > >> Any examples of code or tips would appreciate to point me right
> > > > > >> direction...
> > > > > >>
> > > > > >>
> > > > > >> thanks,
> > > > > >> Quy
> > > > > >>
> > > > > >> _______________________________________________
> > > > > >> Papervision3D mailing list
> > > > > >> Papervision3D at osflash.org
> > > > > >> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> > > > > >>
> > > > > >>
> > > > > >> ------------------------------
> > > > > >> Sent from
> > > > > >> Yahoo!<
> > > > > http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=51949/*http://uk.docs.yahoo.com/mail/winter07.html
> > > > > >-
> > > > > >> a smarter inbox.
> > > > > >>
> > > > > >>
> > > > > >> _______________________________________________
> > > > > >> 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/how-to-make-cube-rotate-to-right-selected-area--tp15327400p15343802.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
> > > >
> > > >
> > > >
> > > > ------------------------------
> > > > Sent from Yahoo!<http://us.rd.yahoo.com/mailuk/taglines/isp/control/*http://us.rd.yahoo.com/evt=51949/*http://uk.docs.yahoo.com/mail/winter07.html>- a smarter inbox.
> > > >
> > > > _______________________________________________
> > > > Papervision3D mailing list
> > > > Papervision3D at osflash.org
> > > > http://osflash.org/mailman/listinfo/papervision3d_osflash.org
> > > >
> > > >
> > >
> > >
> > > --
> > >
> > >
> > > ---------------------------------------------------
> > > Francisco Murillo C.
> > > (506) 389-2177
> > > http://www.frazko.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
>
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20080215/fbbb3ecc/attachment-0001.html
More information about the Papervision3D
mailing list