Improve shader resource parsing

This commit is contained in:
Lubos Lenco 2016-02-21 21:06:01 +01:00
parent 06f1385e82
commit 813966f4ea
4 changed files with 40 additions and 28 deletions

View file

@ -37,8 +37,7 @@ class VehicleBody extends Trait {
public function new(wheelName1:String, wheelName2:String, wheelName3:String, wheelName4:String) {
super();
//wheelNames = [wheelName1, wheelName2, wheelName3, wheelName4];
wheelNames = ["Wheel0", "Wheel1", "Wheel2", "Wheel3"];
wheelNames = [wheelName1, wheelName2, wheelName3, wheelName4];
requestInit(init);
requestUpdate(update);
@ -171,10 +170,10 @@ class VehicleBody extends Trait {
}
if (left) {
gVehicleSteering = 0.2;
gVehicleSteering = 0.3;
}
else if (right) {
gVehicleSteering = -0.2;
gVehicleSteering = -0.3;
}
else {
gVehicleSteering = 0;

View file

@ -13,8 +13,8 @@ class VehicleWheel extends Trait {
public var connectionPointCS0:BtVector3Pointer;
public var isFrontWheel:Bool;
public var wheelRadius = 0.715;
public var wheelWidth = 0.35;
public var wheelRadius = 0.75;
public var wheelWidth = 0.53;
var id:Int;
public function new(id:Int) {
@ -22,43 +22,47 @@ class VehicleWheel extends Trait {
this.id = id;
var CUBE_HALF_EXTENTS = 1;
var connectionHeight = 0.9; //1.2;
var VEHICLE_FRONT_X = 3.5 / 2; // Distance to wheel from vehicle center
var VEHICLE_BACK_X = 4.1 / 2;
var VEHICLE_FRONT_Y = 3.6;
var VEHICLE_BACK_Y = 3.5;
var CONNECTION_HEIGHT_FRONT = 0.3;
var CONNECTION_HEIGHT_BACK = 0.4;
if (id == 0) {
isFrontWheel = true;
connectionPointCS0 = BtVector3.create(
CUBE_HALF_EXTENTS - (0.3 * wheelWidth),
2 * CUBE_HALF_EXTENTS - wheelRadius,
connectionHeight
VEHICLE_FRONT_X - (0.3 * wheelWidth),
VEHICLE_FRONT_Y - wheelRadius,
CONNECTION_HEIGHT_FRONT
);
}
else if (id == 1) {
isFrontWheel = true;
connectionPointCS0 = BtVector3.create(
-CUBE_HALF_EXTENTS + (0.3 * wheelWidth),
2 * CUBE_HALF_EXTENTS - wheelRadius,
connectionHeight
-VEHICLE_FRONT_X + (0.3 * wheelWidth),
VEHICLE_FRONT_Y - wheelRadius,
CONNECTION_HEIGHT_FRONT
);
}
else if (id == 2) {
isFrontWheel = false;
connectionPointCS0 = BtVector3.create(
-CUBE_HALF_EXTENTS + (0.3 * wheelWidth),
-2 * CUBE_HALF_EXTENTS + wheelRadius,
connectionHeight
-VEHICLE_BACK_X + (0.3 * wheelWidth),
-VEHICLE_BACK_Y + wheelRadius,
CONNECTION_HEIGHT_BACK
);
}
else if (id == 3) {
isFrontWheel = false;
connectionPointCS0 = BtVector3.create(
CUBE_HALF_EXTENTS - (0.3 * wheelWidth),
-2 * CUBE_HALF_EXTENTS + wheelRadius,
connectionHeight
VEHICLE_BACK_X - (0.3 * wheelWidth),
-VEHICLE_BACK_Y + wheelRadius,
CONNECTION_HEIGHT_BACK
);
}
}

View file

@ -2090,11 +2090,6 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
c.id = ArmoryExporter.pipeline_id
c.bind_constants = []
const = Object()
const.id = "albedo_color"
const.vec4 = [1, 1, 1, 1]
c.bind_constants.append(const)
const = Object()
const.id = "lighting"
const.bool = material.lighting_bool
@ -2191,6 +2186,7 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
tex = Object()
tex.id = id
tex.name = image_node.image.name.rsplit('.', 1)[0] # Remove extension
tex.name = tex.name.replace('.', '_')
if image_node.interpolation == 'Cubic': # Mipmap linear
tex.mipmap_filter = 'linear'
tex.generate_mipmaps = True
@ -2214,8 +2210,11 @@ class ArmoryExporter(bpy.types.Operator, ExportHelper):
elif albedo_node.type == 'ATTRIBUTE': # Assume vcols for now
defs.append('_VCols')
else: # Take node color
const = Object()
const.id = "albedo_color"
col = albedo_input.default_value
c.bind_constants[0].vec4 = [col[0], col[1], col[2], col[3]]
const.vec4 = [col[0], col[1], col[2], col[3]]
c.bind_constants.append(const)
# Metalness Map
metalness_input = node.inputs[3]
if metalness_input.is_linked:

View file

@ -66,6 +66,7 @@ def writeResource(res, defs, json_data, base_name):
def parse_shader(sres, c, con, defs, lines, parse_attributes):
skipTillEndIf = 0
skipElse = False
vertex_structure_parsed = False
vertex_structure_parsing = False
@ -81,12 +82,21 @@ def parse_shader(sres, c, con, defs, lines, parse_attributes):
if d == s:
found = True
break
if found == False or s == '_Instancing': # TODO: Prevent instanced data to go into main verrtex structure
if found == False or s == '_Instancing': # TODO: Prevent instanced data to go into main vertex structure
skipTillEndIf += 1
else:
skipElse = True # #ifdef passed, skip #else if present
continue
if line.startswith('#endif') or line.startswith('#else'):
# Previous ifdef passed, skip else
if skipElse == True and line.startswith('#else'):
skipElse = False
skipTillEndIf += 1
continue
if line.startswith('#endif') or line.startswith('#else'): # Starts parsing again
skipTillEndIf -= 1
skipElse = False
if skipTillEndIf < 0: # #else + #endif will go below 0
skipTillEndIf = 0
continue