the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "MinecartModel.h"
3#include "ModelPart.h"
4
5MinecartModel::MinecartModel() : Model()
6{
7 cubes[0] = new ModelPart(this, 0, 10);
8 cubes[1] = new ModelPart(this, 0, 0);
9 cubes[2] = new ModelPart(this, 0, 0);
10 cubes[3] = new ModelPart(this, 0, 0);
11 cubes[4] = new ModelPart(this, 0, 0);
12 cubes[5] = new ModelPart(this, 44, 10);
13
14 int w = 20;
15 int d = 8;
16 int h = 16;
17 int yOff = 4;
18
19 cubes[0]->addBox((float)(-w / 2), (float)(-h / 2), -1, w, h, 2, 0);
20 cubes[0]->setPos(0, (float)(0 + yOff), 0);
21
22 cubes[5]->addBox((float)(-w / 2 + 1), (float)(-h / 2 + 1), -1, w - 2, h - 2, 1, 0);
23 cubes[5]->setPos(0, (float)(0 + yOff), 0);
24
25 cubes[1]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0);
26 cubes[1]->setPos((float)(-w / 2 + 1), (float)(0 + yOff), 0);
27
28 cubes[2]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0);
29 cubes[2]->setPos((float)(+w / 2 - 1), (float)(0 + yOff), 0);
30
31 cubes[3]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0);
32 cubes[3]->setPos(0, (float)(0 + yOff), (float)(-h / 2 + 1));
33
34 cubes[4]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0);
35 cubes[4]->setPos(0, (float)(0 + yOff), (float)(+h / 2 - 1));
36
37 cubes[0]->xRot = PI / 2;
38 cubes[1]->yRot = PI / 2 * 3;
39 cubes[2]->yRot = PI / 2 * 1;
40 cubes[3]->yRot = PI / 2 * 2;
41 cubes[5]->xRot = -PI / 2;
42
43 // 4J added - compile now to avoid random performance hit first time cubes are rendered
44 for (int i = 0; i < MINECART_LENGTH; i++)
45 {
46 cubes[i]->compile(1.0f/16.0f);
47 }
48}
49
50void MinecartModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled)
51{
52 cubes[5]->y = 4 - bob;
53 for (int i = 0; i < MINECART_LENGTH; i++)
54 {
55 cubes[i]->render(scale, usecompiled);
56 }
57}