2017-09-08 09:24:16 -07:00
|
|
|
//
|
|
|
|
// race3DUI.js
|
|
|
|
//--------------------
|
|
|
|
// by RHY3756547
|
|
|
|
//
|
|
|
|
// includes:
|
|
|
|
// render stuff idk
|
|
|
|
//
|
|
|
|
|
|
|
|
window.Race3DUI = function(scene, type, animStart) {
|
|
|
|
//type: count, goal, start, lose, win
|
|
|
|
var forceBill;
|
|
|
|
var obji = obji;
|
|
|
|
var res = [];
|
|
|
|
|
|
|
|
var t = this;
|
|
|
|
|
|
|
|
t.pos = vec3.clone([0,0,0]);
|
|
|
|
|
|
|
|
t.update = update;
|
|
|
|
t.draw = draw;
|
|
|
|
|
|
|
|
var mat = mat4.create();
|
|
|
|
var frame = 0;
|
|
|
|
var anim = null;
|
|
|
|
var animFrame = 0;
|
|
|
|
if (animStart != null) animFrame = animStart;
|
|
|
|
var animMat = null;
|
|
|
|
var model = null;
|
|
|
|
var proj = mat4.create();
|
|
|
|
var length = 0;
|
|
|
|
|
|
|
|
var params = {
|
|
|
|
"count": [ //offset 21 down
|
2019-06-09 15:50:55 -07:00
|
|
|
-128/1024, 128/1024, -(96)/1024, 96/1024
|
2017-09-08 09:24:16 -07:00
|
|
|
],
|
|
|
|
"start": [ //offset 86 up
|
2019-06-09 15:50:55 -07:00
|
|
|
-128/1024, 128/1024, -(96)/1024, 96/1024
|
2019-05-28 17:08:48 -07:00
|
|
|
],
|
|
|
|
"goal": [ //why are these all so different?
|
2019-06-09 15:50:55 -07:00
|
|
|
-128/1024, 128/1024, -(96)/1024, 96/1024
|
|
|
|
//-128/1024, 128/1024, -(512 + 64)/1024, -(512 - 128)/1024
|
2019-05-28 17:08:48 -07:00
|
|
|
],
|
|
|
|
|
|
|
|
//animations seem completely broken for these two (quickly files off screen after start)
|
|
|
|
//right now the vertical range of the viewport is large to try figure out where the hell it's going?
|
|
|
|
"win": [
|
2019-06-09 15:50:55 -07:00
|
|
|
-128/1024, 128/1024, -(96)/1024, 96/1024
|
|
|
|
//-128/1024, 128/1024, -(1024)/1024, 1024/1024
|
2019-05-28 17:08:48 -07:00
|
|
|
],
|
|
|
|
"lose": [
|
2019-06-09 15:50:55 -07:00
|
|
|
-128/1024, 128/1024, -(96)/1024, 96/1024
|
|
|
|
//-128/1024, 128/1024, -(1024)/1024, 1024/1024
|
2019-05-28 17:08:48 -07:00
|
|
|
],
|
2017-09-08 09:24:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
var param = params[type];
|
2019-05-28 17:08:48 -07:00
|
|
|
if (param == null) param = params["count"];
|
2017-09-08 09:24:16 -07:00
|
|
|
|
|
|
|
mat4.ortho(proj, param[0], param[1], param[2], param[3], -0.001, 10);
|
|
|
|
buildOrtho(nitroRender.getViewWidth(), nitroRender.getViewHeight());
|
|
|
|
var lastWidth = 0;
|
|
|
|
initRes();
|
|
|
|
|
|
|
|
function initRes() {
|
|
|
|
var bmd = scene.gameRes.Race.getFile(type+".nsbmd");
|
|
|
|
if (bmd == null) bmd = scene.gameRes.RaceLoc.getFile(type+".nsbmd");
|
|
|
|
|
|
|
|
bmd = new nsbmd(bmd);
|
|
|
|
|
|
|
|
var bca = new nsbca(scene.gameRes.Race.getFile(type+".nsbca"));
|
2019-05-28 17:08:48 -07:00
|
|
|
var btp = scene.gameRes.Race.getFile(type+".nsbtp");
|
|
|
|
if (btp != null) btp = new nsbtp(btp);
|
2017-09-08 09:24:16 -07:00
|
|
|
anim = new nitroAnimator(bmd, bca);
|
|
|
|
length = anim.getLength(0);
|
|
|
|
if (type == "count") length *= 3;
|
|
|
|
model = new nitroModel(bmd);
|
2019-05-28 17:08:48 -07:00
|
|
|
model.loadTexPAnim(btp)
|
2017-09-08 09:24:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function buildOrtho(width, height) {
|
|
|
|
lastWidth = width;
|
|
|
|
var ratio = width / height;
|
|
|
|
var w = (param[3]-param[2]) * ratio/2;
|
|
|
|
mat4.ortho(proj, -w, w, param[2], param[3], -0.001, 10);
|
|
|
|
}
|
|
|
|
|
|
|
|
function draw(view, pMatrix) {
|
|
|
|
if (nitroRender.flagShadow || animFrame < 0) return;
|
|
|
|
var width = nitroRender.getViewWidth();
|
|
|
|
if (width != lastWidth) buildOrtho(width, nitroRender.getViewHeight());
|
|
|
|
mat4.translate(mat, view, t.pos);
|
2019-05-28 17:08:48 -07:00
|
|
|
nitroRender.pauseShadowMode();
|
2017-09-08 09:24:16 -07:00
|
|
|
model.draw(mat, proj, animMat);
|
2019-05-28 17:08:48 -07:00
|
|
|
nitroRender.unpauseShadowMode();
|
2017-09-08 09:24:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
if (anim != null) {
|
2019-05-28 17:08:48 -07:00
|
|
|
model.setFrame(animFrame);
|
2017-09-08 09:24:16 -07:00
|
|
|
animMat = anim.setFrame(0, 0, Math.max(0, animFrame++));
|
|
|
|
}
|
|
|
|
if (animFrame > length) {
|
|
|
|
scene.removeEntity(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|