tornado stuff

This commit is contained in:
RandomityGuy 2021-07-13 16:40:39 +05:30
parent b2c56da65e
commit c622e59b6d
6 changed files with 32 additions and 11 deletions

Binary file not shown.

View file

@ -777,7 +777,8 @@ class DtsObject extends GameObject {
vec.transform(mat); vec.transform(mat);
vec = vec.multiply(mesh.weights[i]); vec = vec.multiply(mesh.weights[i]);
vec2.transform3x3(mat);
Util.m_matF_x_vectorF(mat, vec2);
vec2 = vec2.multiply(mesh.weights[i]); vec2 = vec2.multiply(mesh.weights[i]);
info.vertices[vIndex] = info.vertices[vIndex].add(vec); info.vertices[vIndex] = info.vertices[vIndex].add(vec);
@ -786,7 +787,7 @@ class DtsObject extends GameObject {
for (i in 0...info.normals.length) { for (i in 0...info.normals.length) {
var norm = info.normals[i]; var norm = info.normals[i];
var len2 = norm.lengthSq(); var len2 = norm.dot(norm);
if (len2 > 0.01) if (len2 > 0.01)
norm.normalize(); norm.normalize();
@ -820,15 +821,16 @@ class DtsObject extends GameObject {
var vertex = info.vertices[i]; var vertex = info.vertices[i];
var normal = info.normals[i]; var normal = info.normals[i];
prim.points[pos] = vertex.toPoint(); prim.points[pos] = vertex.toPoint();
prim.normals[pos] = normal.toPoint().normalized();
if (prim.buffer != null) { if (prim.buffer != null) {
prim.dirtyFlags[pos] = true; prim.dirtyFlags[pos] = true;
} }
pos++; pos++;
} }
if (prim.buffer != null) { if (prim.buffer != null) {
prim.addNormals(); // prim.addNormals();
for (norm in prim.normals) // for (norm in prim.normals)
norm = norm.multiply(-1); // norm = norm.multiply(-1);
prim.flush(); prim.flush();
} }
if (_regenNormals) { if (_regenNormals) {

View file

@ -68,7 +68,7 @@ class MarbleGame {
if (!paused) { if (!paused) {
world.update(dt); world.update(dt);
} }
if (Key.isPressed(Key.ESCAPE) && world.finishTime == null) { if (Key.isPressed(Key.ESCAPE) && world.finishTime == null && world._ready) {
#if hl #if hl
paused = !paused; paused = !paused;
handlePauseGame(); handlePauseGame();
@ -107,9 +107,11 @@ class MarbleGame {
}); });
canvas.pushDialog(exitGameDlg); canvas.pushDialog(exitGameDlg);
} else { } else {
if (exitGameDlg != null) if (world._ready) {
canvas.popDialog(exitGameDlg); if (exitGameDlg != null)
world.setCursorLock(true); canvas.popDialog(exitGameDlg);
world.setCursorLock(true);
}
} }
} }

View file

@ -168,6 +168,9 @@ class MarbleWorld extends Scheduler {
} }
}; };
this.resourceLoadFuncs.push(() -> {
this.playGui.init(this.scene2d);
});
this.resourceLoadFuncs.push(() -> { this.resourceLoadFuncs.push(() -> {
this.addSimGroup(this.mission.root); this.addSimGroup(this.mission.root);
this._loadingLength = resourceLoadFuncs.length; this._loadingLength = resourceLoadFuncs.length;
@ -222,7 +225,6 @@ class MarbleWorld extends Scheduler {
sky.dmlPath = "data/skies/sky_day.dml"; sky.dmlPath = "data/skies/sky_day.dml";
sky.init(cast this); sky.init(cast this);
playGui.init(scene2d);
scene.addChild(sky); scene.addChild(sky);
} }
@ -728,7 +730,7 @@ class MarbleWorld extends Scheduler {
public function render(e:h3d.Engine) { public function render(e:h3d.Engine) {
if (!_ready) if (!_ready)
asyncLoadResources(); asyncLoadResources();
if (this.playGui != null) if (this.playGui != null && _ready)
this.playGui.render(e); this.playGui.render(e);
} }

View file

@ -1,5 +1,6 @@
package src; package src;
import h3d.Matrix;
import hxd.Key; import hxd.Key;
import h2d.Tile; import h2d.Tile;
import h3d.mat.Texture; import h3d.mat.Texture;
@ -218,4 +219,17 @@ class Util {
keyName = "Space Bar"; keyName = "Space Bar";
return keyName; return keyName;
} }
public static function m_matF_x_vectorF(matrix:Matrix, v:Vector) {
var m = matrix.clone();
m.transpose();
var v0 = v.x, v1 = v.y, v2 = v.z;
var vresult_0 = m._11 * v0 + m._12 * v1 + m._13 * v2;
var vresult_1 = m._21 * v0 + m._22 * v1 + m._23 * v2;
var vresult_2 = m._31 * v0 + m._23 * v1 + m._33 * v2;
v.set(vresult_0, vresult_1, vresult_2);
}
} }

View file

@ -49,6 +49,7 @@ class Tornado extends ForceObject {
this.soundChannel = AudioManager.playSound(ResourceLoader.getAudio("data/sound/tornado.wav"), this.getAbsPos().getPosition(), true); this.soundChannel = AudioManager.playSound(ResourceLoader.getAudio("data/sound/tornado.wav"), this.getAbsPos().getPosition(), true);
for (material in this.materials) { for (material in this.materials) {
material.blendMode = Alpha; material.blendMode = Alpha;
material.mainPass.culling = h3d.mat.Data.Face.None;
} }
} }