Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
TaylorMouse committed Mar 8, 2022
2 parents e77e377 + 4ca5639 commit dbccb81
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 37 deletions.
Binary file modified Documentation/Tutorial/Resources/TM_Druidbear.zip
Binary file not shown.
28 changes: 6 additions & 22 deletions Warcraft_3_Reforged_Tools/GriffonStudios_Helpers.ms
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,14 @@
*/
struct GriffonStudios_Helpers
(
function FixZRotation rot=
function ZRotation rot=
(
local pnt = getnodebyname "IMPORTEXPORT_BASE"
if pnt == undefined then
(
format "IMPORTEXPORT_BASE not found, creating one now"
pnt = point name:"IMPORTEXPORT_BASE"
select $*
group selection name:"MyGroup" select:true
$MyGroup.pivot = [0,0,0]
rotate $MyGroup (angleaxis rot [0,0,1])
ungroup $MyGroup

local selectedObjects = #()

for obj in objects do
(
if ( obj.parent == undefined and obj.name != "IMPORTEXPORT_BASE" ) then
append selectedObjects obj
)

if selectedObjects.count > 0 then (
select selectedObjects
$.parent = pnt
rotate pnt (angleaxis rot [0,0,1])
)
)
else
rotate pnt (angleaxis rot [0,0,1])
true
),
function ReplaceString str oldStr newStr =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ STRUCT GriffonStudios_Warcraft_3_Reforged_Exporter
animationrange = interval 0 100
slidertime = 0

_helper.FixZRotation 90

_helper.ZRotation 90


-- gather data from the scene
_parser.GetObjects mdx
_parser.GetSEQS mdx
Expand All @@ -71,7 +72,6 @@ STRUCT GriffonStudios_Warcraft_3_Reforged_Exporter
_parser.GetRIBB mdx
_parser.GetRIBB mdx
_parser.GetPRE2 mdx

-- write the parts to file
mdx.stream = fOpen file "wb"

Expand Down Expand Up @@ -101,11 +101,12 @@ STRUCT GriffonStudios_Warcraft_3_Reforged_Exporter

fFlush mdx.stream
fClose mdx.stream
_helper.ZRotation -90

_helper.FixZRotation -90

animationrange = interval animationInterval.start animationInterval.end
gc()

--enableSceneRedraw()
setArrowCursor()
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ STRUCT WC3REF_MDX
fClose stream
_build.Create mdx

_helper.FixZRotation -90
_helper.ZRotation -90

format "Done!\n"
gc()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +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 @@ -333,7 +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 - pvt

val = [-val.y,val.x,val.z]

--val = val - pvt
val = val - altpvt

append kgtr.AnimBlock ( KeyValuePair Key:t Val:val )
)
Expand All @@ -356,6 +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 @@ -700,7 +708,7 @@ struct Warcraft_3_Ref_Parser
/* get the mesh references that can be exported */
local geos = #()
local mtls = mdx.mtls
local obj = undefined
for obj in objects do
if ( classof obj == editable_mesh and classof obj.material == WC3RefMaterial and obj.ishidden == false) then
append geos ( geo1000 meshRef:obj )
Expand Down Expand Up @@ -1213,6 +1221,8 @@ struct Warcraft_3_Ref_Parser
for m=1 to mdx.MTLS.Count do
if mdx.MTLS[m].MaterialRef == theRibbon.mtlsId then ribb.mtlsId = m - 1



-- KRHA
if ( theRibbon.staticHeightAbove.controller != undefined ) then (
ribb.KRHA = WC3Ref_KG nbrKeys:theRibbon.staticHeightAbove.controller.keys.count lineType:1 glbsId:-1 type:type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ struct Warcraft_3_Ref_Write
),
function WriteTris stream tris=
(

writeShort stream tris[1]
writeShort stream tris[2]
writeShort stream tris[3]
),
function WriteVector3 stream vector3=
(

writeFloat stream vector3.X
writeFloat stream vector3.Y
writeFloat stream vector3.Z
Expand All @@ -46,6 +48,7 @@ struct Warcraft_3_Ref_Write
),
function WriteQuat stream quaternian=
(

writeFloat stream quaternian.x
writeFloat stream quaternian.y
writeFloat stream quaternian.z
Expand Down Expand Up @@ -246,7 +249,7 @@ struct Warcraft_3_Ref_Write
if mat.unlit then shadingFlags += 0x01
if mat.envmap then shadingFlags += 0x02
if mat.wrapwidth then shadingFlags += 0x04
if mat.wrapheight then shadingFlags += 0x04
if mat.wrapheight then shadingFlags += 0x08
if mat.twosided then shadingFlags += 0x10
if mat.nofog then shadingFlags += 0x20
if mat.nodepthset then shadingFlags += 0x40
Expand Down Expand Up @@ -598,9 +601,11 @@ struct Warcraft_3_Ref_Write
for obj in mdx.allobjects do
(
if DEBUG_MODE then format "- %\n" obj.name
writeFloat mdx.stream obj.objRef.pos.x
writeFloat mdx.stream obj.objRef.pos.y
writeFloat mdx.stream obj.objRef.pos.z

writeFloat mdx.stream obj.objRef.pos.x
writeFloat mdx.stream obj.objRef.pos.y
writeFloat mdx.stream obj.objRef.pos.z

)

),
Expand Down Expand Up @@ -743,12 +748,15 @@ struct Warcraft_3_Ref_Write
writeLong mdx.stream mdx.allObjects.count

if DEBUG_MODE then format "Nbr: % Size: %\n" mdx.allObjects.count totalSize

for obj in mdx.allobjects do
(
local transf = obj.objRef.Transform

for r=1 to 4 do
for c=1 to 3 do
writeFloat mdx.stream obj.objRef.Transform[r][c]
for c=1 to 3 do (
writeFloat mdx.stream obj.objRef.Transform[r][c]
)
)
),
function WriteCAMS mdx=
Expand Down Expand Up @@ -1044,6 +1052,7 @@ struct Warcraft_3_Ref_Write
function WritePRE2 mdx=
(
local totalSize = 0
if mdx.PRE2 == undefined then return undefined
for pre2 in mdx.PRE2 do totalSize += pre2.Size

if totalSize == 0 then return undefined
Expand Down

0 comments on commit dbccb81

Please sign in to comment.