I’ve finally managed to successfully generate proper procedural actor files, but there are some minor problems regarding transformations: both texture transformations and 3D geometry transformations.
1. Texture transforms:
I’ll start with the texture transformations. The image below highlights the problem:
The right segment of the above image shows the texture on a cube as generated within the game under a certain transform. The left segment shows the same texture on the cube saved as an .egg file but, under the same transform. Visually as you can see, they are different. Here is the in-game code used to set the texture transform:
nodeP.setTexOffset(TextureStage.getDefault(), self.u_offset, self.v_offset)
nodeP.setTexRotate(TextureStage.getDefault(), self.tex_rotate)
nodeP.setTexScale(TextureStage.getDefault(), self.u_scale, self.v_scale)
And when writing out the file to disk, here is the code used to set the texture transform data:
x_s=nodeP.getTexScale(TextureStage.getDefault()).x
y_s=nodeP.getTexScale(TextureStage.getDefault()).y
rot=nodeP.getTexRotate(TextureStage.getDefault())
x_off=nodeP.getTexOffset(TextureStage.getDefault()).x
y_off=nodeP.getTexOffset(TextureStage.getDefault()).y
The values set both within the game and written to disk are these ones: scale:2.0 and 2.0, rotation: 4.0, translation: 0.10000000149 and 0.10000000149. So if both the texture values in-game and in the file are the same, why do they look different visually? How would I resolve this?
2. 3D Geometry Transforms:
Regarding this issue, I discovered that the translation facet of the transform error could be resolved by multiplying the vector that stored the translation data by 10. The scale transform applied both in-game and the in the file is alright, but I am not sure about the rotation transform, it looks slightly erroneous:
The left segment of the above image shows the two models as generated within the game, whereas the right segment shows the file generated from the two models. To get the hpr, pos and scale of the models as I write them to disk, this is what I do:
transformz=EggTransform()
#rotation:
transformz.addRotx(nodeP.getP(render))
transformz.addRoty(nodeP.getR(render))
transformz.addRotz(nodeP.getH(render))
#scale:
transformz.addScale3d(VBase3D(nodeP.getSx(render),nodeP.getSy(render),nodeP.getSz(render)))
#translation:
transformz.addTranslate3d(Vec3D(nodeP.getX(render),nodeP.getY(render),nodeP.getZ(render))*10)
As you can see on the last line above, to fix the translation error, I multiply the Vec3D object by 10, and all is apparently well. Here is the fixed file:
So the last question: why does the transform data from the models in the game not bring about the same result in the generated .egg file? For instance, regarding the translate issue, if the value of the position [relative to the render nodePath] of one model is “-1.668”, why must I multiply it by 10->"-16.68" to get the same visual result when the .egg file is loaded?
Thanks.