Skip to content

Commit c36e53c

Browse files
author
Roberto De Ioris
authored
Update PlottingGraphsWithMatplotlibAndUnrealEnginePython.md
1 parent 2c22c91 commit c36e53c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Time to check if all is working well.
6262

6363
We will start by generating a texture asset. The content of this texture will be generated by matplotlib.
6464

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+
6567
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:
6668

6769
```python
@@ -138,6 +140,13 @@ The first blueprint we are about to create, is the 'carpet' (we call it Graph_Bl
138140

139141
![Graph Blueprint](https://github.com/20tab/UnrealEnginePython/blob/master/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython_Assets/graph_blueprint.png)
140142

143+
As you can see it is really simple:
144+
145+
* add a StaticMeshComponent (as root if you want) with a plane as the mesh and the material instance you created before
146+
* add a Python component with the module as 'plotter' and the class as 'PlotComponent' (this is where the matplotlib part will be)
147+
* add an event dispatcher called 'OnGraphDataUpdated' (this will be triggered whenever the character steps over a cube)
148+
149+
You can now create (again into Content/Scripts) the plotter.py python script
141150

142151
```python
143152
import unreal_engine as ue
@@ -175,6 +184,10 @@ class PlotComponent:
175184
self.texture.texture_set_data(self.fig.canvas.buffer_rgba())
176185
```
177186

187+
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+
178191
### The "Plotter Platforms"
179192

180193
### Playing it

0 commit comments

Comments
 (0)