Skip to content

Commit e318cd5

Browse files
test: Add non-ascii characters test. (#135)
Signed-off-by: Karthik Bekal Pattathana <133984042+karthikbekalp@users.noreply.github.com>
1 parent 0b3c05d commit e318cd5

File tree

4 files changed

+213
-0
lines changed

4 files changed

+213
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
assetReferences:
2+
inputs:
3+
directories: []
4+
filenames:
5+
- "C:\normalized\job\bundle\dir\redshift_textured-_\u20BF\
6+
_\u0119_\xF1_\u03B2_\u0411_\u062A.c4d"
7+
- "C:\normalized\job\bundle\dir\tex\checkerboard-_\u20BF\
8+
_\u0119_\xF1_\u03B2_\u0411_\u062A.bmp"
9+
outputs:
10+
directories:
11+
- C:\normalized\job\bundle\dir\renders
12+
referencedPaths: []
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
parameterValues:
2+
- name: Cinema4DFile
3+
value: "C:\normalized\job\bundle\dir\\\\
4+
redshift_textured_with_non_ascii_characters\\scene\\redshift_textured-_\u20BF\
5+
_\u0119_\xF1_\u03B2_\u0411_\u062A.c4d"
6+
- name: OutputPath
7+
value: "C:\normalized\job\bundle\dir\\\\
8+
redshift_textured_with_non_ascii_characters\\scene\\renders\\redshift_textured-_\u20BF\
9+
_\u0119_\xF1_\u03B2_\u0411_\u062A"
10+
- name: MultiPassPath
11+
value: C:\normalized\job\bundle\dir\redshift_textured_with_non_ascii_characters\scene
12+
- name: Frames
13+
value: '1'
14+
- name: deadline:targetTaskRunStatus
15+
value: READY
16+
- name: deadline:maxFailedTasksCount
17+
value: 20
18+
- name: deadline:maxRetriesPerTask
19+
value: 5
20+
- name: deadline:priority
21+
value: 50
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
specificationVersion: jobtemplate-2023-09
2+
name: "redshift_textured-_\u20BF_\u0119_\xF1_\u03B2_\u0411_\u062A.c4d"
3+
parameterDefinitions:
4+
- name: Cinema4DFile
5+
type: PATH
6+
objectType: FILE
7+
dataFlow: IN
8+
userInterface:
9+
control: CHOOSE_INPUT_FILE
10+
label: Cinema4D Document File
11+
groupLabel: Cinema4D Settings
12+
fileFilters:
13+
- label: Cinema4D document files
14+
patterns:
15+
- '*.c4d'
16+
- label: All Files
17+
patterns:
18+
- '*'
19+
description: The Cinema4D document file to render.
20+
- name: Frames
21+
type: STRING
22+
userInterface:
23+
control: LINE_EDIT
24+
label: Frames
25+
groupLabel: Cinema4D Settings
26+
description: The frames to render. E.g. 1-3,8,11-15
27+
minLength: 1
28+
- name: OutputPath
29+
type: STRING
30+
userInterface:
31+
control: LINE_EDIT
32+
label: Default image output
33+
groupLabel: Cinema4D Settings
34+
description: Image output path
35+
- name: MultiPassPath
36+
type: STRING
37+
userInterface:
38+
control: LINE_EDIT
39+
label: Multi-pass output path
40+
groupLabel: Cinema4D Settings
41+
description: Multi-pass image output
42+
steps:
43+
- name: Main
44+
parameterSpace:
45+
taskParameterDefinitions:
46+
- name: Frame
47+
type: INT
48+
range: '{{Param.Frames}}'
49+
stepEnvironments:
50+
- name: Cinema4D
51+
description: Runs Cinema4D in the background.
52+
variables:
53+
PYTHONUNBUFFERED: '1'
54+
script:
55+
embeddedFiles:
56+
- name: initData
57+
filename: init-data.yaml
58+
type: TEXT
59+
data: |-
60+
scene_file: '{{Param.Cinema4DFile}}'
61+
take: 'Main'
62+
output_path: '{{Param.OutputPath}}'
63+
multi_pass_path: '{{Param.MultiPassPath}}'
64+
actions:
65+
onEnter:
66+
command: cinema4d-openjd
67+
args:
68+
- daemon
69+
- start
70+
- --path-mapping-rules
71+
- file://{{Session.PathMappingRulesFile}}
72+
- --connection-file
73+
- '{{Session.WorkingDirectory}}/connection.json'
74+
- --init-data
75+
- file://{{Env.File.initData}}
76+
cancelation:
77+
mode: NOTIFY_THEN_TERMINATE
78+
onExit:
79+
command: cinema4d-openjd
80+
args:
81+
- daemon
82+
- stop
83+
- --connection-file
84+
- '{{ Session.WorkingDirectory }}/connection.json'
85+
cancelation:
86+
mode: NOTIFY_THEN_TERMINATE
87+
script:
88+
embeddedFiles:
89+
- name: runData
90+
filename: run-data.yaml
91+
type: TEXT
92+
data: |
93+
frame: {{Task.Param.Frame}}
94+
actions:
95+
onRun:
96+
command: cinema4d-openjd
97+
args:
98+
- daemon
99+
- run
100+
- --connection-file
101+
- '{{ Session.WorkingDirectory }}/connection.json'
102+
- --run-data
103+
- file://{{ Task.File.runData }}
104+
cancelation:
105+
mode: NOTIFY_THEN_TERMINATE
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import os
2+
import struct
3+
import c4d
4+
5+
6+
def _checkerboard_bmp(filename):
7+
width = 128
8+
height = 128
9+
color1 = (255, 255, 255)
10+
color2 = (0, 0, 0)
11+
# BMP file header
12+
file_size = 14 + 40 + (width * height * 3)
13+
file_header = struct.pack("<2sIHHI", b"BM", file_size, 0, 0, 54)
14+
# DIB header
15+
dib_header = struct.pack(
16+
"<IiiHHIIiiII", 40, width, height, 1, 24, 0, width * height * 3, 2835, 2835, 0, 0
17+
)
18+
pixel_data = []
19+
for y in range(height):
20+
row_data = []
21+
for x in range(width):
22+
if (x // 8 + y // 8) % 2 == 0:
23+
row_data.extend(color1)
24+
else:
25+
row_data.extend(color2)
26+
padding = (4 - (width * 3) % 4) % 4
27+
row_data.extend([0] * padding)
28+
pixel_data.extend(row_data)
29+
with open(filename, "wb") as bmp_file:
30+
bmp_file.write(file_header)
31+
bmp_file.write(dib_header)
32+
bmp_file.write(bytearray(pixel_data))
33+
34+
35+
def main():
36+
doc = c4d.documents.GetActiveDocument()
37+
doc.Flush()
38+
cube = c4d.BaseObject(c4d.Ocube)
39+
cube[c4d.PRIM_CUBE_LEN] = c4d.Vector(400, 400, 400)
40+
cube.SetAbsPos(c4d.Vector(0, 50, -50))
41+
doc.InsertObject(cube)
42+
mat = c4d.BaseList2D(c4d.Mmaterial)
43+
doc.InsertMaterial(mat)
44+
mat[c4d.MATERIAL_USE_REFLECTION] = False
45+
bitmap_shader = c4d.BaseShader(c4d.Xbitmap)
46+
tex_dir = os.path.join(os.path.dirname(__file__), "tex")
47+
os.makedirs(tex_dir, exist_ok=True)
48+
_checkerboard_bmp(os.path.join(tex_dir, "checkerboard-_₿_ę_ñ_β_Б_ت.bmp"))
49+
bitmap_shader[c4d.BITMAPSHADER_FILENAME] = "tex/checkerboard-_₿_ę_ñ_β_Б_ت.bmp"
50+
mat[c4d.MATERIAL_COLOR_SHADER] = bitmap_shader
51+
mat.InsertShader(bitmap_shader)
52+
texture_tag = c4d.TextureTag()
53+
texture_tag.SetMaterial(mat)
54+
cube.InsertTag(texture_tag)
55+
render_data = doc.GetActiveRenderData()
56+
render_data[c4d.RDATA_PATH] = "renders/$prj"
57+
frame_start = c4d.BaseTime(1, doc.GetFps())
58+
frame_end = c4d.BaseTime(1, doc.GetFps())
59+
render_data[c4d.RDATA_FRAMEFROM] = frame_start
60+
render_data[c4d.RDATA_FRAMETO] = frame_end
61+
render_data[c4d.RDATA_RENDERENGINE] = 1036219 # redshift
62+
63+
save_dir = os.path.dirname(__file__)
64+
save_name = "redshift_textured-_₿_ę_ñ_β_Б_ت.c4d"
65+
save_file = os.path.join(save_dir, save_name)
66+
doc.SetDocumentPath(save_dir)
67+
doc.SetDocumentName(save_name)
68+
c4d.documents.SaveDocument(doc, save_file, c4d.SAVEDOCUMENTFLAGS_0, c4d.FORMAT_C4DEXPORT)
69+
70+
c4d.documents.InsertBaseDocument(doc)
71+
c4d.EventAdd()
72+
73+
74+
if __name__ == "__main__":
75+
main()

0 commit comments

Comments
 (0)