Author Topic: Best Way To Do Page Turning Mechanic  (Read 3546 times)

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Best Way To Do Page Turning Mechanic
« on: July 22, 2015, 10:15:59 AM »
I'm looking for the best way to accomplish page turning in a book app.

A Page is:
Background image
UI elements

There is a top page mesh which animates and a bottom page mesh.

Here is my idea for the top page:

1. Player hits NEXT
2. Generate screen cap using readPixels(). Bakes UI and background image into one image.
3. Apply screen cap texture to top page mesh
4. Disable actual UI elements so they're hidden during page turn.
5. Trigger the page turn animation. Everything on the page "curls" nicely with the page.

Idea for bottom page:

1. Player hits NEXT
2. Offscreen in a "staging area" I create my page with a dummy camera
3. Generate screen cap using readPixels(). Bakes UI and image into one image.
4. Apply screen cap to bottom page mesh
5. The TOP page mesh animates away revealing bottom page
6. Enable the UI elements.

What do people think about this idea? Is there a better way to handle this?

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Best Way To Do Page Turning Mechanic
« Reply #1 on: July 22, 2015, 10:19:29 PM »
I hit a snag. I created the "staging area" offscreen and setup my page with several UI elements.

I figured I could take a screen grab on a staging area camera and get all the UI elements baked into a single texture which I could apply to the bottom page mesh. Idea being, when the top page mesh peeled away, the underlying page mesh would be revealed.

Problem is, after creating a duplicate UI root and camera, whatever is in the camera view shows up in the game viewport regardless if it is far away from the other cameras in the world.

I'm still a newb. Does anyone know how to do what I am trying to do?

Essentially, I want the camera to render to its own viewport that does not get added to the game viewport and allows me to take a screen cap of using readPixels()

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Best Way To Do Page Turning Mechanic
« Reply #2 on: July 24, 2015, 10:37:43 AM »
You need to render-to-texture. You can create a render texture dynamically via code and then use your existing camera, set its render texture target, Render() your scene, then remove the render texture target. This will effectively create a snapshot of what you see and place it in your render texture that you can then use as any other texture.

P.S. This isn't an NGUI question. :P