I’m trying to make a script to copy/paste lights into unreal engine 5.11+
The problem is the rotations, I can’t get it to work, once pasted into unreal the rotation is all wrong for some lights but it’s fine for others.
I was trying to follow the code on the datasmith c++ code but its still not working
(
_LightSpot_strStart =
"Begin Map
Begin Level
"
_LightSpot_end =
"End Level
Begin Surface
End Surface
End Map
"
_LightSpot_str =
"Begin Actor Class=/Script/Engine.SpotLight Name=%
Archetype=/Script/Engine.SpotLight'/Script/Engine.Default__SpotLight'
Begin Object Class=/Script/Engine.ArrowComponent Name=\"ArrowComponent0\"
Archetype=/Script/Engine.ArrowComponent'Default__SpotLight:ArrowComponent0'
End Object
Begin Object Class=SpotLightComponent Name=\"LightComponent0\"
Archetype=SpotLightComponent'Default__SpotLight:LightComponent0'
End Object
Begin Object Name=\"ArrowComponent0\"
AttachParent=LightComponent0
End Object
Begin Object Name=\"LightComponent0\"
SourceRadius=2.0
IntensityUnits=Lumens
bUseTemperature=True
IESBrightnessScale=0.100000
LightGuid=D40F03274E2FB63E3A1BBA9C54B5D3C3
IndirectLightingIntensity=3.000000
bPrecomputedLightingIsValid=False
RelativeLocation=(X=%,Y=%,Z=%)
RelativeRotation=(Pitch=%,Yaw=%,Roll=%)
Mobility=Movable
End Object
SpotLightComponent=LightComponent0
ArrowComponent=ArrowComponent0
LightComponent=LightComponent0
RootComponent=LightComponent0
ActorLabel=\"%\"
End Actor
"
fn copyLightToClipboard theLights =
(
strFile = stringstream ""
format _LightSpot_strStart to:strFile
for c = 1 to theLights.count do
(
_Name = theLights[c].name
_expScale = 2.54
_Pos = theLights[c].pos * _expScale
quatRot = theLights[c].transform.rotationpart as quat
quatRot.y = quatRot.y * -1
quatRot = quatRot * (quat 90 0 -90 1)
theRotation = quatToEuler2 quatRot
x = theRotation.y
y = theRotation.z
z = theRotation.x
theRotation.x = x
theRotation.y = y
theRotation.z = z
format _LightSpot_str _Name _Pos.x (_Pos.y*-1) _Pos.z theRotation.x theRotation.y theRotation.z _Name to:strFile
)
format _LightSpot_end to:strFile
setClipBoardText strFile
free strFile
)
theLights = selection as array
copyLightToClipboard theLights
)
Any suggestions are appreciated.
Guillermo