Skip to content

Commit 04c8bc4

Browse files
committed
v1.13.0
1 parent 215a654 commit 04c8bc4

File tree

5 files changed

+33
-35
lines changed

5 files changed

+33
-35
lines changed

advancedfx/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
bl_info = {
44
"name": "advancedfx Blender Scripts",
55
"author": "advancedfx.org",
6-
"version": (1, 12, 7),
6+
"version": (1, 13, 0),
77
"blender": (2, 80, 0),
88
"location": "File > Import/Export",
99
"description": "For inter-operation with HLAE.",

advancedfx/export_cam.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ def FloatToBvhString(value):
1414

1515
def WriteHeader(file, frames, frameTime):
1616
file.write("advancedfx Cam\n")
17-
file.write("version 1\n")
18-
file.write("scaleFov none\n")
17+
file.write("version 2\n")
1918
file.write("channels time xPosition yPosition zPositon xRotation yRotation zRotation fov\n")
2019
file.write("DATA\n")
2120

advancedfx/import_agr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ def createCamera(self, context, camName):
582582
o.rotation_mode = 'QUATERNION'
583583

584584

585-
# Create actions and their curves (boobs):
585+
# Create actions and their curves:
586586

587587
o.animation_data_create()
588588
action = bpy.data.actions.new(name="game_data")

advancedfx/import_cam.py

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,13 @@ def ReadLineWords(file):
1919
return words
2020

2121
def AlienSwarm_FovScaling(width, height, fov):
22-
2322
if 0 == height:
2423
return fov
25-
26-
engineAspectRatio = width / height;
27-
defaultAscpectRatio = 4.0 / 3.0;
28-
ratio = engineAspectRatio / defaultAscpectRatio;
29-
halfAngle = 0.5 * fov * (2.0 * math.pi / 360.0);
30-
t = ratio * math.tan(halfAngle);
31-
return 2.0 * math.atan(t) / (2.0 * math.pi / 360.0);
24+
engineAspectRatio = width / height
25+
defaultAscpectRatio = 4.0 / 3.0
26+
ratio = engineAspectRatio / defaultAscpectRatio
27+
t = ratio * math.tan(math.radians(0.5 * fov))
28+
return 2.0 * math.degrees(math.atan(t))
3229

3330
class CameraData:
3431
def __init__(self,o,c):
@@ -76,9 +73,8 @@ def invoke(self, context, event):
7673

7774
def createCamera(self, context, camName):
7875

79-
camBData = bpy.data.cameras.new(camName)
80-
o = bpy.data.objects.new(camName, camBData)
81-
c = bpy.data.cameras[o.name]
76+
c = bpy.data.cameras.new(camName)
77+
o = bpy.data.objects.new(camName, c)
8278

8379
context.scene.collection.objects.link(o)
8480

@@ -91,7 +87,7 @@ def createCamera(self, context, camName):
9187
o.rotation_mode = 'QUATERNION'
9288

9389

94-
# Create actions and their curves (boobs):
90+
# Create actions and their curves:
9591

9692
o.animation_data_create()
9793
action = bpy.data.actions.new(name="game_data")
@@ -108,28 +104,17 @@ def createCamera(self, context, camName):
108104
c.animation_data.action = action
109105

110106
camData.curves.append(action.fcurves.new("lens"))
111-
112-
return camData
113-
114-
# <returns> Camera FOV in radians </returns>
115-
def calcCameraFov(self):
116-
fov = math.radians(self.cameraFov)
117-
118-
if self.scaleFov:
119-
defaultAspectRatio = 4.0/3.0
120-
engineAspectRatio = (self.screenWidth / self.screenHeight) if 0 != self.screenHeight else defaultAspectRatio
121-
ratio = engineAspectRatio / defaultAspectRatio
122-
halfAngle = fov * 0.5
123-
fov = math.atan(math.tan(halfAngle) * ratio) * 2.0
124107

125-
return fov
108+
return camData
126109

127110
def readCam(self, context):
128111
fps = context.scene.render.fps
129112

130113
width = context.scene.render.pixel_aspect_x * context.scene.render.resolution_x
131114
height = context.scene.render.pixel_aspect_y * context.scene.render.resolution_y
132115

116+
frame_end = None
117+
133118
camData = self.createCamera(context,"afxCam")
134119

135120
if camData is None:
@@ -144,7 +129,7 @@ def readCam(self, context):
144129
file = open(self.filepath, 'rU')
145130

146131
version = 0
147-
scaleFov = 'none'
132+
scaleFov = ''
148133

149134
words = ReadLineWords(file)
150135

@@ -163,11 +148,11 @@ def readCam(self, context):
163148
if 'scaleFov' == words[0] and 2 <= len(words):
164149
scaleFov = words[1]
165150

166-
if(1 != version):
167-
self.error("Invalid version, only 1 is supported.")
151+
if(version < 1 or version > 2):
152+
self.error("Invalid version, only 1 - 2 are supported.")
168153
return False
169154

170-
if not(scaleFov in ['none', 'alienSwarm']):
155+
if not(scaleFov in ['','none', 'alienSwarm']):
171156
self.error("Unsupported scaleFov value.")
172157
return False
173158

@@ -191,6 +176,8 @@ def readCam(self, context):
191176

192177
time = 1.0 + time * fps
193178

179+
frame_end = int(math.ceil(time))
180+
194181
renderOrigin = mathutils.Vector((-float(words[2]),float(words[1]),float(words[3]))) * self.global_scale
195182
qAngle = afx_utils.QAngle(float(words[5]),float(words[6]),float(words[4]))
196183

@@ -206,7 +193,8 @@ def readCam(self, context):
206193

207194
fov = float(words[7])
208195

209-
if 'alienSwarm' == scaleFov:
196+
# none and alienSwarm was confused in version 1, version 2 always outputs real fov and doesn't have scaleFov.
197+
if 'none' == scaleFov:
210198
fov = AlienSwarm_FovScaling(width, height, fov)
211199

212200
lens = camData.c.sensor_width / (2.0 * math.tan(math.radians(fov) / 2.0))
@@ -218,6 +206,10 @@ def readCam(self, context):
218206
afx_utils.AddKey_Rotation(self.interKey, curves[0+3].keyframe_points, curves[0+4].keyframe_points, curves[0+5].keyframe_points, curves[0+6].keyframe_points, time, quat)
219207

220208
afx_utils.AddKey_Value(self.interKey, curves[0+7].keyframe_points, time, lens)
209+
210+
if frame_end is not None:
211+
bpy.context.scene.frame_start = 1
212+
bpy.context.scene.frame_end = frame_end
221213

222214
finally:
223215
if file is not None:

advancedfx/readme.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ For more informations visit it's Advancedfx Wiki page ( https://github.com/advan
5050

5151
Changelog:
5252

53+
1.13.0 (2021-09-17T05:17Z):
54+
- HLAE Camera IO (.cam):
55+
- Added version 2 support for to import.
56+
- Adjusted import to understand how HLAE mixes up the scaleFov for version 1 and fixed bugs.
57+
- Updated export to version 2.
58+
- Import now sets frame_begin and frame_end.
59+
5360
1.12.7 (2021-08-31T16:04Z):
5461
- fixed decal_e sticker skipping
5562

0 commit comments

Comments
 (0)