Skip to content

Commit 3f9d3c8

Browse files
author
Roberto De Ioris
authored
Update WritingAColladaFactoryWithPython.md
1 parent 0ea0200 commit 3f9d3c8

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎tutorials/WritingAColladaFactoryWithPython.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,39 @@ Technically it is a skeletal mesh with an animation (something we will try to im
204204

205205
![Broken vampire](https://github.com/20tab/UnrealEnginePython/blob/master/tutorials/WritingAColladaFactoryWithPython_Assets/broken_vampire.png)
206206

207+
time to use some vector math to fix the mesh rotation:
208+
209+
```python
210+
...
211+
212+
from unreal_engine import FVector, FRotator
213+
...
214+
def FixMeshData(self):
215+
# move from collada system (y on top) to ue4 one (z on top, forward decreases over viewer)
216+
for i in range(0, len(self.vertices), 3):
217+
xv, yv, zv = self.vertices[i], self.vertices[i+1], self.vertices[i+2]
218+
# invert forward
219+
vec = FVector(zv * -1, xv, yv) * FRotator(0, -90, 180)
220+
self.vertices[i] = vec.x
221+
self.vertices[i+1] = vec.y
222+
self.vertices[i+2] = vec.z
223+
xn, yn, zn = self.normals[i], self.normals[i+1], self.normals[i+2]
224+
nor = FVector(zn * -1, xn, yn) * FRotator(0, -90, 180)
225+
# invert forward
226+
self.normals[i] = nor.x
227+
self.normals[i+1] = nor.y
228+
self.normals[i+2] = nor.z
229+
230+
# fix uvs from 0 on bottom to 0 on top
231+
for i, uv in enumerate(uvs):
232+
if i % 2 != 0:
233+
uvs[i] = 1 - uv
234+
```
235+
236+
re-run and re-import the vampire, it should be correctly rotated now.
237+
238+
Obviously if we reimport the duck with the current code, its rotation will be wrong. So, time to add a configurator GUI for the factory.
239+
207240
## Adding a GUI to the importer: The Slate API
208241

209242
## Persistent importer options: more subclassing

0 commit comments

Comments
 (0)