the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 68 lines 2.4 kB view raw
1#include "stdafx.h" 2#include "..\Minecraft.World\Mth.h" 3#include "BookModel.h" 4#include "ModelPart.h" 5 6BookModel::BookModel() 7{ 8 leftLid = (new ModelPart(this))->texOffs(0, 0)->addBox(-6, -5, 0, 6, 10, 0); 9 rightLid = (new ModelPart(this))->texOffs(16, 0)->addBox(0, -5, 0, 6, 10, 0); 10 11 seam = (new ModelPart(this))->texOffs(12, 0)->addBox(-1, -5, 0, 2, 10, 0); 12 13 // 4J - added faceMasks here to remove sides of these page boxes which end up being nearly coplanar to the cover of the book and flickering when rendering at a distance 14 leftPages = (new ModelPart(this))->texOffs(0, 10)->addBoxWithMask(0, -4, -1 + 0.01f, 5, 8, 1, 47); // 4J - faceMask is binary 101111 15 rightPages = (new ModelPart(this))->texOffs(12, 10)->addBoxWithMask(0, -4, -0.01f, 5, 8, 1, 31); // 4J - faceMask is binary 011111 16 17 flipPage1 = (new ModelPart(this))->texOffs(24, 10)->addBox(0, -4, 0, 5, 8, 0); 18 flipPage2 = (new ModelPart(this))->texOffs(24, 10)->addBox(0, -4, 0, 5, 8, 0); 19 20 leftLid->setPos(0, 0, -1); 21 rightLid->setPos(0, 0, 1); 22 23 seam->yRot = PI / 2; 24 25 // 4J added - compile now to avoid random performance hit first time cubes are rendered 26 leftLid->compile(1.0f/16.0f); 27 rightLid->compile(1.0f/16.0f); 28 seam->compile(1.0f/16.0f); 29 leftPages->compile(1.0f/16.0f); 30 rightPages->compile(1.0f/16.0f); 31 flipPage1->compile(1.0f/16.0f); 32 flipPage2->compile(1.0f/16.0f); 33 34} 35 36void BookModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) 37{ 38 setupAnim(time, r, bob, yRot, xRot, scale, entity); 39 40 leftLid->render(scale,usecompiled); 41 rightLid->render(scale,usecompiled); 42 seam->render(scale,usecompiled); 43 44 leftPages->render(scale,usecompiled); 45 rightPages->render(scale,usecompiled); 46 47 flipPage1->render(scale,usecompiled); 48 flipPage2->render(scale,usecompiled); 49} 50 51void BookModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr<Entity> entity, unsigned int uiBitmaskOverrideAnim) 52{ 53 float openness = (Mth::sin(time * 0.02f) * 0.10f + 1.25f) * yRot; 54 55 leftLid->yRot = PI + openness; 56 rightLid->yRot = -openness; 57 leftPages->yRot = +openness; 58 rightPages->yRot = -openness; 59 60 flipPage1->yRot = +openness - openness * 2 * r; 61 flipPage2->yRot = +openness - openness * 2 * bob; 62 63 leftPages->x = Mth::sin(openness); 64 rightPages->x = Mth::sin(openness); 65 flipPage1->x = Mth::sin(openness); 66 flipPage2->x = Mth::sin(openness); 67} 68