the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 59 lines 1.8 kB view raw
1#include "stdafx.h" 2#include "..\Minecraft.World\Random.h" 3#include "..\Minecraft.World\Mth.h" 4#include "GhastModel.h" 5#include "ModelPart.h" 6 7GhastModel::GhastModel() : Model() 8{ 9 int yoffs = -16; 10 body = new ModelPart(this, 0, 0); 11 body->addBox(-8, -8, -8, 16, 16, 16); 12 body->y += (8 + 16) + yoffs; 13 14 Random *random = new Random(1660); 15 for (int i = 0; i < TENTACLESLENGTH; i++) // 4J - 9 was tentacles.length 16 { 17 tentacles[i] = new ModelPart(this, 0, 0); 18 19 float xo = (((i % 3 - (i / 3 % 2) * 0.5f + 0.25f) / 2.0f * 2 - 1) * 5); 20 float yo = (((i / 3) / 2.0f * 2 - 1) * 5); 21 int len = random->nextInt(7) + 8; 22 tentacles[i]->addBox(-1, 0, -1, 2, len, 2); 23 24 tentacles[i]->x = xo; 25 tentacles[i]->z = yo; 26 tentacles[i]->y = (float)(31 + yoffs); 27 } 28 29 // 4J added - compile now to avoid random performance hit first time cubes are rendered 30 body->compile(1.0f/16.0f); 31 for( int i = 0; i < TENTACLESLENGTH; i++ ) 32 { 33 tentacles[i]->compile(1.0f/16.0f); 34 } 35} 36 37void GhastModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr<Entity> entity, unsigned int uiBitmaskOverrideAnim) 38{ 39 for (int i = 0; i < TENTACLESLENGTH; i++) // 4J - 9 was tentacles.length 40 { 41 tentacles[i]->xRot = 0.2f * Mth::sin(bob * 0.3f + i) + 0.4f; 42 } 43} 44 45void GhastModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) 46{ 47 setupAnim(time, r, bob, yRot, xRot, scale, entity); 48 49 glPushMatrix(); 50 glTranslatef(0, .6f, 0); 51 52 body->render(scale, usecompiled); 53 for (int i = 0; i < TENTACLESLENGTH; i++) // 4J - 9 was tentacles.length 54 { 55 tentacles[i]->render(scale, usecompiled); 56 } 57 58 glPopMatrix(); 59}