Help plz! Sprite dont work!

3 views
Skip to first unread message

justfunk

unread,
Mar 28, 2008, 8:07:08 AM3/28/08
to away3d.dev
Hi all ;
I recently have started to study away3d. At me has appeared two
problems. First: why the MovieClipSlip, at moving on an axis, does not
change the sizes(scaling)? By the way - BitmapSprite changes normally.
I do not know in what a problem. I shall be very grateful, if somebody
will help me. A source code and exemple I apply.




var view:View3D = new View3D({x:300, y:200});

view.camera.y = 500;
view.camera.z = 0;
view.camera.x = -800;

addChild(view);

// simple Bitmap Sprite
var asset:BitmapData= new LostSoulFrontImage(1,1);
var ppc:Sprite2D = new Sprite2D({bitmap:asset,scaling:2,
smooth:false});

// MovieClip sprite
var lol:MovieClip= new ass();
var axe:MovieClipSprite = new MovieClipSprite(lol);

ppc.x = 150;
ppc.y = 400;
axe.x = 150;
axe.y = 400;
axe.z = -200;

view.scene.addChildren(ppc,axe);
view.camera.lookAt(axe.position);

addEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(event:KeyboardEvent):void {
switch (event.keyCode) {
case Keyboard.UP :
view.camera.x+=5;
break;
case Keyboard.DOWN :
view.camera.x-=5;
break;
case Keyboard.RIGHT :
view.camera.z+=5;
break;
case Keyboard.LEFT :
view.camera.z-=5;
break;
}
}
function onEnterFrame(event:Event):void {
view.render();
}

justfunk

unread,
Mar 28, 2008, 8:14:32 AM3/28/08
to away3d.dev

Rob Bateman

unread,
Mar 28, 2008, 8:52:01 AM3/28/08
to away3...@googlegroups.com
Hey justfunk

thanx for your  comments and code. for future reference, uploading flas to the google group will not store them correctly - try downloading the file below and you'll see what i mean... the best way to send stuff is simply in an email attachment.

regarding your comments on MovieClipSprite, the class is intended to allow movieclips to be placed within 3d content in a scene,  so that z-sorting is performed to provide a better 2d-3d integration. If distance scaling is something you would like to see added as an optional functionality of the movieclipsprite, we should be able to add that feature in the next revision of away3d.


atb


Rob
--
Rob Bateman
Flash Development & Consultancy

rob.b...@gmail.com
www.infiniteturtles.co.uk
www.away3d.com

justfunk

unread,
Mar 28, 2008, 10:09:34 AM3/28/08
to away3d.dev
ok, it's will be great.
In a sandy3d there is a Sprite3d analogue Sprite2DDir. In a sandy it
is possible to use the movieclip(clip in a lib) as a
data(bitmapdata) .
I have a second question:
Whether it is possible to use a movieclip as a data(bitmapdata) for
Sprite2DDir in away3d. If yes, as it can be made?

Rob Bateman

unread,
Mar 28, 2008, 1:44:08 PM3/28/08
to away3...@googlegroups.com
ok, it's will be great.
 In a sandy3d there is a Sprite3d  analogue Sprite2DDir. In a sandy it
is possible to use the movieclip(clip in a lib) as a
data(bitmapdata) .

uh, do you mean Away3d for Sprite2DDir? Sandy doesn't have this class, afaik

it is currently not possible to use a movieclip in a Sprite2dDir class, but it would make sense to have a directional sprite equivalent for MovieClipSprite - is this what you meant?

cheers

Rob

justfunk

unread,
Mar 28, 2008, 3:26:35 PM3/28/08
to away3d.dev
I simply looked a lesson on the sandy. It is site about a sandy:
http://www.flashsandy.org/tutorials/3.0/sandy_cs3_tut043 From
there I download an example. There the clip as library for images is
just used. I want to make too most with a away3d.

Here a part of a code from thise exemple:

public class Example0043 extends Sprite
{
private var scene:Scene3D;
private var camera:Camera3D;
private var queue:LoaderQueue;
private var s:Sprite3D;

public function Example0043():void
{
queue = new LoaderQueue();
queue.add( "plane", new URLRequest("plane/plane.swf") );
queue.addEventListener(SandyEvent.QUEUE_COMPLETE, loadComplete );
queue.start();
}

public function loadComplete(event:QueueEvent ):void
{
// We create the camera
camera = new Camera3D( 500, 300 );
camera.y = 10;
camera.z = -300;

// We create the "group" that is the tree of all the visible
objects
var root:Group = createScene();

// We create a Scene and we add the camera and the objects tree
scene = new Scene3D( "scene", this, camera, root );
scene.rectClipping = true;

// Listen to the heart beat and render the scene
addEventListener( Event.ENTER_FRAME, enterFrameHandler );
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedHandler);
}

// Create the scene graph based on the root Group of the scene
private function createScene():Group
{
// Create the root Group
var g:Group = new Group();

// let's create the Sprete 3D object
s = new Sprite3D("plane",queue.data["plane"],2);
s.rotateY = 90;
s.x = 0;
s.z = 0;
s.y = 0;
g.addChild(s);

return g;
}

// The Event.ENTER_FRAME event handler tells the Scene3D to
render
private function enterFrameHandler( event : Event ) : void
{
if (s.rotateY==0)
s.rotateY=0.1;
if(s.x > 220 && s.z < 0)
s.x=-220;
else if(s.x < -220 && s.z < 0)
s.x=220;
else if (s.z<-250)
s.z=1000;

s.moveForward(-7);
scene.render();
}

// This function handles the move foreward or backward simultaion
private function keyPressedHandler(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.RIGHT)
s.rotateY -=5;
if(event.keyCode == Keyboard.LEFT)
s.rotateY +=5;
}
}


P.S.: Probably I badly explain, coz my English is unreal bad.

link (using mc):
http://away3d-dev.googlegroups.com/web/Sandi3dSpriteExemple.rar?gda=JvSo3EkAAAAHMJMgzEEFY9eje5YoZG2YvJ2MJKSX_2oj0SM8gqgpQGG1qiJ7UbTIup-M2XPURDR9at1yCnUo3-8G1kpo_IIPaVlcxA3SGWbGzZuMbMYyXw

Rob Bateman

unread,
Mar 28, 2008, 5:02:29 PM3/28/08
to away3...@googlegroups.com
I simply looked a lesson on the sandy. It is site about a sandy:
http://www.flashsandy.org/tutorials/3.0/sandy_cs3_tut043      From
there I download an example. There the clip as library for images is
just used. I want to make too most with a away3d.

ok, i see what you mean now


the scene3d class is similar in what it achieves to the sprite2ddir class, but i have to say that i personally thik the implementation is restrictive. in sprite3d (sandy), you pass a movieclip that contains a different sprite in each frame, this is interpreted as a position in a viewing ring around the sprite.

Sprite2ddir (Away3d) on the other hand, allows you to specify individual images that are included in the sprite using the add() method, which defines a bitmapdata object to use, and a direction vector that the sprite represents. This is more flexible, because you can aadd an image with any diretion vector you like, and the sprite will display the image whole vector produces the largest dot product between itself and the line of sight of the camera. With this operation, you can specify images around any number of axis, so that you a re not just restricted to an evenly spaced ring of images around the sprite position.

having said all that, i still think that a directional MovieClipSprite could be useful - if you wanted to perform animation inside a sprite2ddir for example. Well add this to our list for future feature consideration


atb


Rob

 

Makc

unread,
Mar 29, 2008, 5:11:03 AM3/29/08
to away3...@googlegroups.com
On Fri, Mar 28, 2008 at 11:02 PM, Rob Bateman <rob.b...@gmail.com> wrote:
> the scene3d class is similar in what it achieves to the sprite2ddir class,
> but i have to say that i personally thik the implementation is restrictive.
> in sprite3d (sandy), you pass a movieclip that contains a different sprite
> in each frame, this is interpreted as a position in a viewing ring around
> the sprite.
>
> Sprite2ddir (Away3d) on the other hand, allows you to specify individual
> images that are included in the sprite using the add() method, which defines
> a bitmapdata object to use, and a direction vector that the sprite
> represents. This is more flexible, because you can aadd an image with any
> diretion vector you like, and the sprite will display the image whole vector
> produces the largest dot product between itself and the line of sight of the
> camera. With this operation, you can specify images around any number of
> axis, so that you a re not just restricted to an evenly spaced ring of
> images around the sprite position.

I agree, but generating images for sandy sprite3d is difficult
already, even more so for your directional sprite (add views from
above/below). Someone has to write some sort of tool for that.

Rob Bateman

unread,
Mar 29, 2008, 6:43:02 PM3/29/08
to away3...@googlegroups.com
I agree, but generating images for sandy sprite3d is difficult
already, even more so for your directional sprite (add views from
above/below). Someone has to write some sort of tool for that.

maybe a future version of away3d will support an option for directional sprite caching on all 3d objects... whoops - did i say that out loud? :)


Rob

Makc

unread,
Mar 30, 2008, 8:25:48 AM3/30/08
to away3...@googlegroups.com
that's good idea, could allow for lots of model instances on stage at
the same time.

justfunk

unread,
Mar 30, 2008, 9:13:17 AM3/30/08
to away3d.dev
When dreams come true.... "(0_0)"
Reply all
Reply to author
Forward
0 new messages