{"id":1214,"date":"2011-12-08T16:29:09","date_gmt":"2011-12-08T16:29:09","guid":{"rendered":"http:\/\/www.west-racing.com\/mf\/?page_id=1214"},"modified":"2012-07-13T12:45:33","modified_gmt":"2012-07-13T12:45:33","slug":"book-builder","status":"publish","type":"page","link":"http:\/\/www.west-racing.com\/mf\/?page_id=1214","title":{"rendered":"Book Builder"},"content":{"rendered":"<p><a href=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/11\/book.jpg\"><img loading=\"lazy\" src=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/11\/book-1024x524.jpg\" alt=\"\" title=\"book\" width=\"640\" height=\"327\" class=\"aligncenter size-large wp-image-840 fancy\" srcset=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/11\/book-1024x524.jpg 1024w, http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/11\/book-300x153.jpg 300w, http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/11\/book-680x348.jpg 680w, http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/11\/book.jpg 1068w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/a><br \/>\nThere is a helper script included in the system to help make animating books using the Page mesh objects and the Page Flip modifiers. The video guide is at the bottom of the page so press play and follow along in Unity. It will first show you how to make a turning page then move on to building a book. This will involve you making 5 page meshes, 3 for the turning pages of the book and 2 for the covers. It will show how to group the objects under a main parent with helper objects for pivot points. Then by attaching the Mega Book component and filling in the params you will be left with a book that simply by changing one value will open the book turn all the pages, automatically update the page textures and then finally close the book. You have control over various params such as the number of pages, the texture for each page and vertical spacing.<\/p>\n<p>The way the script works is by figuring out from the Book Alpha value the state of the book ie which page should be visible and how far turned it should be, it will then apply the correct page textures to the 3 pages to make it seem like the book is open at the correct point and apply the right turn value to the page flip modifiers. If the book is near the start of end it will rotate the front or back covers as needed. This is a basic system and it would be easy enough for someone with scripting knowledge to expand and improve it.<br \/>\n<div class=\"message_box info_box\">\n<p class=\"message_box_sign info_box_sign\">Info<\/p>\nThe Book builder is provided as an example of how the modifier system can be extended and used, it is meant to be used by the user as a learning tool and to be extended and customized. So have a go at improving the example code.\n<\/div><br \/>\n<a href=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/12\/megabookinsp.jpg\"><img loading=\"lazy\" src=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/12\/megabookinsp.jpg\" alt=\"\" title=\"megabookinsp\" width=\"259\" height=\"245\" class=\"alignright size-full wp-image-1223 fancy\" \/><\/a><\/p>\n<h3>Book Params<\/h3>\n<h4><strong>Front<\/strong><\/h4>\n<p>The object that will be used as the front cover.<\/p>\n<h4><strong>Back<\/strong><\/h4>\n<p>The object that will be used as the back cover.<\/p>\n<h4><strong>Page 1<\/strong><\/h4>\n<p>The object that will be used as the first visible page of the book, this object and the other page objects should have a working Page Flip effect applied already.<\/p>\n<h4><strong>Page 2<\/strong><\/h4>\n<p>The object that will be used as the second visible page.<\/p>\n<h4><strong>Page 3<\/strong><\/h4>\n<p>The object that be used as the third visible page of the book.<\/p>\n<h4><strong>Pages<\/strong><\/h4>\n<p>This is a list of the textures that make up the book, they should be in order and should be at least 6 and be an even number. Each pair make up a front and back of a page.<\/p>\n<h4><strong>Book Alpha<\/strong><\/h4>\n<p>Value from 0 to 1 for how far through the book to show, 0 is an unopened book, 0.5 is a book open half way through and 1 is a fully read book showing the back.<\/p>\n<h4><strong>Cover Gap<\/strong><\/h4>\n<p>Gap between the front and back covers.<\/p>\n<h4><strong>Page Space<\/strong><\/h4>\n<p>Gap between the pages.<\/p>\n<h3>MegaBook Classs<\/h3>\n<p>[cc lang=&#8221;c#&#8221;]public class MegaBook : MonoBehaviour<br \/>\n{<br \/>\n\tpublic GameObject\t\tfront;<br \/>\n\tpublic GameObject\t\tback;<br \/>\n\tpublic GameObject\t\tpage1;<br \/>\n\tpublic GameObject\t\tpage2;<br \/>\n\tpublic GameObject\t\tpage3;<br \/>\n\tpublic List<Texture>\tpages;<br \/>\n\tpublic float\t\t\tbookalpha;<br \/>\n\tpublic float\t\t\tcovergap;<br \/>\n\tpublic float\t\t\tpagespace;<br \/>\n}[\/cc]<\/p>\n<h3>Interacting with Book<\/h3>\n<p>If you want to add some form of interaction to your books you can use some simple code like the snippet below to link some form of input to the book alpha value in the script to control the page turn, so this could be mouse movement, key presses or a GUI element etc.<br \/>\n[cc lang=&#8221;c#&#8221;]public float    dragsensi = 1.0f;<br \/>\npublic float    keysensi = 1.0f;<\/p>\n<p>\/\/ Call this from Update()<br \/>\nvoid Interactive()<br \/>\n{<br \/>\n    \/\/ Mouse version<br \/>\n    bookalpha += Input.GetAxis(&#8220;Mouse X&#8221;) * dragsensi;<br \/>\n    bookalpha = Mathf.Clamp(bookalpha, 0.0f, 100.0f);<\/p>\n<p>    \/\/ Keyboard version<br \/>\n    bookalpha += Input.GetKey(KeyCode.A) * keysensi;<br \/>\n    bookalpha += Input.GetKey(KeyCode.D) * keysensi;<br \/>\n    bookalpha = Mathf.Clamp(bookalpha, 0.0f, 100.0f);<br \/>\n}[\/cc]<\/p>\n<p>If you are using Unity 3.5 and notice a slight glitch in the texture swaps on turning pages then you should turn on &#8216;Late Update&#8217; on the Modify Object component.<\/p>\n<h3>Video Guide<\/h3>\n<p><a href=\"http:\/\/www.youtube.com\/watch?v=IZWCVQ8UKMM&#038;hd=1&#038;fs=1&#038;autoplay=1\" class=\"fancybox-youtube\"><img loading=\"lazy\" src=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/12\/ytbookbuild.jpg\" alt=\"\" title=\"ytbookbuild\" width=\"680\" height=\"372\" class=\"aligncenter size-full wp-image-1427 fancy\" srcset=\"http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/12\/ytbookbuild.jpg 680w, http:\/\/www.west-racing.com\/mf\/wp-content\/uploads\/2011\/12\/ytbookbuild-300x164.jpg 300w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a helper script included in the system to help make animating books using the Page mesh objects and the Page Flip modifiers. The video guide is at the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":299,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":[],"_links":{"self":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/1214"}],"collection":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1214"}],"version-history":[{"count":18,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/1214\/revisions"}],"predecessor-version":[{"id":1216,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/1214\/revisions\/1216"}],"up":[{"embeddable":true,"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=\/wp\/v2\/pages\/299"}],"wp:attachment":[{"href":"http:\/\/www.west-racing.com\/mf\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}