Cardboard VR Projects for Android by Jonathan Linowes & Matt Schoen
Author:Jonathan Linowes & Matt Schoen [Linowes, Jonathan]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2016-05-17T04:00:00+00:00
Time for animation
It's time to throw in a little more excitement. Let's animate the cube so that it rotates. This'll help demonstrate the shading as well.
For this, we need a Time class. This is a singleton utility class that ticks off frames and makes that information available to the application, for example, via getDeltaTime. Note that this is a final class, which explicitly means that it cannot be extended. There is no such thing as a static class in Java, but if we make the constructor private, we can ensure that nothing will ever instantiate it.
Create a new Time class in the renderbox/ folder. It won't be getting extended, so we can declare it final. Here's the code:
public final class Time { private Time(){} static long startTime; static long lastFrame; static long deltaTime; static int frameCount; protected static void start(){ frameCount = 0; startTime = System.currentTimeMillis(); lastFrame = startTime; } protected static void update(){ long current =System.currentTimeMillis(); frameCount++; deltaTime = current - lastFrame; lastFrame = current; } public static int getFrameCount(){return frameCount;} public static float getTime(){ return (float)(System.currentTimeMillis() - startTime) / 1000; } public static float getDeltaTime(){ return deltaTime * 0.001f; } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Blood, Sweat, and Pixels by Jason Schreier(3486)
Dawn of the New Everything by Jaron Lanier(2690)
Godot 4 Game Development Cookbook by Jeff Johnson(2557)
The Art of Doom by Bethesda(2039)
Significant Zero by Walt Williams(1886)
Creative Character Design by Bryan Tillman(1842)
World of Warcraft Chronicle Volume 3 by Blizzard Entertainment(1663)
The Ultimate Roblox Book by David Jagneaux(1617)
Art Of Atari by Tim Lapetino(1567)
Pillars of Eternity Guidebook by Obsidian Entertainment(1540)
Dawn of the New Everything: Encounters with Reality and Virtual Reality by Jaron Lanier(1539)
1628927445Game by Unknown(1478)
Unreal Engine 4 Virtual Reality Projects by Kevin Mack(1475)
Mission Python by Sean McManus(1458)
Unreal Engine Virtual Reality Quick Start Guide by Jessica Plowman(1455)
The Ultimate Player's Guide to Minecraft by Stephen O'Brien(1421)
Learning D by 2015(1419)
Unity 2018 By Example by Alan Thorn(1394)
Road Games by Road Games(1369)
