Tessellation instancing & fixes.
This commit is contained in:
parent
f7e9d964a7
commit
e7ba7c30ba
|
@ -25,23 +25,27 @@ class FirstPersonController extends Trait {
|
|||
var moveRight = false;
|
||||
var jump = false;
|
||||
|
||||
static inline var rotationSpeed = 1.0;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
notifyOnInit(init);
|
||||
notifyOnUpdate(update);
|
||||
kha.input.Keyboard.get().notify(onDown, onUp);
|
||||
Scene.active.notifyOnInit(init);
|
||||
}
|
||||
|
||||
function init() {
|
||||
transform = object.transform;
|
||||
body = object.getTrait(RigidBody);
|
||||
|
||||
for (o in object.children) {
|
||||
if (Std.is(o, CameraObject)) {
|
||||
camera = cast(o, CameraObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
notifyOnUpdate(update);
|
||||
kha.input.Keyboard.get().notify(onDown, onUp);
|
||||
}
|
||||
|
||||
function onDown(key: kha.Key, char: String) {
|
||||
|
@ -60,79 +64,60 @@ class FirstPersonController extends Trait {
|
|||
else if (char == "x") jump = false;
|
||||
}
|
||||
|
||||
var locked = true;
|
||||
public function update() {
|
||||
var dir = new Vec4();
|
||||
var force = new Vec4();
|
||||
var xVec = new Vec4(1, 0, 0);
|
||||
var zVec = new Vec4(1, 0, 0);
|
||||
var mat = Mat4.identity();
|
||||
function update() {
|
||||
if (Input.occupied || !body.bodyCreated) return;
|
||||
|
||||
// Unlock
|
||||
// if (locked &&
|
||||
// Input.x > iron.App.w / 2 - 20 && Input.x < iron.App.w / 2 + 20 &&
|
||||
// Input.y > iron.App.h / 2 - 20 && Input.y < iron.App.h / 2 +20) {
|
||||
// locked = false;
|
||||
// }
|
||||
|
||||
// Look
|
||||
// if (!locked) {
|
||||
if (Input.touch) {
|
||||
camera.rotate(new Vec4(1, 0, 0), -Input.deltaY / 350);
|
||||
transform.rotate(new Vec4(0, 0, 1), -Input.deltaX / 350);
|
||||
camera.rotate(xVec, -Input.deltaY / 250 * rotationSpeed);
|
||||
transform.rotate(zVec, -Input.deltaX / 250 * rotationSpeed);
|
||||
body.syncTransform();
|
||||
}
|
||||
|
||||
// Move
|
||||
var dir = new Vec4();
|
||||
dir.set(0, 0, 0);
|
||||
if (moveForward) {
|
||||
var mat = Mat4.identity();
|
||||
transform.rot.saveToMatrix(mat);
|
||||
|
||||
var force = new Vec4(0, 1, 0);
|
||||
force.set(0, 1, 0);
|
||||
force.applyProjection(mat);
|
||||
dir.add(force);
|
||||
}
|
||||
if (moveBackward) {
|
||||
var mat = Mat4.identity();
|
||||
transform.rot.saveToMatrix(mat);
|
||||
|
||||
var force = new Vec4(0, -1, 0);
|
||||
force.set(0, -1, 0);
|
||||
force.applyProjection(mat);
|
||||
dir.add(force);
|
||||
}
|
||||
if (moveLeft) {
|
||||
var mat = Mat4.identity();
|
||||
transform.rot.saveToMatrix(mat);
|
||||
|
||||
var force = new Vec4(-1, 0, 0);
|
||||
force.set(-1, 0, 0);
|
||||
force.applyProjection(mat);
|
||||
dir.add(force);
|
||||
}
|
||||
if (moveRight) {
|
||||
var mat = Mat4.identity();
|
||||
transform.rot.saveToMatrix(mat);
|
||||
|
||||
var force = new Vec4(1, 0, 0);
|
||||
force.set(1, 0, 0);
|
||||
force.applyProjection(mat);
|
||||
dir.add(force);
|
||||
}
|
||||
|
||||
if (jump) {
|
||||
var mat = Mat4.identity();
|
||||
transform.rot.saveToMatrix(mat);
|
||||
|
||||
var force = new Vec4(0, 0, 1);
|
||||
force.set(0, 0, 1);
|
||||
force.applyProjection(mat);
|
||||
force = force.mult(Time.delta * 70);
|
||||
|
||||
body.applyImpulse(force);
|
||||
}
|
||||
|
||||
if (!moveForward && !moveBackward && !moveLeft && !moveRight && !jump) {
|
||||
var mat = Mat4.identity();
|
||||
transform.rot.saveToMatrix(mat);
|
||||
|
||||
var force = new Vec4(0, 0, -1);
|
||||
force.set(0, 0, -1);
|
||||
force.applyProjection(mat);
|
||||
force = force.mult(Time.delta * 3000 / 2);
|
||||
// body.applyImpulse(force);
|
||||
|
||||
var btvec = body.getLinearVelocity();
|
||||
body.setLinearVelocity(0.0, 0.0, btvec.z() - 1.0);
|
||||
|
@ -144,7 +129,6 @@ class FirstPersonController extends Trait {
|
|||
}
|
||||
|
||||
body.setAngularFactor(0, 0, 0);
|
||||
|
||||
camera.updateMatrix();
|
||||
}
|
||||
#end
|
||||
|
|
|
@ -27,22 +27,27 @@ class VehicleBody extends Trait {
|
|||
var vehicle:BtRaycastVehiclePointer = null;
|
||||
var carChassis:BtRigidBodyPointer;
|
||||
|
||||
var engineForce = 0.0;
|
||||
var breakingForce = 0.0;
|
||||
var vehicleSteering = 0.0;
|
||||
var chassis_mass = 500.0;
|
||||
var wheelFriction = 1000;
|
||||
var suspensionStiffness = 20.0;
|
||||
var suspensionDamping = 2.3;
|
||||
var suspensionCompression = 4.4;
|
||||
var suspensionRestLength = 0.6;
|
||||
var rollInfluence = 0.1;
|
||||
|
||||
var maxEngineForce = 3000.0;
|
||||
var maxBreakingForce = 100.0;
|
||||
|
||||
var engineForce = 0.0;
|
||||
var breakingForce = 0.0;
|
||||
var vehicleSteering = 0.0;
|
||||
|
||||
public function new(wheelName1:String, wheelName2:String, wheelName3:String, wheelName4:String) {
|
||||
super();
|
||||
|
||||
wheelNames = [wheelName1, wheelName2, wheelName3, wheelName4];
|
||||
|
||||
notifyOnInit(init);
|
||||
notifyOnUpdate(update);
|
||||
|
||||
kha.input.Keyboard.get().notify(onKeyDown, onKeyUp);
|
||||
Scene.active.notifyOnInit(init);
|
||||
}
|
||||
|
||||
var up = false;
|
||||
|
@ -75,20 +80,9 @@ class VehicleBody extends Trait {
|
|||
wheels.push(iron.Scene.active.root.getChild(n));
|
||||
}
|
||||
|
||||
var rightIndex = 0;
|
||||
var upIndex = 2;
|
||||
var forwardIndex = 1;
|
||||
|
||||
var wheelDirectionCS0 = BtVector3.create(0, 0, -1).value;
|
||||
var wheelAxleCS = BtVector3.create(1, 0, 0).value;
|
||||
|
||||
var wheelFriction = 1000;
|
||||
var suspensionStiffness = 20.0;
|
||||
var suspensionDamping = 2.3;
|
||||
var suspensionCompression = 4.4;
|
||||
var suspensionRestLength = 0.6;
|
||||
var rollInfluence = 0.1;
|
||||
|
||||
var chassisShape = BtBoxShape.create(BtVector3.create(
|
||||
transform.size.x / 2,
|
||||
transform.size.y / 2,
|
||||
|
@ -106,7 +100,7 @@ class VehicleBody extends Trait {
|
|||
compound.value.addChildShape(localTrans.value, chassisShape);
|
||||
#end
|
||||
|
||||
carChassis = createRigidBody(500, compound);
|
||||
carChassis = createRigidBody(chassis_mass, compound);
|
||||
|
||||
// Create vehicle
|
||||
var tuning = BtVehicleTuning.create();
|
||||
|
@ -117,6 +111,9 @@ class VehicleBody extends Trait {
|
|||
carChassis.ptr.setActivationState(BtCollisionObject.DISABLE_DEACTIVATION);
|
||||
|
||||
// Choose coordinate system
|
||||
var rightIndex = 0;
|
||||
var upIndex = 2;
|
||||
var forwardIndex = 1;
|
||||
vehicle.ptr.setCoordinateSystem(rightIndex, upIndex, forwardIndex);
|
||||
|
||||
// Add wheels
|
||||
|
@ -143,10 +140,12 @@ class VehicleBody extends Trait {
|
|||
}
|
||||
|
||||
physics.world.ptr.addAction(vehicle);
|
||||
|
||||
kha.input.Keyboard.get().notify(onKeyDown, onKeyUp);
|
||||
notifyOnUpdate(update);
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (vehicle == null) return;
|
||||
|
||||
if (up) {
|
||||
|
|
|
@ -1872,7 +1872,7 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
|
|||
return
|
||||
|
||||
print ('Exporting mesh ' + bobject.data.name)
|
||||
if len(bobject.data.vertices) > 40000:
|
||||
if bobject.type != 'FONT' and len(bobject.data.vertices) > 40000:
|
||||
print('Armory Warning: "' + bobject.name + '" contains over 40000 vertices, split mesh to smaller parts to fit into 16-bit indices')
|
||||
|
||||
o = {}
|
||||
|
|
|
@ -41,7 +41,7 @@ def init_armory_props():
|
|||
for scene in bpy.data.scenes:
|
||||
if scene.render.engine != 'CYCLES':
|
||||
scene.render.engine = 'CYCLES'
|
||||
scene.render.fps = 60 # Default to 60fps for update loop
|
||||
scene.render.fps = 60 # Default to 60fps for chromium update loop
|
||||
# Force camera far to at least 200 units for now, to prevent fighting with light far plane
|
||||
for c in bpy.data.cameras:
|
||||
if c.clip_end < 200:
|
||||
|
@ -340,14 +340,16 @@ def watch_play():
|
|||
|
||||
def watch_compile(mode):
|
||||
play_project.compileproc.wait()
|
||||
armory_progress(100)
|
||||
result = play_project.compileproc.poll()
|
||||
play_project.compileproc = None
|
||||
play_project.compileproc_finished = True
|
||||
if result == 0:
|
||||
play_project.compileproc_success = True
|
||||
on_compiled(mode)
|
||||
else:
|
||||
play_project.compileproc_success = False
|
||||
armory_log('Build failed, check console')
|
||||
armory_progress(100)
|
||||
|
||||
def watch_patch():
|
||||
play_project.compileproc.wait()
|
||||
|
@ -411,6 +413,7 @@ play_project.playproc = None
|
|||
play_project.compileproc = None
|
||||
play_project.playproc_finished = False
|
||||
play_project.compileproc_finished = False
|
||||
play_project.compileproc_success = False
|
||||
play_project.play_area = None
|
||||
play_project.chromium_running = False
|
||||
play_project.last_chromium_running = False
|
||||
|
@ -424,7 +427,6 @@ def run_server():
|
|||
print('Server already running')
|
||||
|
||||
def on_compiled(mode): # build, play, play_viewport, publish
|
||||
armory_progress(100)
|
||||
armory_log()
|
||||
sdk_path = utils.get_sdk_path()
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ def make_texture(self, id, image_node, material):
|
|||
tex['u_addressing'] = 'clamp'
|
||||
tex['v_addressing'] = 'clamp'
|
||||
else:
|
||||
if is_pow(image.size[0]) == False or is_pow(image.size[1]) == False:
|
||||
if bpy.data.worlds['Arm'].npot_texture_repeat == False and (is_pow(image.size[0]) == False or is_pow(image.size[1]) == False):
|
||||
print('Armory Warning: ' + material.name + '/' + image.name + ' - non power of 2 texture can not use repeat mode')
|
||||
tex['u_addressing'] = 'clamp'
|
||||
tex['v_addressing'] = 'clamp'
|
||||
|
|
|
@ -74,6 +74,7 @@ def buildNodeTree(world):
|
|||
wrd.world_defs += '_PCSS'
|
||||
sdk_path = utils.get_sdk_path()
|
||||
assets.add(sdk_path + 'armory/Assets/noise64.png')
|
||||
assets.add_embedded_data('noise64.png')
|
||||
|
||||
if wrd.diffuse_oren_nayar:
|
||||
wrd.world_defs += '_OrenNayar'
|
||||
|
|
|
@ -83,8 +83,7 @@ def on_scene_update_post(context):
|
|||
js_source = 'var o = armory.Scene.active.getObject("' + objname + '"); o.transform.rot.set(' + str(vec[1]) + ', ' + str(vec[2]) + ', ' + str(vec[3]) + ' ,' + str(vec[0]) + '); o.transform.dirty = true;'
|
||||
bgame.call_js(js_source)
|
||||
mapped = True
|
||||
|
||||
# Rebuild scene
|
||||
# Othwerwise rebuild scene
|
||||
if mapped == False:
|
||||
make.patch_project()
|
||||
make.compile_project()
|
||||
|
@ -96,6 +95,7 @@ def on_scene_update_post(context):
|
|||
# Read chromium console
|
||||
if bgame.get_console_updated() == 1:
|
||||
make.armory_space_log(bgame.get_console())
|
||||
area.tag_redraw()
|
||||
# Read operator console
|
||||
if bgame.get_operator_updated() == 1:
|
||||
parse_operator(bgame.get_operator())
|
||||
|
@ -122,10 +122,12 @@ def on_scene_update_post(context):
|
|||
for area in bpy.context.screen.areas:
|
||||
if area.type == 'VIEW_3D' or area.type == 'PROPERTIES':
|
||||
area.tag_redraw()
|
||||
# Compilation succesfull
|
||||
if make.play_project.compileproc_success:
|
||||
# Notify embedded player
|
||||
if make.play_project.chromium_running:
|
||||
bgame.call_js('armory.Scene.patch();')
|
||||
# Switch to armory space
|
||||
# Or switch to armory space
|
||||
elif utils.with_chromium() and make.play_project.in_viewport:
|
||||
make.play_project.play_area.type = 'VIEW_GAME'
|
||||
|
||||
|
@ -286,6 +288,7 @@ def initProperties():
|
|||
bpy.types.Camera.mirror_resolution_y = bpy.props.FloatProperty(name="Y", default=256.0)
|
||||
bpy.types.Camera.last_decal_context = bpy.props.StringProperty(name="Decal Context", default='')
|
||||
# For world
|
||||
|
||||
bpy.types.World.world_envtex_name = bpy.props.StringProperty(name="Environment Texture", default='')
|
||||
bpy.types.World.world_envtex_num_mips = bpy.props.IntProperty(name="Number of mips", default=0)
|
||||
bpy.types.World.world_envtex_color = bpy.props.FloatVectorProperty(name="Environment Color", size=4, default=[0,0,0,1])
|
||||
|
@ -355,6 +358,7 @@ def initProperties():
|
|||
# Material override flags
|
||||
bpy.types.World.force_no_culling = bpy.props.BoolProperty(name="Force No Culling", default=False)
|
||||
bpy.types.World.force_anisotropic_filtering = bpy.props.BoolProperty(name="Force Anisotropic Filtering", default=False)
|
||||
bpy.types.World.npot_texture_repeat = bpy.props.BoolProperty(name="NPoT Texture Repeat", description="Enable texture repeat mode for non-power of two textures", default=False)
|
||||
# Lighting flags
|
||||
bpy.types.World.diffuse_oren_nayar = bpy.props.BoolProperty(name="Oren Nayar Diffuse", default=False, update=invalidate_shader_cache)
|
||||
# For material
|
||||
|
@ -749,6 +753,7 @@ class WorldPropsPanel(bpy.types.Panel):
|
|||
layout.label('Flags')
|
||||
layout.prop(wrd, 'force_no_culling')
|
||||
layout.prop(wrd, 'force_anisotropic_filtering')
|
||||
layout.prop(wrd, 'npot_texture_repeat')
|
||||
layout.prop(wrd, 'diffuse_oren_nayar')
|
||||
|
||||
# Menu in render region
|
||||
|
|
|
@ -159,9 +159,9 @@ void getSkinningDualQuat(vec4 weights, out vec4 A, inout vec4 B) {
|
|||
void main() {
|
||||
|
||||
#ifdef _Instancing
|
||||
vec4 sPos = (vec4(pos + off, 1.0));
|
||||
vec4 sPos = vec4(pos + off, 1.0);
|
||||
#else
|
||||
vec4 sPos = (vec4(pos, 1.0));
|
||||
vec4 sPos = vec4(pos, 1.0);
|
||||
#endif
|
||||
#ifdef _Skinning
|
||||
// mat4 skinningMat = getSkinningMat();
|
||||
|
|
|
@ -35,6 +35,10 @@ out vec3 v_normal;
|
|||
|
||||
void main() {
|
||||
v_position = pos;
|
||||
#ifdef _Instancing
|
||||
v_position += off;
|
||||
#endif
|
||||
|
||||
v_texCoord = tex;
|
||||
v_normal = nor;
|
||||
#ifdef _NorTex
|
||||
|
|
|
@ -32,6 +32,9 @@ out vec3 v_normal;
|
|||
|
||||
void main() {
|
||||
v_position = pos;
|
||||
#ifdef _Instancing
|
||||
v_position += off;
|
||||
#endif
|
||||
v_texCoord = tex;
|
||||
v_normal = nor;
|
||||
// v_position += v_normal * texture(sheight, tex).r * heightStrength;
|
||||
|
|
Loading…
Reference in a new issue