How can I know a mesh will be rendered or not?

Software: Away3D 4.x

Avatar
GoroMatsumoto, Sr. Member
Posted: 06 June 2013 04:44 PM   Total Posts: 166

Hi,

I have a mesh that is animated by cpu based vertex animation.

I want to stop the updating of animation when the mesh will be not rendered.
How can I do that?
Is there a useful function or property for that in Away3D?

   

Avatar
Fabrice Closier, Administrator
Posted: 06 June 2013 06:09 PM   Total Posts: 1265   [ # 1 ]

if you mean by vertex animation, that you do update the subgeometry yourself, simply stop doing that. If you mean that you use a VertexAnimator, simply say mesh.animator.stop();

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 06 June 2013 06:40 PM   Total Posts: 166   [ # 2 ]

Maybe my English was bad.
Sorry…

I know how to stop my animation.
And I’m using updating subGeometry data by code in each enter frame.
That’s heavy task for CPU.
So I don’t want to update, if the mesh is outside the viewport.

Can I know whether or not the mesh is inside the viewport?

   

Dlate, Newbie
Posted: 07 June 2013 03:35 PM   Total Posts: 21   [ # 3 ]
var 2dcoords:Vector3D view.projectmesh.sceneTransform.position );

if( 
2dcoords.|| 2dcoords.stage.stageWidth {
mesh
.visible false;
else {
mesh
.visible true;
   

Avatar
GoroMatsumoto, Sr. Member
Posted: 07 June 2013 04:28 PM   Total Posts: 166   [ # 4 ]

Thank you smile

   

Pierce, Jr. Member
Posted: 07 June 2013 05:32 PM   Total Posts: 40   [ # 5 ]

To clarify, you are actually creating the vertex animation through code rather than loading an external vertex animation file, correct? If not, the system should handle this for you invisibly I think, but if so then I definitely understand your concern with doing all the math to no visual benefit. The above snippet of code is a useful starting point, but it is a bit problematic. Firstly, as understand you don’t care about the visibility property of the mesh, you just want to stop updating the geometry, so you would use this if/else statement to instead make that call in your enter frame rather than toggle visibility. Secondly the parameters of the if statement are far too simplified. You’ll need to establish what the maximum bounding box of the animation is, so that a static cube generated around the mesh will contain the mesh for the entire duration of the animation. I recommend actually rendering said cube for testing purposes. Then rather than using the coordinates of the mesh’s position, you would determine if the 2d projected coordinates of the leftmost, rightmost, topmost, or bottommost pixels of the cube were within the bounds of stageWidth and stageHeight. This way, your animation will still continue playing when entirely off-screen if at some later point in the animation part of the mesh at that same position SHOULD appear on screen. If that was confusing I can try to explain it better, but hopefully you get what I mean. Good Luck!

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 07 June 2013 06:15 PM   Total Posts: 166   [ # 6 ]

@Pierce
Thank you for your worrying.
But I have known the bounds problem.

I’ve already had a own class to get 2D coords and 2Dsize in viewport.
I had just remembered it with Dlate’s snippet.
Silly me!

And I generate the geometry by code too.
So I can’t have a animation made by 3d applications.

Anyway, thank you for your time.

Cheers.

   

Pierce, Jr. Member
Posted: 07 June 2013 06:39 PM   Total Posts: 40   [ # 7 ]

Haha coolcool, it just drives me crazy when people get things *almost* just right smile
If your view coordinates class has any functionality not easily accessible in the current build, consider uploading it for the community or inclusion in the framework!

   

Avatar
GoroMatsumoto, Sr. Member
Posted: 08 June 2013 12:51 PM   Total Posts: 166   [ # 8 ]

Yes. When I finish my current work,
I will try to upload some useful class for Away3D.

Cheers.

   
   
‹‹ Sharing materials?

X

Away3D Forum

Member Login

Username

Password

Remember_me



X