Skip to content

Commit

Permalink
fixed rotation vs skin error
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorMouse committed Mar 13, 2022
1 parent dbccb81 commit 80fa67d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@ struct Warcraft_3_Ref_Parser


local pvt = at time 0f in coordsys parent obj.pos
local altPvt = [-pvt.y, pvt.x, pvt.z]
local kgtr = anim1000 LineType:lineType

kgtr.nbrKeys = numkeys cntrl
Expand All @@ -336,11 +336,11 @@ struct Warcraft_3_Ref_Parser
local t = k.time as integer / TicksPerFrame

local val = at time k.time in coordsys parent obj.pos
val = [-val.y,val.x,val.z]
--val = val - pvt
val = val - altpvt
val = val - pvt

append kgtr.AnimBlock ( KeyValuePair Key:t Val:val )
)
Expand All @@ -363,7 +363,7 @@ struct Warcraft_3_Ref_Parser

local rot = inverse obj.rotation
local parentRot = quat 0 0 0 1

if obj.parent != undefined then parentRot = inverse obj.parent.rotation

Expand Down Expand Up @@ -501,7 +501,7 @@ struct Warcraft_3_Ref_Parser
for obj in objects do
if ( getUserProp obj "COLLISION-OBJECT" != undefined and getUserProp obj "COLLISION-OBJECT" == true ) then
(
if ( classof obj == box or classof obj == sphere or classof obj == plane or classof obj == cylinder ) then
if ( classof obj == box or classof obj == sphere or classof obj == plane or classof obj == cylinder or classof obj == editable_mesh ) then
(
local o = object1000 Id:id Name:obj.name ObjectType:#wc3CLID Flags:0x2000 objRef:obj TotalSize:96
id +=1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ struct Warcraft_3_Ref_Read
lay.FresnelMultiplier = readfloat stream
lay.TeamColorMultiplier = readfloat stream





if DEBUG_MODE then format " - %\n" lay

if (lay.Size > 52 ) then
Expand Down Expand Up @@ -678,7 +682,7 @@ struct Warcraft_3_Ref_Read

totalSize -= size
offset += size
if ( _debug_read ) then format "%\n" h
if ( DEBUG_MODE ) then format "%\n" h
append wc3_helpers h
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,13 @@ struct Warcraft_3_Ref_Write
if( classOf selectionSphere == sphere ) then radius = selectionSphere.radius * 4.0

writefloat mdx.stream radius

local bbox = _parser.GetMODLBoundingBoxBetweenFrames 0 1
local bbox = #()
if( radius > 0.0 ) then (
bbox[1] = selectionSphere.min
bbox[2] = selectionSphere.max
)
else
bbox = _parser.GetMODLBoundingBoxBetweenFrames 0 10000

_writer.WriteVector3 mdx.stream bbox[1]
_writer.WriteVector3 mdx.stream bbox[2]
Expand Down Expand Up @@ -222,6 +227,7 @@ struct Warcraft_3_Ref_Write
),
function WriteLAYS mdx mtlsIndex layerIndex=
(

local mat = mdx.mtls[mtlsIndex].MaterialRef
local laySize = 52

Expand All @@ -244,7 +250,7 @@ struct Warcraft_3_Ref_Write
local fresnel_multi = 0.0
local tealcolor_multi = 0.0
local alpha_init = 1.0

if layerIndex == 1 then (
if mat.unlit then shadingFlags += 0x01
if mat.envmap then shadingFlags += 0x02
Expand All @@ -263,7 +269,7 @@ struct Warcraft_3_Ref_Write
tealcolor_multi = mat.teamcolor_multiplier
alpha_init = mat.material_alpha / 100.0
)

writeLong mdx.stream shadingFlags

local texsID = _parser.GetTextureId mat layerIndex mdx.TEXS
Expand Down Expand Up @@ -661,6 +667,7 @@ struct Warcraft_3_Ref_Write
if obj.ObjectType == #wc3CLID then
(
totalSize += obj.TotalSize
if ( classof obj.objRef == editable_mesh ) then totalSize += 28
if ( classof obj.objRef == box ) then totalSize += 28
if ( classof obj.objRef == plane ) then totalSize += 28
if ( classof obj.objRef == sphere ) then totalSize += 20
Expand Down Expand Up @@ -688,7 +695,16 @@ struct Warcraft_3_Ref_Write
_writer.WriteKGAnim mdx.stream obj.KGRT
_writer.WriteKGAnim mdx.stream obj.KGSC


if ( classof obj.objRef == Editable_Mesh ) then
(
writeLong mdx.stream 0
writeFloat mdx.stream obj.objRef.min.x
writeFloat mdx.stream obj.objRef.min.y
writeFloat mdx.stream obj.objRef.min.z
writeFloat mdx.stream obj.objRef.max.x
writeFloat mdx.stream obj.objRef.max.y
writeFloat mdx.stream obj.objRef.max.z
)
if ( classof obj.objRef == box ) then
(
writeLong mdx.stream 0
Expand Down

0 comments on commit 80fa67d

Please sign in to comment.