Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Finding 2D bounding box for an object when drawn?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  19 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
bakedbeing  
View profile  
 More options Nov 6 2008, 6:16 pm
From: bakedbeing <danny.mcgill...@gmail.com>
Date: Thu, 6 Nov 2008 15:16:53 -0800 (PST)
Local: Thurs, Nov 6 2008 6:16 pm
Subject: Finding 2D bounding box for an object when drawn?
Heya again lads!

Is there a direct way to find a 2D bounding box for an object as
finally drawn to the view?

I want to find the top left and bottom right of the object, so I can
crop my swf to just the edges of the object (move the view object,
resize the swf).

I couldn't find anything in the object3D properties or in view3D.

I was thinking a long way would be to draw the whole view to a
bitmapData object with BitmapRenderSession and trawl that for pixel
data, but I'm hoping there's something easier? A sprite object inside
Projector who's x,y, height and width (in 2D) I can grab??

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bakedbeing  
View profile  
 More options Nov 6 2008, 6:44 pm
From: bakedbeing <danny.mcgill...@gmail.com>
Date: Thu, 6 Nov 2008 15:44:54 -0800 (PST)
Local: Thurs, Nov 6 2008 6:44 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Is there a way to access the graphics container in the view3D or in
the session object? Something that will give me access to the sprite
created for each object?

On Nov 7, 10:16 am, bakedbeing <danny.mcgill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 6 2008, 10:07 pm
From: Mango <whiskers8...@yahoo.com>
Date: Thu, 6 Nov 2008 19:07:27 -0800 (PST)
Local: Thurs, Nov 6 2008 10:07 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Hello!

The data in these containers doesn't live long enough to access. I
don't think you can retrieve the properties of the objects without
inserting code into the Away3D classes (and the height and width
default to swf height and width anyway).

Object3D provides objectWidth, objectHeight, and objectDepth
properties, and from these you can calculate with the projection the
width and height of the drawn graphic. Unfortunately, I do not have
the time (or knowledge, probably) to show you how to do this.

I'm curious as to why you need these values, though. To what end does
resizing the swf serve? :)

On Nov 6, 5:44 pm, bakedbeing <danny.mcgill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bakedbeing  
View profile  
 More options Nov 6 2008, 10:24 pm
From: bakedbeing <danny.mcgill...@gmail.com>
Date: Thu, 6 Nov 2008 19:24:36 -0800 (PST)
Local: Thurs, Nov 6 2008 10:24 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Heya Mango, thanks for the response. Yeah I was thinking there's ways
to do it using Matrix math and all the values in the render scene, but
it's well beyond me to do, and I was hoping that the data would be
somewhere in the 3D pipeline and just need to be fished out.

I'm overlaying a 3D object on Google Street View, and it's moving
pretty well with the maps, but if you completely cover the streetview
with another div with flash on it, you can't click and drag on the
streetview below. So I need to calculate my bottle's position, render
it, then move my view and move/crop my swf so it's only the size of
the drawn 3D object :)

On Nov 7, 2:07 pm, Mango <whiskers8...@yahoo.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 6 2008, 11:15 pm
From: Mango <whiskers8...@yahoo.com>
Date: Thu, 6 Nov 2008 20:15:40 -0800 (PST)
Local: Thurs, Nov 6 2008 11:15 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
I'm not sure if this is easier or more useful, but you can use the
Google Maps API for Flash, add the object to a sprite, and set the
sprite to the background of the view:

var view:View3D = new View3D(...);
var streetView:Sprite = //google street view API
view.background = streetView;

In this way, transparent space will not interfere with mouse clicks as
long as you're not using something that fills the entire view (fog
filter, etc).

Quote:
"The Google Maps API now provides a Street View service for obtaining
and manipulating the imagery used in Google Maps Street View!"

I have no experience with street view or google maps, so this info may
be completely irrevalant or useless. :P

On Nov 6, 9:24 pm, bakedbeing <danny.mcgill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 6 2008, 11:21 pm
From: Mango <whiskers8...@yahoo.com>
Date: Thu, 6 Nov 2008 20:21:07 -0800 (PST)
Local: Thurs, Nov 6 2008 11:21 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Sorry, here's the link:
http://code.google.com/apis/maps/documentation/flash/

On Nov 6, 10:15 pm, Mango <whiskers8...@yahoo.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bakedbeing  
View profile  
 More options Nov 7 2008, 12:42 am
From: bakedbeing <danny.mcgill...@gmail.com>
Date: Thu, 6 Nov 2008 21:42:52 -0800 (PST)
Local: Fri, Nov 7 2008 12:42 am
Subject: Re: Finding 2D bounding box for an object when drawn?
Heya Mango, we were thinking the same here, but it doesn't look like
the actionscript API for google maps includes streetview yet, for that
you need to be using  a browser and javascript as far as I can tell :(

On Nov 7, 3:21 pm, Mango <whiskers8...@yahoo.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Bateman  
View profile  
 More options Nov 7 2008, 8:02 am
From: "Rob Bateman" <rob.bate...@gmail.com>
Date: Fri, 7 Nov 2008 13:02:17 +0000
Local: Fri, Nov 7 2008 8:02 am
Subject: Re: [away3d] Re: Finding 2D bounding box for an object when drawn?

Hey bakedbeing

have you tried using the bounding radius property yet? you can access the
containing radius of any object through the property boundingRadius. This
doesn't give you a screen bounding box, but you could use a perspective
calulation on the radius to get a view value and work from there.

another quick hack that may be simpler to execute is just taking the
rectangle returned from getBounds() on the view! this will give you a
Rectangle instance that you can extract all relevant data relating to the
bounds of the object inside.

atb

Rob

On Fri, Nov 7, 2008 at 5:42 AM, bakedbeing <danny.mcgill...@gmail.com>wrote:

--
Rob Bateman
Flash Development & Consultancy

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bakedbeing  
View profile  
 More options Nov 10 2008, 7:46 pm
From: bakedbeing <danny.mcgill...@gmail.com>
Date: Mon, 10 Nov 2008 16:46:41 -0800 (PST)
Local: Mon, Nov 10 2008 7:46 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Hey thanks for the tip Rob. I've tried using getBounds on the view,
but it's giving me a bounding rectangle the size of the whole canvas.
Do you know what containers I could look at inside the object to get
something that matches the outline of our object?

On Nov 8, 12:02 am, "Rob Bateman" <rob.bate...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Kapelyan  
View profile  
 More options Nov 10 2008, 9:35 pm
From: "Peter Kapelyan" <flashn...@gmail.com>
Date: Mon, 10 Nov 2008 21:35:31 -0500
Local: Mon, Nov 10 2008 9:35 pm
Subject: Re: [away3d] Re: Finding 2D bounding box for an object when drawn?

If your object is the only thing in that view, then the width and height of
the view itself should be the number you are looking for (quick hack).

I guess you can try this:

hideeverything but the object,
render the view,
get the width and height of the view,
turn on all objects
render again...

If it works i guess its not that bad, it's only rendering that one object
twice (should be fast).
Hope it works and sorry if my idea or dirty hack doesn't work, but it's more
fun for me than thinking of the math!

-Pete

On Mon, Nov 10, 2008 at 7:46 PM, bakedbeing <danny.mcgill...@gmail.com>wrote:

--
___________________

Actionscript 3.0 Flash 3D Graphics Engine

HTTP://AWAY3D.COM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Kapelyan  
View profile  
 More options Nov 10 2008, 10:13 pm
From: "Peter Kapelyan" <flashn...@gmail.com>
Date: Mon, 10 Nov 2008 22:13:24 -0500
Local: Mon, Nov 10 2008 10:13 pm
Subject: Re: [away3d] Re: Finding 2D bounding box for an object when drawn?

Ahh, I just tried it and maybe that's what you already tried, the width of
the view does return the full view width...darn.

--
___________________

Actionscript 3.0 Flash 3D Graphics Engine

HTTP://AWAY3D.COM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 11 2008, 1:49 am
From: Mango <whiskers8...@yahoo.com>
Date: Mon, 10 Nov 2008 22:49:57 -0800 (PST)
Local: Tues, Nov 11 2008 1:49 am
Subject: Re: Finding 2D bounding box for an object when drawn?
Rob and Peter both have the right idea. Unfortunately, when you add
the view sprite to the parent, it inherits the parent's dimensions.
Solution? Create two identical scenes, but only add one to the parent
display object.

Example:
http://www.mediafire.com/?sharekey=c8a7966316f99e07d2db6fb9a8902bda
(Sorry about the hosting link. My site is not up currently, so I
cannot host it properly. Also, the file upload on this site doesn't
appear to load swfs. Feel free to rehost.)

AS3:
public class BoundTest extends Sprite {
  private var view:View3D;
  private var view2:View3D;
  private var cube:Cube;
  private var cube2:Cube;
  private var rect:Rectangle;

  public function BoundTest() {
    init();
  }

  private function init():void {
    view = new View3D({x:200, y:200, clip:new RectangleClipping(-190,
-150, 190, 150)});
    view2 = new View3D({x:200, y:200, clip:new RectangleClipping(-190,
-150, 190, 150)});
    cube = new Cube();
    cube2 = new Cube();
    view.scene.addChild(cube);
    view2.scene.addChild(cube2);

    addChild(view);
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
  }

  private function onEnterFrame(event:Event):void {
    cube.rotationX += 5;
    cube.rotationY += 5;
    cube.rotationZ += 5;
    cube2.rotationX += 5;
    cube2.rotationY += 5;
    cube2.rotationZ += 5;

    view2.render();
    rect = view2.getBounds(this);
    view.render();

    trace(rect.width + ", " + rect.height);
  }

}// of class

On Nov 10, 6:46 pm, bakedbeing <danny.mcgill...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 11 2008, 2:06 am
From: Mango <whiskers8...@yahoo.com>
Date: Mon, 10 Nov 2008 23:06:31 -0800 (PST)
Local: Tues, Nov 11 2008 2:06 am
Subject: Re: Finding 2D bounding box for an object when drawn?
One thing I forgot to note:

Notice the RectangleClipping added to both views. For the view that is
not added to the parent display object, it is necessary to specify a
Clipping, because the view Sprite does not have access to stage
properties.

On Nov 11, 12:49 am, Mango <whiskers8...@yahoo.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Kapelyan  
View profile  
 More options Nov 11 2008, 9:33 am
From: "Peter Kapelyan" <flashn...@gmail.com>
Date: Tue, 11 Nov 2008 09:33:34 -0500
Local: Tues, Nov 11 2008 9:33 am
Subject: Re: [away3d] Re: Finding 2D bounding box for an object when drawn?

That is really great!

Can you add this example here please, I think it will help others:

http://away3d.com/examples.php?add=new

Thank you for taking your time to help out, and for your example!

-Pete

--
___________________

Actionscript 3.0 Flash 3D Graphics Engine

HTTP://AWAY3D.COM


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 11 2008, 6:11 pm
From: Mango <whiskers8...@yahoo.com>
Date: Tue, 11 Nov 2008 15:11:23 -0800 (PST)
Local: Tues, Nov 11 2008 6:11 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Sure, I have submitted the example.

On Nov 11, 8:33 am, "Peter Kapelyan" <flashn...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 11 2008, 6:16 pm
From: Mango <whiskers8...@yahoo.com>
Date: Tue, 11 Nov 2008 15:16:38 -0800 (PST)
Local: Tues, Nov 11 2008 6:16 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
bakedbeing has also posted two great examples that use
session.getContainer() to find the bounds of a single object.

On Nov 11, 8:33 am, "Peter Kapelyan" <flashn...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bakedbeing  
View profile  
 More options Nov 11 2008, 6:50 pm
From: bakedbeing <danny.mcgill...@gmail.com>
Date: Tue, 11 Nov 2008 15:50:58 -0800 (PST)
Local: Tues, Nov 11 2008 6:50 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Heya gents, thanks for working so hard on that solution Mango, I'll
have a good look through it this afternoon. As you mentioned above,
after a morning of digging through the source I managed to figure out
that the contents of the session.container object report their bounds
as being flush with their edges, not the entire view. I'll post the
code here for anyone who should come looking:

Here's a way to use the Session object within your View3D to find the
bounds of an object you've drawn to the screen with view.render().
This example is built for a single object, in my case an imported OBJ
file. The coordinates returned are relative to (this), the movie
within which the view object is contained.

        // view has been defined previously, it's our View3D object.
        var sessionContainer:DisplayObjectContainer =
view.session.getContainer(view) as DisplayObjectContainer;
        var drawnObject = sessionContainer.getChildAt(0);
        var viewBounds = drawnObject.getRect(this);
        trace("vb: " + viewBounds.left + "," + viewBounds.top + "/" +
viewBounds.right + "," +viewBounds.bottom);

The next challenge is to find a way to wait until the view has been
successfully rendered. Right now I'm using onEnterframe and I think
it's lagging a frame or two behind.

On Nov 12, 10:16 am, Mango <whiskers8...@yahoo.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bakedbeing  
View profile  
 More options Nov 11 2008, 6:53 pm
From: bakedbeing <danny.mcgill...@gmail.com>
Date: Tue, 11 Nov 2008 15:53:54 -0800 (PST)
Local: Tues, Nov 11 2008 6:53 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Oh yeah Mango I wasn't sure where the example fitted best so I
submitted it to (I think) the view and session pages.

On Nov 12, 10:16 am, Mango <whiskers8...@yahoo.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mango  
View profile  
 More options Nov 11 2008, 7:29 pm
From: Mango <whiskers8...@yahoo.com>
Date: Tue, 11 Nov 2008 16:29:46 -0800 (PST)
Local: Tues, Nov 11 2008 7:29 pm
Subject: Re: Finding 2D bounding box for an object when drawn?
Hmm. If I remember correctly, you're overlaying a page with the swf,
and you need the swf to resize and reposition dynamically. How are you
communicating with the DOM to achieve this? It's possible that the
delay you're experiencing is caused by interaction between flash
player and the external scripts.

On Nov 11, 5:50 pm, bakedbeing <danny.mcgill...@gmail.com> wrote:

...

read more »


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »