SDK plug-in method to check if object is 3D Camera viewport?

0 favourites
  • 4 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • Is there an plug-in SDK method to check if an object is within the 3D camera viewport?

    For example, how the engine might determine using the 3D Shape's x, y, z elevation, bbox, and z height if Draw() should be called or not (I'm not sure how it's done, just guessing.)

    I want to check if my 3D Object is visible or not depending on the camera location and orientation. If it is, I want to have the option to pause animations to save CPU cycles.

    For 2D I used to do the below, but, this is not applicable for 3D.

     let wi = this.GetWorldInfo();
     let layerRect = wi.GetLayer().GetViewport();
     let instanceRect = wi.GetBoundingBox();
     let onScreen = instanceRect.intersectsRect(layerRect);
    
  • I think this requested SDK method is similar to the Common ACE Is on-screen - which looks to work for both 3D and 2D.

  • Construct determines whether to call the Draw() method, so your plugin shouldn't need to worry about that.

    You don't need your own viewport check either - you can implement logic along the lines of "if Draw() hasn't been called for a few ticks, assume I'm now outside the viewport, and stop doing processing work".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks Ashley for the response, yes I was not concerned about whether Draw() was called or not, I was thinking more about the processing I was doing for animation (I want some of it to continue, but not all the detailed processing, if it's not being rendered / on screen.)

    I will take a look at implementing a check if Draw() has been called in the last few ticks (probably a simple shift register like array pushed by Draw() and popped by Tick() )

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)