Skip to content

Commit 7b89406

Browse files
committed
Redesign pack to python script and added examples scripts
1 parent f585f38 commit 7b89406

12 files changed

Lines changed: 148 additions & 18 deletions

File tree

DEVELOPMENT.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@
55

66
Install requirements
77

8+
1. Require UNIGINE SDK Browser
9+
Pluging for scripting by python3 in Unigine Editor https://unigine.com/get-unigine/
10+
11+
12+
2. Require System Packages
13+
814
Ubuntu/Debian:
915
```bash
1016
$ sudo apt install qt5-default cmake gcc git-core
1117
```
1218

19+
Windows:
20+
- install cmake >= 3.20
21+
- install visual studio
22+
- install qt 5.12.x
23+
- install python3 (for command scripts)
24+
1325
### step 1: create a empty project
1426

1527
Use a UNIGINE SDK Browser and create some empty project, for example `my_project`
@@ -41,7 +53,7 @@ Ubuntu/Debian:
4153
```bash
4254
$ cd my_project
4355
$ cd UnigineEditorPlugin_Python3Scripting
44-
$ ./build_plugin.sh
56+
$ ./build_plugin_linux.sh
4557
```
4658

4759
### step 5: run editor
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import unigine
2+
print('Disable shadows')
3+
for mat in LIST_MATERIALS:
4+
print(mat.get_name())
5+
mat.set_shadow_mask(0x00000000)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enabled": true,
3+
"for": "materials",
4+
"id": "materials_shadows_disable",
5+
"name": "Shadows Disable"
6+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import unigine
2+
import os
3+
4+
unigine.log_info('start')
5+
print("getcwd: " + os.getcwd())
6+
7+
8+
print('Enable shadows')
9+
for mat in LIST_MATERIALS:
10+
print(mat.get_name())
11+
mat.set_shadow_mask(0xffffffffdd)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enabled": true,
3+
"for": "materials",
4+
"id": "materials_shadows_enable",
5+
"name": "Shadows Enable"
6+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import unigine
2+
import time
3+
print('Nodes')
4+
5+
i = 0
6+
_max = 30
7+
angels_diff = 0.2
8+
angels_cur = 0
9+
sleep_s = 0.026
10+
while i < _max:
11+
i += 1
12+
for node in LIST_NODES:
13+
node.rotate_by_angels(angels_cur, angels_cur, angels_cur)
14+
angels_cur += angels_diff
15+
time.sleep(sleep_s)
16+
i = 0
17+
while i < _max:
18+
i += 1
19+
for node in LIST_NODES:
20+
node.rotate_by_angels(-angels_cur, -angels_cur, -angels_cur)
21+
angels_cur -= angels_diff
22+
time.sleep(sleep_s)
23+
24+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"enabled": true,
3+
"for": "nodes",
4+
"id": "nodes_spin_example",
5+
"name": "Spin Example"
6+
}
File renamed without changes.

build_plugin_windows.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@echo off

pack_plugin.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
import sys
5+
import os
6+
import zipfile
7+
import platform
8+
9+
10+
_platform = platform.platform().lower()
11+
is_linux = False
12+
is_windows = False
13+
if _platform.startswith("linux"):
14+
_platform = "linux"
15+
is_linux = True
16+
elif _platform.startswith("windows"):
17+
_platform = "windows"
18+
is_windows = True
19+
else:
20+
sys.exit("Unknown platform")
21+
22+
23+
if is_linux:
24+
ret = os.system("./build_plugin_linux.sh")
25+
26+
if is_windows:
27+
ret = os.system("./build_plugin_windows.bat")
28+
29+
if ret != 0:
30+
sys.exit("Could not build...")
31+
32+
33+
with open("version") as _file:
34+
content = _file.read()
35+
_version = content.strip()
36+
37+
folder_inside = "UnigineEditorPlugin_Python3Scripting_" + _version
38+
_zip_filename = _platform + "_UnigineEditorPlugin_Python3Scripting_" + _version + ".zip"
39+
40+
if os.path.isfile(_zip_filename):
41+
os.remove(_zip_filename)
42+
43+
zf = zipfile.ZipFile(_zip_filename, 'w', zipfile.ZIP_DEFLATED)
44+
45+
if is_linux:
46+
zf.write(
47+
"bin/editor/libUnigineEditorPlugin_Python3Scripting_x64.so",
48+
folder_inside + "/bin/editor/libUnigineEditorPlugin_Python3Scripting_x64.so",
49+
)
50+
zf.write(
51+
"bin/editor_debug/libUnigineEditorPlugin_Python3Scripting_x64d.so",
52+
folder_inside + "/bin/editor_debug/libUnigineEditorPlugin_Python3Scripting_x64d.so",
53+
)
54+
55+
if is_windows:
56+
zf.write(
57+
"bin/editor/UnigineEditorPlugin_Python3Scripting_x64.dll",
58+
folder_inside + "/bin/editor/UnigineEditorPlugin_Python3Scripting_x64.dll",
59+
)
60+
zf.write(
61+
"bin/editor_debug/UnigineEditorPlugin_Python3Scripting_x64d.dll",
62+
folder_inside + "/bin/editor_debug/UnigineEditorPlugin_Python3Scripting_x64d.dll",
63+
)
64+
65+
66+
rootdir = "Python3Scripting_examples"
67+
for root, subdirs, files in os.walk(rootdir):
68+
for _file in files:
69+
_src = os.path.join(root, _file)
70+
_src = _src[len(rootdir)+1:]
71+
_src = os.path.join("bin", "Python3Scripting", _src)
72+
_dst = os.path.join(folder_inside, _src)
73+
zf.write(_src, _dst)
74+
75+
zf.close()

0 commit comments

Comments
 (0)