mirror of
https://github.com/RandomityGuy/MBHaxe.git
synced 2025-10-30 08:11:25 +00:00
Dump DtsTexture, fix the blending bugs and shit, fix triggers
This commit is contained in:
parent
ab58664ced
commit
48132d8ea3
13 changed files with 138 additions and 55 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import h3d.shader.pbr.PropsValues;
|
||||||
import h3d.mat.Material;
|
import h3d.mat.Material;
|
||||||
import src.ResourceLoader;
|
import src.ResourceLoader;
|
||||||
import src.PathedInterior;
|
import src.PathedInterior;
|
||||||
|
|
@ -302,6 +303,7 @@ class DifBuilder {
|
||||||
} else {
|
} else {
|
||||||
material = Material.create();
|
material = Material.create();
|
||||||
}
|
}
|
||||||
|
// material.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1));
|
||||||
// material.mainPass.wireframe = true;
|
// material.mainPass.wireframe = true;
|
||||||
|
|
||||||
var mesh = new Mesh(prim, material, itr);
|
var mesh = new Mesh(prim, material, itr);
|
||||||
|
|
|
||||||
|
|
@ -333,11 +333,11 @@ class DtsObject extends GameObject {
|
||||||
texture.wrap = Wrap.Repeat;
|
texture.wrap = Wrap.Repeat;
|
||||||
material.texture = texture;
|
material.texture = texture;
|
||||||
// if (this.useInstancing) {
|
// if (this.useInstancing) {
|
||||||
var dtsshader = new DtsTexture();
|
// var dtsshader = new DtsTexture();
|
||||||
dtsshader.texture = texture;
|
// dtsshader.texture = texture;
|
||||||
dtsshader.currentOpacity = 1;
|
// dtsshader.currentOpacity = 1;
|
||||||
material.mainPass.removeShader(material.textureShader);
|
// material.mainPass.removeShader(material.textureShader);
|
||||||
material.mainPass.addShader(dtsshader);
|
// material.mainPass.addShader(dtsshader);
|
||||||
// }
|
// }
|
||||||
// TODO TRANSLUENCY SHIT
|
// TODO TRANSLUENCY SHIT
|
||||||
}
|
}
|
||||||
|
|
@ -354,11 +354,15 @@ class DtsObject extends GameObject {
|
||||||
}
|
}
|
||||||
if (flags & 4 > 0) {
|
if (flags & 4 > 0) {
|
||||||
material.blendMode = BlendMode.Alpha;
|
material.blendMode = BlendMode.Alpha;
|
||||||
material.mainPass.culling = h3d.mat.Data.Face.Front;
|
material.mainPass.depthWrite = false;
|
||||||
|
// material.mainPass.culling = h3d.mat.Data.Face.Front;
|
||||||
}
|
}
|
||||||
// TODO TRANSPARENCY SHIT
|
// TODO TRANSPARENCY SHIT
|
||||||
if (flags & 8 > 0)
|
if (flags & 8 > 0) {
|
||||||
material.blendMode = BlendMode.Add;
|
material.blendMode = BlendMode.Add;
|
||||||
|
material.mainPass.setPassName("overlay");
|
||||||
|
// material.textureShader.additive = true;
|
||||||
|
}
|
||||||
if (flags & 16 > 0)
|
if (flags & 16 > 0)
|
||||||
material.blendMode = BlendMode.Sub;
|
material.blendMode = BlendMode.Sub;
|
||||||
|
|
||||||
|
|
@ -367,7 +371,7 @@ class DtsObject extends GameObject {
|
||||||
// }
|
// }
|
||||||
// ((flags & 32) || environmentMaterial) ? new Materia
|
// ((flags & 32) || environmentMaterial) ? new Materia
|
||||||
|
|
||||||
material.mainPass.addShader(new AlphaMult());
|
// material.mainPass.addShader(new AlphaMult());
|
||||||
|
|
||||||
this.materials.push(material);
|
this.materials.push(material);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ class InstanceManager {
|
||||||
minfo.meshbatch.begin(opaqueinstances.length);
|
minfo.meshbatch.begin(opaqueinstances.length);
|
||||||
for (instance in opaqueinstances) { // Draw the opaque shit first
|
for (instance in opaqueinstances) { // Draw the opaque shit first
|
||||||
var transform = instance.emptyObj.getAbsPos().clone();
|
var transform = instance.emptyObj.getAbsPos().clone();
|
||||||
|
minfo.meshbatch.material.mainPass.setPassName(minfo.mesh.material.mainPass.name);
|
||||||
minfo.meshbatch.setTransform(transform);
|
minfo.meshbatch.setTransform(transform);
|
||||||
minfo.meshbatch.emitInstance();
|
minfo.meshbatch.emitInstance();
|
||||||
}
|
}
|
||||||
|
|
@ -48,12 +49,15 @@ class InstanceManager {
|
||||||
var transparentinstances = minfo.instances.filter(x -> x.gameObject.currentOpacity != 1);
|
var transparentinstances = minfo.instances.filter(x -> x.gameObject.currentOpacity != 1);
|
||||||
minfo.transparencymeshbatch.begin(transparentinstances.length);
|
minfo.transparencymeshbatch.begin(transparentinstances.length);
|
||||||
for (instance in transparentinstances) { // Non opaque shit
|
for (instance in transparentinstances) { // Non opaque shit
|
||||||
var dtsShader = minfo.transparencymeshbatch.material.mainPass.getShader(DtsTexture);
|
var dtsShader = minfo.transparencymeshbatch.material.mainPass.getShader(h3d.shader.Texture);
|
||||||
minfo.transparencymeshbatch.material.blendMode = Alpha;
|
minfo.transparencymeshbatch.material.blendMode = Alpha;
|
||||||
if (dtsShader != null) {
|
minfo.transparencymeshbatch.material.color.a = instance.gameObject.currentOpacity;
|
||||||
dtsShader.currentOpacity = instance.gameObject.currentOpacity;
|
minfo.transparencymeshbatch.material.mainPass.setPassName(minfo.mesh.material.mainPass.name);
|
||||||
minfo.transparencymeshbatch.shadersChanged = true;
|
minfo.transparencymeshbatch.shadersChanged = true;
|
||||||
}
|
// if (dtsShader != null) {
|
||||||
|
// dtsShader.currentOpacity = instance.gameObject.currentOpacity;
|
||||||
|
// minfo.transparencymeshbatch.shadersChanged = true;
|
||||||
|
// }
|
||||||
var transform = instance.emptyObj.getAbsPos().clone();
|
var transform = instance.emptyObj.getAbsPos().clone();
|
||||||
minfo.transparencymeshbatch.setTransform(transform);
|
minfo.transparencymeshbatch.setTransform(transform);
|
||||||
minfo.transparencymeshbatch.emitInstance();
|
minfo.transparencymeshbatch.emitInstance();
|
||||||
|
|
@ -93,14 +97,17 @@ class InstanceManager {
|
||||||
}
|
}
|
||||||
if (isMesh) {
|
if (isMesh) {
|
||||||
var mat = cast(obj, Mesh).material;
|
var mat = cast(obj, Mesh).material;
|
||||||
var dtsshader = mat.mainPass.getShader(DtsTexture);
|
// var dtsshader = mat.mainPass.getShader(DtsTexture);
|
||||||
if (dtsshader != null) {
|
// if (dtsshader != null) {
|
||||||
minfo.meshbatch.material.mainPass.removeShader(minfo.meshbatch.material.textureShader);
|
// minfo.meshbatch.material.mainPass.removeShader(minfo.meshbatch.material.textureShader);
|
||||||
minfo.meshbatch.material.mainPass.addShader(dtsshader);
|
// minfo.meshbatch.material.mainPass.addShader(dtsshader);
|
||||||
}
|
// }
|
||||||
minfo.transparencymeshbatch = new MeshBatch(cast(cast(obj, Mesh).primitive), cast(cast(obj, Mesh)).material.clone(), scene);
|
minfo.transparencymeshbatch = new MeshBatch(cast(cast(obj, Mesh).primitive), cast(cast(obj, Mesh)).material.clone(), scene);
|
||||||
minfo.transparencymeshbatch.material.mainPass.removeShader(minfo.meshbatch.material.textureShader);
|
// minfo.transparencymeshbatch.material.mainPass.removeShader(minfo.meshbatch.material.textureShader);
|
||||||
minfo.transparencymeshbatch.material.mainPass.addShader(dtsshader);
|
// minfo.transparencymeshbatch.material.mainPass.addShader(dtsshader);
|
||||||
|
|
||||||
|
minfo.meshbatch.material.mainPass.removeShader(minfo.meshbatch.material.mainPass.getShader(PropsValues));
|
||||||
|
minfo.transparencymeshbatch.material.mainPass.removeShader(minfo.transparencymeshbatch.material.mainPass.getShader(PropsValues));
|
||||||
|
|
||||||
var pbrshader = mat.mainPass.getShader(PropsValues);
|
var pbrshader = mat.mainPass.getShader(PropsValues);
|
||||||
if (pbrshader != null) {
|
if (pbrshader != null) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import h3d.scene.Object;
|
||||||
class InteriorObject extends GameObject {
|
class InteriorObject extends GameObject {
|
||||||
public var collider:CollisionEntity;
|
public var collider:CollisionEntity;
|
||||||
public var interiorFile:String;
|
public var interiorFile:String;
|
||||||
public var useInstancing = true;
|
public var useInstancing = false;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
|
|
|
||||||
|
|
@ -61,10 +61,6 @@ class Main extends hxd.App {
|
||||||
|
|
||||||
world = new MarbleWorld(s3d, s2d, mission);
|
world = new MarbleWorld(s3d, s2d, mission);
|
||||||
|
|
||||||
var dirlight = new DirLight(new Vector(0.5, 0.5, -0.5), s3d);
|
|
||||||
dirlight.enableSpecular = true;
|
|
||||||
s3d.lightSystem.ambientLight.set(0.3, 0.3, 0.3);
|
|
||||||
|
|
||||||
world.init();
|
world.init();
|
||||||
|
|
||||||
// s3d.camera.
|
// s3d.camera.
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,6 @@ class Marble extends GameObject {
|
||||||
for (i in 0...contacts.length) {
|
for (i in 0...contacts.length) {
|
||||||
var sVel = this.velocity.sub(contacts[i].velocity);
|
var sVel = this.velocity.sub(contacts[i].velocity);
|
||||||
var surfaceDot = contacts[i].normal.dot(sVel);
|
var surfaceDot = contacts[i].normal.dot(sVel);
|
||||||
trace(contacts[i].normal.length());
|
|
||||||
|
|
||||||
if ((!looped && surfaceDot < 0) || surfaceDot < -SurfaceDotThreshold) {
|
if ((!looped && surfaceDot < 0) || surfaceDot < -SurfaceDotThreshold) {
|
||||||
var velLen = this.velocity.length();
|
var velLen = this.velocity.length();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package src;
|
package src;
|
||||||
|
|
||||||
|
import h3d.scene.pbr.DirLight;
|
||||||
|
import h3d.col.Bounds;
|
||||||
import triggers.HelpTrigger;
|
import triggers.HelpTrigger;
|
||||||
import triggers.InBoundsTrigger;
|
import triggers.InBoundsTrigger;
|
||||||
import triggers.OutOfBoundsTrigger;
|
import triggers.OutOfBoundsTrigger;
|
||||||
|
|
@ -127,18 +129,47 @@ class MarbleWorld extends Scheduler {
|
||||||
};
|
};
|
||||||
scanMission(this.mission.root);
|
scanMission(this.mission.root);
|
||||||
|
|
||||||
|
this.initScene();
|
||||||
|
|
||||||
|
this.addSimGroup(this.mission.root);
|
||||||
|
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function initScene() {
|
||||||
this.collisionWorld = new CollisionWorld();
|
this.collisionWorld = new CollisionWorld();
|
||||||
this.playGui = new PlayGui();
|
this.playGui = new PlayGui();
|
||||||
this.instanceManager = new InstanceManager(scene);
|
this.instanceManager = new InstanceManager(scene);
|
||||||
this.particleManager = new ParticleManager(cast this);
|
this.particleManager = new ParticleManager(cast this);
|
||||||
|
|
||||||
|
var renderer = cast(this.scene.renderer, h3d.scene.pbr.Renderer);
|
||||||
|
|
||||||
|
renderer.skyMode = Hide;
|
||||||
|
|
||||||
|
for (element in mission.root.elements) {
|
||||||
|
if (element._type != MissionElementType.Sun)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var sunElement:MissionElementSun = cast element;
|
||||||
|
|
||||||
|
var directionalColor = MisParser.parseVector4(sunElement.color);
|
||||||
|
var ambientColor = MisParser.parseVector4(sunElement.ambient);
|
||||||
|
var sunDirection = MisParser.parseVector3(sunElement.direction);
|
||||||
|
sunDirection.x = -sunDirection.x;
|
||||||
|
|
||||||
|
scene.lightSystem.ambientLight.load(ambientColor);
|
||||||
|
|
||||||
|
var sunlight = new DirLight(sunDirection, scene);
|
||||||
|
sunlight.color = directionalColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// var skyElement:MissionElementSky = cast this.mission.root.elements.filter((element) -> element._type == MissionElementType.Sky)[0];
|
||||||
|
|
||||||
this.sky = new Sky();
|
this.sky = new Sky();
|
||||||
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);
|
playGui.init(scene2d);
|
||||||
scene.addChild(sky);
|
scene.addChild(sky);
|
||||||
|
|
||||||
this.addSimGroup(this.mission.root);
|
|
||||||
this.playGui.formatGemCounter(this.gemCount, this.totalGems);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function start() {
|
public function start() {
|
||||||
|
|
@ -427,8 +458,6 @@ class MarbleWorld extends Scheduler {
|
||||||
public function addTrigger(element:MissionElementTrigger) {
|
public function addTrigger(element:MissionElementTrigger) {
|
||||||
var trigger:Trigger = null;
|
var trigger:Trigger = null;
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Create a trigger based on type
|
// Create a trigger based on type
|
||||||
if (element.datablock == "OutOfBoundsTrigger") {
|
if (element.datablock == "OutOfBoundsTrigger") {
|
||||||
trigger = new OutOfBoundsTrigger(element, cast this);
|
trigger = new OutOfBoundsTrigger(element, cast this);
|
||||||
|
|
@ -627,17 +656,26 @@ class MarbleWorld extends Scheduler {
|
||||||
}
|
}
|
||||||
if (contact.go is Trigger) {
|
if (contact.go is Trigger) {
|
||||||
var trigger:Trigger = cast contact.go;
|
var trigger:Trigger = cast contact.go;
|
||||||
var contacttest = trigger.collider.sphereIntersection(contactsphere, timeState);
|
var triggeraabb = trigger.collider.boundingBox;
|
||||||
if (contacttest.length != 0) {
|
|
||||||
trigger.onMarbleContact(timeState);
|
|
||||||
}
|
|
||||||
|
|
||||||
trigger.onMarbleInside(timeState);
|
var box = new Bounds();
|
||||||
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
var center = marble.collider.transform.getPosition();
|
||||||
this.shapeOrTriggerInside.push(contact.go);
|
var radius = marble._radius;
|
||||||
trigger.onMarbleEnter(timeState);
|
box.xMin = center.x - radius;
|
||||||
|
box.yMin = center.y - radius;
|
||||||
|
box.zMin = center.z - radius;
|
||||||
|
box.xMax = center.x + radius;
|
||||||
|
box.yMax = center.y + radius;
|
||||||
|
box.zMax = center.z + radius;
|
||||||
|
|
||||||
|
if (triggeraabb.collide(box)) {
|
||||||
|
trigger.onMarbleInside(timeState);
|
||||||
|
if (!this.shapeOrTriggerInside.contains(contact.go)) {
|
||||||
|
this.shapeOrTriggerInside.push(contact.go);
|
||||||
|
trigger.onMarbleEnter(timeState);
|
||||||
|
}
|
||||||
|
inside.push(contact.go);
|
||||||
}
|
}
|
||||||
inside.push(contact.go);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,7 @@ class ParticleManager {
|
||||||
particleShader.scale = instance.scale;
|
particleShader.scale = instance.scale;
|
||||||
particleShader.rotation = instance.rotation;
|
particleShader.rotation = instance.rotation;
|
||||||
batch.meshBatch.material.blendMode = instance.o.blending;
|
batch.meshBatch.material.blendMode = instance.o.blending;
|
||||||
|
batch.meshBatch.material.mainPass.setPassName("overlay");
|
||||||
batch.meshBatch.material.color.load(instance.color);
|
batch.meshBatch.material.color.load(instance.color);
|
||||||
batch.meshBatch.shadersChanged = true;
|
batch.meshBatch.shadersChanged = true;
|
||||||
batch.meshBatch.setScale(instance.scale);
|
batch.meshBatch.setScale(instance.scale);
|
||||||
|
|
@ -321,9 +322,11 @@ class ParticleManager {
|
||||||
prim.uvs = [new UV(0, 0), new UV(0, 1), new UV(1, 0), new UV(1, 1)];
|
prim.uvs = [new UV(0, 0), new UV(0, 1), new UV(1, 0), new UV(1, 1)];
|
||||||
prim.addNormals();
|
prim.addNormals();
|
||||||
var mat = Material.create(particleData.texture);
|
var mat = Material.create(particleData.texture);
|
||||||
mat.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1));
|
// matshader.texture = mat.texture;
|
||||||
|
mat.mainPass.enableLights = false;
|
||||||
|
mat.mainPass.setPassName("overlay");
|
||||||
|
// mat.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1));
|
||||||
mat.texture.wrap = Wrap.Repeat;
|
mat.texture.wrap = Wrap.Repeat;
|
||||||
mat.blendMode = Alpha;
|
|
||||||
var billboardShader = new Billboard();
|
var billboardShader = new Billboard();
|
||||||
mat.mainPass.addShader(billboardShader);
|
mat.mainPass.addShader(billboardShader);
|
||||||
var mb = new MeshBatch(prim, mat, this.scene);
|
var mb = new MeshBatch(prim, mat, this.scene);
|
||||||
|
|
|
||||||
12
src/Sky.hx
12
src/Sky.hx
|
|
@ -28,12 +28,20 @@ class Sky extends Object {
|
||||||
var skyMesh = new h3d.scene.Mesh(sky, this);
|
var skyMesh = new h3d.scene.Mesh(sky, this);
|
||||||
skyMesh.material.mainPass.culling = Front;
|
skyMesh.material.mainPass.culling = Front;
|
||||||
// This is such a hack
|
// This is such a hack
|
||||||
skyMesh.material.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1));
|
// skyMesh.material.mainPass.addShader(new h3d.shader.pbr.PropsValues(1, 0, 0, 1));
|
||||||
|
skyMesh.material.mainPass.enableLights = false;
|
||||||
|
skyMesh.material.receiveShadows = false;
|
||||||
skyMesh.material.blendMode = None;
|
skyMesh.material.blendMode = None;
|
||||||
|
var pbrprops = skyMesh.material.mainPass.getShader(PropsValues);
|
||||||
|
pbrprops.emissiveValue = 1;
|
||||||
|
pbrprops.roughnessValue = 0;
|
||||||
|
pbrprops.occlusionValue = 0;
|
||||||
|
pbrprops.metalnessValue = 1;
|
||||||
|
|
||||||
skyMesh.scale(200);
|
skyMesh.scale(200);
|
||||||
var env = new Environment(texture);
|
var env = new Environment(texture);
|
||||||
env.compute();
|
env.compute();
|
||||||
var renderer = cast(level.scene.renderer, h3d.scene.pbr.Renderer);
|
// var renderer = cast(level.scene.renderer, h3d.scene.pbr.Renderer);
|
||||||
var shad = new h3d.shader.pbr.CubeLod(texture);
|
var shad = new h3d.shader.pbr.CubeLod(texture);
|
||||||
skyMesh.material.mainPass.addShader(shad);
|
skyMesh.material.mainPass.addShader(shad);
|
||||||
skyMesh.material.shadows = false;
|
skyMesh.material.shadows = false;
|
||||||
|
|
|
||||||
|
|
@ -234,9 +234,9 @@ class PlayGui {
|
||||||
this.helpTextForeground.text = text;
|
this.helpTextForeground.text = text;
|
||||||
this.helpTextBackground.text = text;
|
this.helpTextBackground.text = text;
|
||||||
helpTextForeground.x = scene2d.width / 2 - helpTextForeground.textWidth / 2;
|
helpTextForeground.x = scene2d.width / 2 - helpTextForeground.textWidth / 2;
|
||||||
helpTextForeground.y = scene2d.height - 102;
|
helpTextForeground.y = scene2d.height * 0.45;
|
||||||
helpTextBackground.x = scene2d.width / 2 - helpTextBackground.textWidth / 2 + 1;
|
helpTextBackground.x = scene2d.width / 2 - helpTextBackground.textWidth / 2 + 1;
|
||||||
helpTextBackground.y = scene2d.height - 102 + 1;
|
helpTextBackground.y = scene2d.height * 0.45 + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setPowerupImage(powerupIdentifier:String) {
|
public function setPowerupImage(powerupIdentifier:String) {
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,12 @@ class DtsTexture extends hxsl.Shader {
|
||||||
if (killAlpha && c.a - killAlphaThreshold < 0)
|
if (killAlpha && c.a - killAlphaThreshold < 0)
|
||||||
discard;
|
discard;
|
||||||
if (additive)
|
if (additive)
|
||||||
pixelColor += c;
|
pixelColor = c;
|
||||||
else
|
else
|
||||||
pixelColor *= c;
|
pixelColor *= c;
|
||||||
if (specularAlpha)
|
if (specularAlpha)
|
||||||
specColor *= c.aaa;
|
specColor *= c.aaa;
|
||||||
pixelColor.a = c.a * currentOpacity;
|
pixelColor.a *= c.a * currentOpacity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ class Gem extends DtsObject {
|
||||||
ambientRotate = true;
|
ambientRotate = true;
|
||||||
isCollideable = false;
|
isCollideable = false;
|
||||||
pickedUp = false;
|
pickedUp = false;
|
||||||
|
useInstancing = true;
|
||||||
showSequences = false; // Gems actually have an animation for the little shiny thing, but the actual game ignores that. I get it, it was annoying as hell.
|
showSequences = false; // Gems actually have an animation for the little shiny thing, but the actual game ignores that. I get it, it was annoying as hell.
|
||||||
|
|
||||||
var GEM_COLORS = ["blue", "red", "yellow", "purple", "green", "turquoise", "orange", "black"];
|
var GEM_COLORS = ["blue", "red", "yellow", "purple", "green", "turquoise", "orange", "black"];
|
||||||
|
|
@ -29,7 +30,13 @@ class Gem extends DtsObject {
|
||||||
super.init(level);
|
super.init(level);
|
||||||
|
|
||||||
for (material in this.materials) {
|
for (material in this.materials) {
|
||||||
material.mainPass.addShader(new PropsValues(1, 0, 0, 1));
|
material.mainPass.enableLights = false;
|
||||||
|
var pbrprops = material.mainPass.getShader(h3d.shader.pbr.PropsValues);
|
||||||
|
pbrprops.emissiveValue = 1;
|
||||||
|
pbrprops.roughnessValue = 0;
|
||||||
|
pbrprops.occlusionValue = 0;
|
||||||
|
pbrprops.metalnessValue = 1;
|
||||||
|
// material.mainPass.addShader(new PropsValues(1, 0, 0, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
package triggers;
|
package triggers;
|
||||||
|
|
||||||
|
import h3d.scene.Mesh;
|
||||||
|
import h3d.mat.Material;
|
||||||
|
import h3d.prim.Cube;
|
||||||
import h3d.col.Bounds;
|
import h3d.col.Bounds;
|
||||||
import h3d.Matrix;
|
import h3d.Matrix;
|
||||||
import h3d.Vector;
|
import h3d.Vector;
|
||||||
|
|
@ -23,10 +26,10 @@ class Trigger extends GameObject {
|
||||||
this.level = level;
|
this.level = level;
|
||||||
var coordinates = MisParser.parseNumberList(element.polyhedron);
|
var coordinates = MisParser.parseNumberList(element.polyhedron);
|
||||||
|
|
||||||
var origin = new Vector(coordinates[0], coordinates[1], coordinates[2]);
|
var origin = new Vector(-coordinates[0], coordinates[1], coordinates[2]);
|
||||||
var d1 = new Vector(coordinates[3], coordinates[4], coordinates[5]);
|
var d1 = new Vector(-coordinates[3], coordinates[4], coordinates[5]);
|
||||||
var d2 = new Vector(coordinates[6], coordinates[7], coordinates[8]);
|
var d2 = new Vector(-coordinates[6], coordinates[7], coordinates[8]);
|
||||||
var d3 = new Vector(coordinates[9], coordinates[10], coordinates[11]);
|
var d3 = new Vector(-coordinates[9], coordinates[10], coordinates[11]);
|
||||||
|
|
||||||
// Create the 8 points of the parallelepiped
|
// Create the 8 points of the parallelepiped
|
||||||
var p1 = origin.clone();
|
var p1 = origin.clone();
|
||||||
|
|
@ -40,18 +43,34 @@ class Trigger extends GameObject {
|
||||||
|
|
||||||
var mat = new Matrix();
|
var mat = new Matrix();
|
||||||
var quat = MisParser.parseRotation(element.rotation);
|
var quat = MisParser.parseRotation(element.rotation);
|
||||||
|
// quat.x = -quat.x;
|
||||||
|
// quat.w = -quat.w;
|
||||||
quat.toMatrix(mat);
|
quat.toMatrix(mat);
|
||||||
var scale = MisParser.parseVector3(element.scale);
|
var scale = MisParser.parseVector3(element.scale);
|
||||||
mat.scale(scale.x, scale.y, scale.z);
|
mat.scale(scale.x, scale.y, scale.z);
|
||||||
mat.setPosition(MisParser.parseVector3(element.position));
|
var pos = MisParser.parseVector3(element.position);
|
||||||
|
pos.x = -pos.x;
|
||||||
|
// mat.setPosition(pos);
|
||||||
|
|
||||||
var vertices = [p1, p2, p3, p4, p5, p6, p7, p8].map((vert) -> vert.transformed(mat));
|
var vertices = [p1, p2, p3, p4, p5, p6, p7, p8].map((vert) -> vert.transformed(mat));
|
||||||
|
|
||||||
var boundingbox = new Bounds();
|
var boundingbox = new Bounds();
|
||||||
for (vector in vertices) {
|
for (vector in vertices) {
|
||||||
boundingbox.addPoint(vector.toPoint());
|
boundingbox.addPoint(vector.add(pos).toPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
collider = new BoxCollisionEntity(boundingbox, this);
|
collider = new BoxCollisionEntity(boundingbox, this);
|
||||||
|
|
||||||
|
// var cub = new Cube(boundingbox.xSize, boundingbox.ySize, boundingbox.zSize);
|
||||||
|
// cub.addUVs();
|
||||||
|
// cub.addNormals();
|
||||||
|
// var mat = Material.create();
|
||||||
|
// mat.mainPass.wireframe = true;
|
||||||
|
// var mesh = new Mesh(cub, mat, level.scene);
|
||||||
|
// // var m1 = new Mesh(cub, mat, level.scene);
|
||||||
|
// // m1.setPosition(boundingbox.xMin, boundingbox.yMin, boundingbox.zMin);
|
||||||
|
// // var m2 = new Mesh(cub, mat, level.scene);
|
||||||
|
// // m2.setPosition(boundingbox.xMax, boundingbox.yMax, boundingbox.zMax);
|
||||||
|
// mesh.setPosition(boundingbox.xMin, boundingbox.yMin, boundingbox.zMin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue