You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,14 +20,52 @@ We will use the third person template
20
20
21
21
## Installing the Python plugin
22
22
23
+
Ensure your project/editor has been closed.
24
+
25
+
Download the most recent embedded binary release from here: https://github.com/20tab/UnrealEnginePython/releases
26
+
27
+
You can use a non-embedded version if you already have python in your system and you are confident with it. The only difference in the tutorial is in where the matplotlib will be installed. For embedded version, the installation will happen in the plugin directory itself. For non-embedded it will be in the python system path. Obviously if your system python installation already includes matplotlib, you can simply skip the related paragraph below.
28
+
29
+
>Note: on Linux and Mac system, you will use the system installation (no embedded distributions are provided) or directly the source one. The rest of the tutorial will be platform independent.
30
+
31
+
Create a Plugins/ directory in your project and unzip the plugin archive into it.
32
+
33
+
Re-start your project and in the Edit/Plugins menu you will be able to enable the python plugin:
If you are using a system python installation (or you are on Linux/Mac) just run:
48
+
49
+
```sh
50
+
pip3 install matplotlib
51
+
```
52
+
53
+
or (based on your config)
54
+
55
+
```sh
56
+
pip install matplotlib
57
+
```
58
+
29
59
## Testing matplotlib in Unreal Engine: generating a graph-texture
30
60
61
+
Time to check if all is working well.
62
+
63
+
We will start by generating a texture asset. The content of this texture will be generated by matplotlib.
64
+
65
+
You can use the included python editor to edit your scripts (it is under Wndow/Python Editor), or your favourite one SsublimeText, Vim, PyCharm...) just ensure scripts are under the Content/Scripts directory of your project.
66
+
67
+
The steps are generating a texture in memory, plotting the graph, transferring the graph data into texture memory, save it as an asset and opening the related editor:
68
+
31
69
```python
32
70
import unreal_engine as ue
33
71
# EPixelFormat defines the various pixel formats for a texture/image, we will use RGBA with 8bit per channel
The only relevant part is the update_graph function that is triggered by the 'OnGraphDataUpdated' event dispatcher.
188
+
189
+
This function receives as the 'platform' argument the Actor triggering the event. This Actor (that we will create in the next phase), expose the counters of the overlapping cubes. We use that values to re-generate our pie chart and uploading it into texture memory whenever the event is triggered
190
+
136
191
### The "Plotter Platforms"
137
192
193
+
The 'PlotterPlatforms' blueprint, implements the actor containing the 3 cubes and manages the overlapping events as well as incrementing the 3 counters.
194
+
195
+
Let's start with the viewport, you need to add 3 static meshes, each with a cube and the related solid-color material we created earlier:
0 commit comments