Haxe 3.3 works.
This commit is contained in:
parent
9debab116c
commit
60dce4b8e9
|
@ -56,9 +56,8 @@ class FirstPersonController extends Trait {
|
|||
}
|
||||
|
||||
var locked = true;
|
||||
|
||||
public function update() {
|
||||
if (Input.occupied) return;
|
||||
if (Input.occupied || !body.bodyCreated) return;
|
||||
|
||||
// Unlock
|
||||
// if (locked &&
|
||||
|
|
|
@ -40,7 +40,7 @@ class PhysicsDrag extends Trait {
|
|||
if (Input.started) {
|
||||
var b = physics.pickClosest(Input.x, Input.y);
|
||||
|
||||
if (b != null && b.mass > 0 && !b.body.value.isKinematicObject()) {
|
||||
if (b != null && b.mass > 0 && !b.body.ptr.isKinematicObject()) {
|
||||
|
||||
setRays();
|
||||
pickedBody = b;
|
||||
|
@ -51,13 +51,13 @@ class PhysicsDrag extends Trait {
|
|||
var pickPos:BtVector3 = physics.rayCallback.value.m_hitPointWorld;
|
||||
#end
|
||||
|
||||
var ct = b.body.value.getCenterOfMassTransform();
|
||||
var ct = b.body.ptr.getCenterOfMassTransform();
|
||||
var inv = ct.inverse();
|
||||
|
||||
#if js
|
||||
var localPivot:BtVector3 = inv.mulVec(pickPos);
|
||||
#elseif cpp
|
||||
var localPivot:BtVector3 = untyped inv * pickPos; // Operator overload
|
||||
var localPivot:BtVector3 = untyped __cpp__("inv.value * pickPos.value"); // Operator overload
|
||||
#end
|
||||
|
||||
var tr = BtTransform.create();
|
||||
|
@ -65,12 +65,13 @@ class PhysicsDrag extends Trait {
|
|||
tr.value.setOrigin(localPivot);
|
||||
|
||||
pickConstraint = BtGeneric6DofConstraint.create(b.body.value, tr.value, false);
|
||||
pickConstraint.value.setLinearLowerLimit(BtVector3.create(0, 0, 0).value);
|
||||
|
||||
pickConstraint.value.setLinearLowerLimit(BtVector3.create(0, 0, 0).value);
|
||||
pickConstraint.value.setLinearUpperLimit(BtVector3.create(0, 0, 0).value);
|
||||
pickConstraint.value.setAngularLowerLimit(BtVector3.create(-10, -10, -10).value);
|
||||
pickConstraint.value.setAngularUpperLimit(BtVector3.create(10, 10, 10).value);
|
||||
|
||||
physics.world.value.addConstraint(pickConstraint, false);
|
||||
physics.world.ptr.addConstraint(pickConstraint, false);
|
||||
|
||||
/*pickConstraint.value.setParam(4, 0.8, 0);
|
||||
pickConstraint.value.setParam(4, 0.8, 1);
|
||||
|
@ -97,7 +98,7 @@ class PhysicsDrag extends Trait {
|
|||
else if (Input.released) {
|
||||
|
||||
if (pickConstraint != null) {
|
||||
physics.world.value.removeConstraint(pickConstraint);
|
||||
physics.world.ptr.removeConstraint(pickConstraint);
|
||||
pickConstraint = null;
|
||||
pickedBody = null;
|
||||
}
|
||||
|
|
|
@ -46,18 +46,18 @@ class PhysicsWorld extends Trait {
|
|||
var solver = BtSequentialImpulseConstraintSolver.create();
|
||||
|
||||
world = BtDiscreteDynamicsWorld.create(dispatcher, broadphase, solver, collisionConfiguration);
|
||||
world.value.setGravity(BtVector3.create(0, 0, -9.81).value);
|
||||
world.ptr.setGravity(BtVector3.create(0, 0, -9.81).value);
|
||||
|
||||
requestUpdate(update);
|
||||
}
|
||||
|
||||
public function addRigidBody(body:RigidBody) {
|
||||
world.value.addRigidBody(body.body);
|
||||
world.ptr.addRigidBody(body.body);
|
||||
rbMap.set(body.id, body);
|
||||
}
|
||||
|
||||
public function removeRigidBody(body:RigidBody) {
|
||||
world.value.removeRigidBody(body.body);
|
||||
world.ptr.removeRigidBody(body.body);
|
||||
#if js
|
||||
Ammo.destroy(body.body);
|
||||
#elseif cpp
|
||||
|
@ -83,10 +83,10 @@ class PhysicsWorld extends Trait {
|
|||
res.push(rbMap.get(c.a));
|
||||
}
|
||||
#elseif cpp
|
||||
if (c.a == body.body.value.getUserIndex()) {
|
||||
if (c.a == body.body.ptr.getUserIndex()) {
|
||||
res.push(rbMap.get(c.b));
|
||||
}
|
||||
else if (c.b == body.body.value.getUserIndex()) {
|
||||
else if (c.b == body.body.ptr.getUserIndex()) {
|
||||
res.push(rbMap.get(c.a));
|
||||
}
|
||||
#end
|
||||
|
@ -95,7 +95,7 @@ class PhysicsWorld extends Trait {
|
|||
}
|
||||
|
||||
public function update() {
|
||||
world.value.stepSimulation(1 / 60);
|
||||
world.ptr.stepSimulation(1 / 60);
|
||||
updateContacts();
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ class PhysicsWorld extends Trait {
|
|||
var rayTo = getRayTo(inputX, inputY);
|
||||
|
||||
rayCallback = ClosestRayResultCallback.create(rayFrom.value, rayTo.value);
|
||||
world.value.rayTest(rayFrom.value, rayTo.value, rayCallback.value);
|
||||
world.ptr.rayTest(rayFrom.value, rayTo.value, rayCallback.value);
|
||||
|
||||
if (rayCallback.value.hasHit()) {
|
||||
#if js
|
||||
|
|
|
@ -34,6 +34,8 @@ class RigidBody extends Trait {
|
|||
public var friction:Float;
|
||||
|
||||
public var body:BtRigidBodyPointer = null;
|
||||
public var bodyCreated = false;
|
||||
public var shapeConvexCreated: Bool;
|
||||
|
||||
static var nextId = 0;
|
||||
public var id = 0;
|
||||
|
@ -53,13 +55,17 @@ class RigidBody extends Trait {
|
|||
}
|
||||
|
||||
public function init() {
|
||||
|
||||
transform = node.transform;
|
||||
physics = Root.physics;
|
||||
|
||||
if (body != null) return;
|
||||
if (bodyCreated) return;
|
||||
bodyCreated = true;
|
||||
|
||||
var _shape:BtCollisionShapePointer = null;
|
||||
var _shapeConvex:BtConvexHullShapePointer = null;
|
||||
shapeConvexCreated = false;
|
||||
var _inertia = BtVector3.create(0, 0, 0);
|
||||
|
||||
if (shape == SHAPE_BOX) {
|
||||
_shape = BtBoxShape.create(BtVector3.create(
|
||||
|
@ -72,6 +78,7 @@ class RigidBody extends Trait {
|
|||
}
|
||||
else if (shape == SHAPE_CONVEX_HULL || shape == SHAPE_MESH) { // Use convex hull for mesh for now
|
||||
_shapeConvex = BtConvexHullShape.create();
|
||||
shapeConvexCreated = true;
|
||||
addPointsToConvexHull(_shapeConvex);
|
||||
}
|
||||
else if (shape == SHAPE_CONE) {
|
||||
|
@ -118,16 +125,15 @@ class RigidBody extends Trait {
|
|||
var _centerOfMassOffset = BtTransform.create();
|
||||
_centerOfMassOffset.value.setIdentity();
|
||||
var _motionState = BtDefaultMotionState.create(_transform.value, _centerOfMassOffset.value);
|
||||
var _inertia = BtVector3.create(0, 0, 0);
|
||||
|
||||
if (_shapeConvex == null) {
|
||||
if (!shapeConvexCreated) {
|
||||
if (shape != SHAPE_STATIC_MESH && shape != SHAPE_TERRAIN) {
|
||||
_shape.value.calculateLocalInertia(mass, _inertia.value);
|
||||
_shape.ptr.calculateLocalInertia(mass, _inertia.value);
|
||||
}
|
||||
var _bodyCI = BtRigidBodyConstructionInfo.create(mass, _motionState, _shape, _inertia.value);
|
||||
body = BtRigidBody.create(_bodyCI.value);
|
||||
body.value.setFriction(friction);
|
||||
body.value.setRollingFriction(friction);
|
||||
body.ptr.setFriction(friction);
|
||||
body.ptr.setRollingFriction(friction);
|
||||
}
|
||||
else {
|
||||
_shapeConvex.value.calculateLocalInertia(mass, _inertia.value);
|
||||
|
@ -142,7 +148,7 @@ class RigidBody extends Trait {
|
|||
//body.setUserIndex(nextId);
|
||||
untyped body.userIndex = id;
|
||||
#elseif cpp
|
||||
body.value.setUserIndex(id);
|
||||
body.ptr.setUserIndex(id);
|
||||
#end
|
||||
|
||||
physics.addRigidBody(this);
|
||||
|
@ -151,77 +157,76 @@ class RigidBody extends Trait {
|
|||
}
|
||||
|
||||
function lateUpdate() {
|
||||
var trans = body.value.getWorldTransform();
|
||||
var trans = body.ptr.getWorldTransform();
|
||||
var p = trans.getOrigin();
|
||||
var q = trans.getRotation();
|
||||
transform.pos.set(p.x(), p.y(), p.z());
|
||||
transform.rot.set(q.x(), q.y(), q.z(), q.w());
|
||||
|
||||
transform.dirty = true;
|
||||
transform.update();
|
||||
}
|
||||
|
||||
public inline function removeFromWorld() {
|
||||
public function removeFromWorld() {
|
||||
physics.removeRigidBody(this);
|
||||
}
|
||||
|
||||
public inline function activate() {
|
||||
body.value.activate(false);
|
||||
public function activate() {
|
||||
body.ptr.activate(false);
|
||||
}
|
||||
|
||||
public inline function disableGravity() {
|
||||
public function disableGravity() {
|
||||
// TODO: use setGravity instead
|
||||
setLinearFactor(0, 0, 0);
|
||||
setAngularFactor(0, 0, 0);
|
||||
}
|
||||
|
||||
/*public inline function setGravity(v:Vec4) {
|
||||
body.value.setGravity(BtVector3.create(v.x, v.y, v.z).value);
|
||||
/*public function setGravity(v:Vec4) {
|
||||
body.ptr.setGravity(BtVector3.create(v.x, v.y, v.z).value);
|
||||
}*/
|
||||
|
||||
/*public inline function setActivationState(newState:Int) {
|
||||
body.value.setActivationState(newState);
|
||||
/*public function setActivationState(newState:Int) {
|
||||
body.ptr.setActivationState(newState);
|
||||
}*/
|
||||
|
||||
public inline function applyImpulse(impulse:Vec4, pos:Vec4 = null) {
|
||||
public function applyImpulse(impulse:Vec4, pos:Vec4 = null) {
|
||||
if (pos == null) {
|
||||
body.value.applyCentralImpulse(BtVector3.create(impulse.x, impulse.y, impulse.z).value);
|
||||
body.ptr.applyCentralImpulse(BtVector3.create(impulse.x, impulse.y, impulse.z).value);
|
||||
}
|
||||
else {
|
||||
body.value.applyImpulse(BtVector3.create(impulse.x, impulse.y, impulse.z).value,
|
||||
body.ptr.applyImpulse(BtVector3.create(impulse.x, impulse.y, impulse.z).value,
|
||||
BtVector3.create(pos.x, pos.y, pos.z).value);
|
||||
}
|
||||
}
|
||||
|
||||
public inline function setLinearFactor(x:Float, y:Float, z:Float) {
|
||||
body.value.setLinearFactor(BtVector3.create(x, y, z).value);
|
||||
public function setLinearFactor(x:Float, y:Float, z:Float) {
|
||||
body.ptr.setLinearFactor(BtVector3.create(x, y, z).value);
|
||||
}
|
||||
|
||||
public inline function setAngularFactor(x:Float, y:Float, z:Float) {
|
||||
body.value.setAngularFactor(BtVector3.create(x, y, z).value);
|
||||
public function setAngularFactor(x:Float, y:Float, z:Float) {
|
||||
body.ptr.setAngularFactor(BtVector3.create(x, y, z).value);
|
||||
}
|
||||
|
||||
// public inline function getLinearVelocity():BtVector3 {
|
||||
// return body.value.getLinearVelocity(); // Unable to compile in cpp
|
||||
// public function getLinearVelocity():BtVector3 {
|
||||
// return body.ptr.getLinearVelocity(); // Unable to compile in cpp
|
||||
// }
|
||||
|
||||
public inline function setLinearVelocity(x:Float, y:Float, z:Float) {
|
||||
body.value.setLinearVelocity(BtVector3.create(x, y, z).value);
|
||||
public function setLinearVelocity(x:Float, y:Float, z:Float) {
|
||||
body.ptr.setLinearVelocity(BtVector3.create(x, y, z).value);
|
||||
}
|
||||
|
||||
// public inline function getAngularVelocity():BtVector3 {
|
||||
// return body.value.getAngularVelocity();
|
||||
// public function getAngularVelocity():BtVector3 {
|
||||
// return body.ptr.getAngularVelocity();
|
||||
// }
|
||||
|
||||
public inline function setAngularVelocity(x:Float, y:Float, z:Float) {
|
||||
body.value.setAngularVelocity(BtVector3.create(x, y, z).value);
|
||||
public function setAngularVelocity(x:Float, y:Float, z:Float) {
|
||||
body.ptr.setAngularVelocity(BtVector3.create(x, y, z).value);
|
||||
}
|
||||
|
||||
public function syncTransform() {
|
||||
var trans = BtTransform.create();
|
||||
trans.value.setOrigin(BtVector3.create(transform.pos.x, transform.pos.y, transform.pos.z).value);
|
||||
trans.value.setRotation(BtQuaternion.create(transform.rot.x, transform.rot.y, transform.rot.z, transform.rot.w).value);
|
||||
body.value.setCenterOfMassTransform(trans.value);
|
||||
body.ptr.setCenterOfMassTransform(trans.value);
|
||||
}
|
||||
|
||||
function addPointsToConvexHull(shape:BtConvexHullShapePointer) {
|
||||
|
|
|
@ -124,14 +124,14 @@ class VehicleBody extends Trait {
|
|||
m_vehicle = BtRaycastVehicle.create(m_tuning.value, m_carChassis, m_vehicleRayCaster);
|
||||
|
||||
// Never deactivate the vehicle
|
||||
m_carChassis.value.setActivationState(BtCollisionObject.DISABLE_DEACTIVATION);
|
||||
m_carChassis.ptr.setActivationState(BtCollisionObject.DISABLE_DEACTIVATION);
|
||||
|
||||
// Choose coordinate system
|
||||
m_vehicle.value.setCoordinateSystem(rightIndex, upIndex, forwardIndex);
|
||||
m_vehicle.ptr.setCoordinateSystem(rightIndex, upIndex, forwardIndex);
|
||||
|
||||
// Add wheels
|
||||
for (w in wheels) {
|
||||
m_vehicle.value.addWheel(
|
||||
m_vehicle.ptr.addWheel(
|
||||
w.connectionPointCS0.value,
|
||||
wheelDirectionCS0.value,
|
||||
wheelAxleCS.value,
|
||||
|
@ -142,8 +142,8 @@ class VehicleBody extends Trait {
|
|||
}
|
||||
|
||||
// Setup wheels
|
||||
for (i in 0...m_vehicle.value.getNumWheels()){
|
||||
var wheel = m_vehicle.value.getWheelInfo(i);
|
||||
for (i in 0...m_vehicle.ptr.getNumWheels()){
|
||||
var wheel = m_vehicle.ptr.getWheelInfo(i);
|
||||
wheel.m_suspensionStiffness = suspensionStiffness;
|
||||
wheel.m_wheelsDampingRelaxation = suspensionDamping;
|
||||
wheel.m_wheelsDampingCompression = suspensionCompression;
|
||||
|
@ -151,7 +151,7 @@ class VehicleBody extends Trait {
|
|||
wheel.m_rollInfluence = rollInfluence;
|
||||
}
|
||||
|
||||
physics.world.value.addAction(m_vehicle);
|
||||
physics.world.ptr.addAction(m_vehicle);
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
@ -179,19 +179,19 @@ class VehicleBody extends Trait {
|
|||
gVehicleSteering = 0;
|
||||
}
|
||||
|
||||
m_vehicle.value.applyEngineForce(gEngineForce, 2);
|
||||
m_vehicle.value.setBrake(gBreakingForce, 2);
|
||||
m_vehicle.value.applyEngineForce(gEngineForce, 3);
|
||||
m_vehicle.value.setBrake(gBreakingForce, 3);
|
||||
m_vehicle.value.setSteeringValue(gVehicleSteering, 0);
|
||||
m_vehicle.value.setSteeringValue(gVehicleSteering, 1);
|
||||
m_vehicle.ptr.applyEngineForce(gEngineForce, 2);
|
||||
m_vehicle.ptr.setBrake(gBreakingForce, 2);
|
||||
m_vehicle.ptr.applyEngineForce(gEngineForce, 3);
|
||||
m_vehicle.ptr.setBrake(gBreakingForce, 3);
|
||||
m_vehicle.ptr.setSteeringValue(gVehicleSteering, 0);
|
||||
m_vehicle.ptr.setSteeringValue(gVehicleSteering, 1);
|
||||
|
||||
for (i in 0...m_vehicle.value.getNumWheels()) {
|
||||
for (i in 0...m_vehicle.ptr.getNumWheels()) {
|
||||
// Synchronize the wheels with the chassis worldtransform
|
||||
m_vehicle.value.updateWheelTransform(i, true);
|
||||
m_vehicle.ptr.updateWheelTransform(i, true);
|
||||
|
||||
// Update wheels transforms
|
||||
var trans = m_vehicle.value.getWheelTransformWS(i);
|
||||
var trans = m_vehicle.ptr.getWheelTransformWS(i);
|
||||
//wheels[i].trans = trans;
|
||||
//wheels[i].syncTransform();
|
||||
var p = trans.getOrigin();
|
||||
|
@ -201,7 +201,7 @@ class VehicleBody extends Trait {
|
|||
wheels[i].node.transform.dirty = true;
|
||||
}
|
||||
|
||||
var trans = m_carChassis.value.getWorldTransform();
|
||||
var trans = m_carChassis.ptr.getWorldTransform();
|
||||
var p = trans.getOrigin();
|
||||
var q = trans.getRotation();
|
||||
transform.pos.set(p.x(), p.y(), p.z());
|
||||
|
@ -225,9 +225,9 @@ class VehicleBody extends Trait {
|
|||
var cInfo = BtRigidBodyConstructionInfo.create(mass, myMotionState, shape, localInertia.value).value;
|
||||
|
||||
var body = BtRigidBody.create(cInfo);
|
||||
body.value.setLinearVelocity(BtVector3.create(0, 0, 0).value);
|
||||
body.value.setAngularVelocity(BtVector3.create(0, 0, 0).value);
|
||||
physics.world.value.addRigidBody(body);
|
||||
body.ptr.setLinearVelocity(BtVector3.create(0, 0, 0).value);
|
||||
body.ptr.setAngularVelocity(BtVector3.create(0, 0, 0).value);
|
||||
physics.world.ptr.addRigidBody(body);
|
||||
|
||||
return body;
|
||||
}
|
||||
|
|
|
@ -227,12 +227,6 @@ void main() {
|
|||
vec4 outColor = vec4(vec3(direct * visibility + indirect * ao), 1.0);
|
||||
|
||||
// outColor.rgb *= occlusion;
|
||||
// outColor.rgb *= ao;
|
||||
|
||||
// outColor = vec4(pow(outColor.rgb, vec3(1.0 / 2.2)), outColor.a);
|
||||
|
||||
gl_FragColor = vec4(outColor.rgb, outColor.a);
|
||||
|
||||
// vec4 aocol = texture(ssaotex, texCoord);
|
||||
// gl_FragColor = aocol;
|
||||
}
|
||||
|
|
|
@ -25,5 +25,6 @@ void main() {
|
|||
// }
|
||||
|
||||
vec3 n = normalize(normal);
|
||||
gl_FragColor = texture(envmap, envMapEquirect(n));
|
||||
// gl_FragColor = texture(envmap, envMapEquirect(n));
|
||||
gl_FragColor = vec4(pow(texture(envmap, envMapEquirect(n)).rgb, vec3(2.2)), 1.0);
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ void main() {
|
|||
hitCoord = viewPos.xyz;
|
||||
|
||||
vec3 dir = reflected * max(minRayStep, -viewPos.z);// * (1.0 - rand(texCoord) * 0.5);
|
||||
vec4 coords = rayCast(dir);
|
||||
vec4 coords = rayCast(dir);
|
||||
|
||||
vec2 deltaCoords = abs(vec2(0.5, 0.5) - coords.xy);
|
||||
float screenEdgeFactor = clamp(1.0 - (deltaCoords.x + deltaCoords.y), 0.0, 1.0);
|
||||
|
|
|
@ -6,8 +6,17 @@ const BrowserWindow = electron.BrowserWindow;
|
|||
let mainWindow;
|
||||
|
||||
function createWindow () {
|
||||
mainWindow = new BrowserWindow({width: 800, height: 600});
|
||||
mainWindow = new BrowserWindow({width: 800, height: 600, frame: false, movable: false, resizable: false, transparent: true});
|
||||
|
||||
mainWindow.setSkipTaskbar(true);
|
||||
// app.dock.setBadge('')
|
||||
|
||||
mainWindow.setAlwaysOnTop(true);
|
||||
mainWindow.setPosition(100, 100);
|
||||
mainWindow.setSize(300, 300);
|
||||
|
||||
mainWindow.loadURL('file://' + __dirname + '/../../../../../build/html5/index.html');
|
||||
// mainWindow.loadURL('http://localhost:8080');
|
||||
mainWindow.on('closed', function() {
|
||||
mainWindow = null;
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue