|
|
@ -13,10 +13,12 @@ |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# You should have received a copy of the GNU General Public License |
|
|
|
# along with Korman. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
# along with Korman. If not, see <http://www.gnu.org/licenses/>. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import bpy |
|
|
|
import mathutils |
|
|
|
import mathutils |
|
|
|
from PyHSPlasma import * |
|
|
|
from PyHSPlasma import * |
|
|
|
import weakref |
|
|
|
import weakref |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from ..helpers import TemporaryObject |
|
|
|
from . import utils |
|
|
|
from . import utils |
|
|
|
|
|
|
|
|
|
|
|
class PhysicsConverter: |
|
|
|
class PhysicsConverter: |
|
|
@ -24,13 +26,17 @@ class PhysicsConverter: |
|
|
|
self._exporter = weakref.ref(exporter) |
|
|
|
self._exporter = weakref.ref(exporter) |
|
|
|
|
|
|
|
|
|
|
|
def _convert_mesh_data(self, bo, physical, indices=True): |
|
|
|
def _convert_mesh_data(self, bo, physical, indices=True): |
|
|
|
mesh = bo.data |
|
|
|
mesh = bo.to_mesh(bpy.context.scene, True, "RENDER") |
|
|
|
mesh.update(calc_tessface=indices) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Yes, we have to have transform data here, even if we have a CoordInterface |
|
|
|
|
|
|
|
mat = bo.matrix_world |
|
|
|
mat = bo.matrix_world |
|
|
|
physical.rot = utils.quaternion(mat.to_quaternion()) |
|
|
|
|
|
|
|
|
|
|
|
with TemporaryObject(mesh, bpy.data.meshes.remove) as mesh: |
|
|
|
|
|
|
|
# We can only use the plPhysical xforms if there is a CI... |
|
|
|
|
|
|
|
if self._mgr.has_coordiface(bo): |
|
|
|
|
|
|
|
mesh.update(calc_tessface=indices) |
|
|
|
physical.pos = utils.vector3(mat.to_translation()) |
|
|
|
physical.pos = utils.vector3(mat.to_translation()) |
|
|
|
|
|
|
|
quat = mat.to_quaternion() |
|
|
|
|
|
|
|
quat.normalize() |
|
|
|
|
|
|
|
physical.rot = utils.quaternion(quat) |
|
|
|
|
|
|
|
|
|
|
|
# Physicals can't have scale... |
|
|
|
# Physicals can't have scale... |
|
|
|
scale = mat.to_scale() |
|
|
|
scale = mat.to_scale() |
|
|
@ -40,6 +46,11 @@ class PhysicsConverter: |
|
|
|
else: |
|
|
|
else: |
|
|
|
# Dagnabbit... |
|
|
|
# Dagnabbit... |
|
|
|
vertices = [hsVector3(i.co.x * scale.x, i.co.y * scale.y, i.co.z * scale.z) for i in mesh.vertices] |
|
|
|
vertices = [hsVector3(i.co.x * scale.x, i.co.y * scale.y, i.co.z * scale.z) for i in mesh.vertices] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
# apply the transform to the physical itself |
|
|
|
|
|
|
|
mesh.transform(mat) |
|
|
|
|
|
|
|
mesh.update(calc_tessface=indices) |
|
|
|
|
|
|
|
vertices = [hsVector3(i.co.x, i.co.y, i.co.z) for i in mesh.vertices] |
|
|
|
|
|
|
|
|
|
|
|
if indices: |
|
|
|
if indices: |
|
|
|
indices = [] |
|
|
|
indices = [] |
|
|
|