Skip to content

Commit

Permalink
cascade problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Palmer-JC committed May 25, 2021
1 parent 42334dc commit 5e0d588
Show file tree
Hide file tree
Showing 33 changed files with 761 additions and 433 deletions.
Binary file not shown.
17 changes: 17 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Blender2Babylon add-on changelog

## Blender 2.93.0 ##
* 25 May 2022

* Changes for API changes in Blender 2.93
* Shape Key animation added
* Switched the default of pickable to False for meshes
* For Shadows, added Cascaded type, autoZBounds & min & max

* For Materials:
* Allow for having a value for Albedo / diffuse or emission when there is also a texture for same
* The emission color is never defaulted on nor explicitly black, when there is an emissive texture
* Added a custom overload property, where a color AND a texture can be specified for Albedo & emissive with the same fields
* Added custom properties of 2 Sided lighting, disable lights, invert X or Y normals, & Object Space Normal mapping
* Support for Parallax and it's scale bias, & occlusion
* Added PBR specific custom properties for Horizon Occlusion, Radiance Occlusion, Irradiance In Fragment, Radiance Over Alpha, Normals Forward, & Specular Anti-Aliasing
* Added custom property to allow mixing STD materials in a PBR export via a STD material override

## Blender 2.80.1 ##
* 18 January 2021

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Blender_JSON_Exporter",
"version": "2.91.0",
"version": "2.93.0",
"description": "Writes .babylon file from Blender file",
"main": "",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions src/babylon_js/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
bl_info = {
'name': 'Babylon.js',
'author': 'David Catuhe, Jeff Palmer',
'version': (2, 91, -1),
'blender': (2, 91, 0),
'version': (2, 93, -2),
'blender': (2, 93, 0),
'location': 'File > Export > Babylon.js (.babylon)',
'description': 'Export Babylon.js scenes (.babylon)',
'wiki_url': 'https://github.com/BabylonJS/BlenderExporter',
Expand Down
17 changes: 8 additions & 9 deletions src/babylon_js/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
FRAME_BASED_ANIMATION = True # turn off for diagnostics; only actual keyframes will be written for skeleton animation

# passed to Animation constructor from animatable objects, defined in BABYLON.Animation
#ANIMATIONTYPE_FLOAT = 0
ANIMATIONTYPE_FLOAT = 0
ANIMATIONTYPE_VECTOR3 = 1
ANIMATIONTYPE_QUATERNION = 2
ANIMATIONTYPE_MATRIX = 3
Expand Down Expand Up @@ -70,7 +70,7 @@ def actionPrep(object, action, includeAllFrames, frameOffset):
frames[frame] = True

frames = sorted(frames)

if len(frames) == 0:
Logger.warn('action ' + action.name + ' has no frames, ignored.', 3)
return None
Expand Down Expand Up @@ -126,8 +126,11 @@ def get_last_frame(self):
def to_json_file(self, file_handler):
precision = bpy.context.scene.world.positionsPrecision if self.propertyInBabylon == 'position' else FLOAT_PRECISION_DEFAULT
file_handler.write('{')
write_int(file_handler, 'dataType', self.dataType, True)
write_string(file_handler, 'name', self.name, True)
write_string(file_handler, 'property', self.propertyInBabylon)
write_int(file_handler, 'dataType', self.dataType)
write_int(file_handler, 'framePerSecond', self.framePerSecond)
write_int(file_handler, 'loopBehavior', self.loopBehavior)

file_handler.write(',"keys":[')
first = True
Expand All @@ -142,17 +145,13 @@ def to_json_file(self, file_handler):
write_matrix4(file_handler, 'values', value_idx)
elif self.dataType == ANIMATIONTYPE_QUATERNION:
write_quaternion(file_handler, 'values', value_idx)
elif self.dataType == ANIMATIONTYPE_FLOAT:
file_handler.write(',"values":[' + format_f(value_idx, precision = precision) + ']')
else:
write_vector(file_handler, 'values', value_idx, precision)
file_handler.write('}')

file_handler.write(']') # close keys

# put this at the end to make less crazy looking ]}]]]}}}}}}}]]]],
# since animation is also at the end of the bone, mesh, camera, or light
write_int(file_handler, 'loopBehavior', self.loopBehavior)
write_string(file_handler, 'name', self.name)
write_string(file_handler, 'property', self.propertyInBabylon)
file_handler.write('}')
#===============================================================================
class VectorAnimation(Animation):
Expand Down
29 changes: 12 additions & 17 deletions src/babylon_js/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
GAMEPAD_CAM = 'GamepadCamera'
TOUCH_CAM = 'TouchCamera'
V_JOYSTICKS_CAM = 'VirtualJoysticksCamera'
VR_DEV_ORIENT_FREE_CAM ='VRDeviceOrientationFreeCamera'
WEB_VR_FREE_CAM = 'WebVRFreeCamera'

# 3D camera rigs, defined in BABYLON.Camera, must be strings to be in 'dropdown'
RIG_MODE_NONE = '0'
Expand All @@ -25,6 +23,9 @@
RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = '12'
RIG_MODE_STEREOSCOPIC_OVERUNDER = '13'
RIG_MODE_VR = '20'

DEF_CHECK_COLLISIONS = False
DEF_APPLY_GRAVITY = False
#===============================================================================
class Camera(FCurveAnimatable):
def __init__(self, bpyCamera, exporter):
Expand All @@ -46,8 +47,6 @@ def __init__(self, bpyCamera, exporter):
self.fov = bpyCamera.data.angle
self.minZ = bpyCamera.data.clip_start
self.maxZ = bpyCamera.data.clip_end
self.speed = 1.0
self.inertia = 0.9
self.checkCollisions = bpyCamera.data.checkCollisions
self.applyGravity = bpyCamera.data.applyGravity
self.ellipsoid = bpyCamera.data.ellipsoid
Expand Down Expand Up @@ -104,15 +103,13 @@ def to_json_file(self, file_handler):
write_float(file_handler, 'fov', self.fov)
write_float(file_handler, 'minZ', self.minZ)
write_float(file_handler, 'maxZ', self.maxZ)
write_float(file_handler, 'speed', self.speed)
write_float(file_handler, 'inertia', self.inertia)
write_bool(file_handler, 'checkCollisions', self.checkCollisions)
write_bool(file_handler, 'applyGravity', self.applyGravity)
if self.checkCollisions: write_bool(file_handler, 'checkCollisions', True) # default is false
if self.applyGravity : write_bool(file_handler, 'applyGravity', True) # default is false
write_array3(file_handler, 'ellipsoid', self.ellipsoid)

# always assign rig, even when none, Reason: Could have VR camera with different Rig than default
write_int(file_handler, 'cameraRigMode', self.Camera3DRig)
write_float(file_handler, 'interaxial_distance', self.interaxialDistance)
if self.Camera3DRig != RIG_MODE_NONE:
write_int(file_handler, 'cameraRigMode', self.Camera3DRig)
write_float(file_handler, 'interaxial_distance', self.interaxialDistance)

write_string(file_handler, 'type', self.CameraType)

Expand Down Expand Up @@ -150,25 +147,23 @@ def to_json_file(self, file_handler):
(UNIVERSAL_CAM , 'Universal' , 'Use Universal Camera'),
(FOLLOW_CAM , 'Follow' , 'Use Follow Camera'),
(DEV_ORIENT_CAM , 'Device Orientation' , 'Use Device Orientation Camera'),
(ARC_ROTATE_CAM , 'Arc Rotate' , 'Use Arc Rotate Camera'),
(VR_DEV_ORIENT_FREE_CAM , 'VR Dev Orientation Free' , 'Use VR Dev Orientation Free Camera'),
(WEB_VR_FREE_CAM , 'Web VR Free' , 'Use Web VR Free Camera')
(ARC_ROTATE_CAM , 'Arc Rotate' , 'Use Arc Rotate Camera')
),
default = UNIVERSAL_CAM
)
bpy.types.Camera.checkCollisions = bpy.props.BoolProperty(
name='Check Collisions',
description='',
default = False
default = DEF_CHECK_COLLISIONS
)
bpy.types.Camera.applyGravity = bpy.props.BoolProperty(
name='Apply Gravity',
description='',
default = False
default = DEF_APPLY_GRAVITY
)
bpy.types.Camera.ellipsoid = bpy.props.FloatVectorProperty(
name='Ellipsoid',
description='',
description='Not used except for a collision system. Enter Coordinates in Y-UP terms',
default = mathutils.Vector((0.2, 0.9, 0.2))
)
bpy.types.Camera.Camera3DRig = bpy.props.EnumProperty(
Expand Down
1 change: 1 addition & 0 deletions src/babylon_js/f_curve_animatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def define_animations(self, object, supportsRotation, supportsPosition, supports
if animationRange is None:
continue

hasData = False
if supportsRotation:
hasData = rotAnimation.append_range(object, animationRange)

Expand Down
Loading

0 comments on commit 5e0d588

Please sign in to comment.