Access to the view3D and Camera from an Object3D.

1 view
Skip to first unread message

ben

unread,
Jan 22, 2009, 4:11:04 PM1/22/09
to away3d.dev
HI !
I'm having some problems accessing to the view3D and the camera from a
class extending object3D...
I thought I could find something like object.session.view.camera in
order to get screenvertex (...for my sweet avoidMouse method !)
But, No.
Do I have to access global>stage>etc.... to camera ???

Looked at the API, from rendersession to ................
I can't help fix this !
Maybe it's a basic, but ...I failed !

Thanks !

ben

unread,
Jan 23, 2009, 4:05:54 AM1/23/09
to away3d.dev
This works :

in your class extending object3D:

private var __view:View3D;
private var __cam:Camera3D;
private var __screenCoord:ScreenVertex;
***********************************
__view = this.sceneTransform as View3D;
__cam = __view.camera as Camera3D;
__screenCoord = __view.camera.screen(this);


This can be usefull !

ben

unread,
Jan 23, 2009, 5:10:14 AM1/23/09
to away3d.dev
Sorry, this worked because of a mistake !
Not Fixed ! Help Needed.

Rob Bateman

unread,
Jan 24, 2009, 11:23:05 AM1/24/09
to away3...@googlegroups.com
Hey Ben

can you just explain why you need to access teh view from your object3d? Usually, the view is located somewhere you create, so can easily be references with a static variable etc.

object3d does not keep a reference to the view because it doesn't act that way round - the view steps through objects via the scene when rendering, and the scene stores global values referring to object status. Also, an object could be rendered a number of times by different views, so a view property in an object would be ambiguous.

Rob




On Fri, Jan 23, 2009 at 10:10 AM, ben <benj...@agence-anonyme.com> wrote:

Sorry, this worked because of a mistake !
Not Fixed !  Help Needed.



--
Rob Bateman
Flash Development & Consultancy

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

ben

unread,
Jan 24, 2009, 11:53:32 AM1/24/09
to away3d.dev
HI Rob,
the reason is simple :
when addin my particle manager, (wish is not extending object3D
anymore), I have a reference to an Object3D (or many ) from the main
view, that have been added to an array.
in the manager, in order to add little playfull mouse interactions, i
just wan't to get the screenVertex of my Object3D>>from my the
Array>>from the particle manager.

I understand the fact that a view property should be ambiguous, and
maybe i should reformulate my querry : in fact as I'm interested with
my object screenVertex,
I do more need the camera...

For now, i pass the view as parameter when buildin my class, i can get
the scene from my object, but I don't know why, even if I can trace a
ref to the main camera (as well as stage, scene, etc...)
the camera.screen return a reference error ???

But in order to extend my particle manager, I would like not to have
to pass the view as parameter... But how can I go back trough the pipe
and get the path to the camera and view from an object3D ???

Is it clear ???

Rob Bateman

unread,
Feb 4, 2009, 8:29:38 PM2/4/09
to away3...@googlegroups.com
Hey Ben

yep, it's clear. but i'm afraid this is just not an option in the framework of away3d - the view is a window on the scene, and resolves all objects to 2d representations, but doesn't leave a stamp on teh objects themselves. I think the best way is to simply pass the view as an argument, which sounds liek what you are doing.

however, screenvertices are fairly easy to grab with some of the recent updates to the trunk: you can do it like this:

screenvertex = view.drawPrimitiveStore.createVertexDictionary(object3d)[vertex]

after a view.render() is called. or if you can't wait for that, use:

screenvertex = view.camera.screen(object3d, vertex);

hth!

Rob
Reply all
Reply to author
Forward
0 new messages