1
This commit is contained in:
commit
a85391509d
211 files changed
+28903
No files matched your search
@@ -0,0 +1,91 @@
|
||||
-- Run in Studio Command Bar with the imported Model selected.
|
||||
-- Does not publish, replace the lobby, or change global Lighting.
|
||||
local Data = game:GetService("HttpService"):JSONDecode([==[{"meshes":[{"id":"A0001","source":"Central citadel | four ground entrances.003","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-32,12,32],"size":[32,24,32]},{"position":[-32,36,32],"size":[32,24,32]},{"position":[-32,36,10.46154],"size":[32,24,11.076919555664062]},{"position":[-32,36,0],"size":[32,24,9.846159934997559]},{"position":[-32,36,-10.46154],"size":[32,24,11.076919555664062]},{"position":[-32,12,-32],"size":[32,24,32]},{"position":[-32,36,-32],"size":[32,24,32]},{"position":[0,36,32],"size":[32,24,32]},{"position":[0,36,10.46154],"size":[32,24,11.076919555664062]},{"position":[0,36,0],"size":[32,24,9.846159934997559]},{"position":[0,36,-10.46154],"size":[32,24,11.076919555664062]},{"position":[0,36,-32],"size":[32,24,32]},{"position":[32,12,32],"size":[32,24,32]},{"position":[32,36,32],"size":[32,24,32]},{"position":[32,36,10.46154],"size":[32,24,11.076919555664062]},{"position":[32,36,0],"size":[32,24,9.846159934997559]},{"position":[32,36,-10.46154],"size":[32,24,11.076919555664062]},{"position":[32,12,-32],"size":[32,24,32]},{"position":[32,36,-32],"size":[32,24,32]}]},{"id":"A0002","source":"Citadel | east ascent to third level","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0003","source":"Citadel | middle gallery and third floor","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[0,60,32],"size":[96,24,32]},{"position":[0,84,32],"size":[96,24,32]},{"position":[0,84,0],"size":[96,24,32]},{"position":[0,60,-32],"size":[96,24,32]},{"position":[0,84,-32],"size":[96,24,32]}]},{"id":"A0004","source":"Citadel | third level cover","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0005","source":"Citadel | third level parapet","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0006","source":"Citadel | third level parapet.001","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0007","source":"Citadel | west ascent to third level","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0008","source":"Corner fort inward access.008","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0009","source":"Corner fort inward access.009","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0010","source":"Corner fort inward access.010","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0011","source":"Corner fort inward access.011","shape":"wedge","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0012","source":"Corner fort top cover.008","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0013","source":"Corner fort top cover.009","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0014","source":"Corner fort top cover.010","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0015","source":"Corner fort top cover.011","shape":"box","neon":false,"color":[1,0.779706,0.234795],"colliders":[]},{"id":"A0016","source":"Corner fort.008","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-336,12,304],"size":[32,24,96]},{"position":[-336,32,304],"size":[32,16,96]},{"position":[-304,32,304],"size":[32,16,96]},{"position":[-272,12,304],"size":[32,24,96]},{"position":[-272,32,304],"size":[32,16,96]}]},{"id":"A0017","source":"Corner fort.009","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[-336,12,-304],"size":[32,24,96]},{"position":[-336,32,-304],"size":[32,16,96]},{"position":[-304,32,-304],"size":[32,16,96]},{"position":[-272,12,-304],"size":[32,24,96]},{"position":[-272,32,-304],"size":[32,16,96]}]},{"id":"A0018","source":"Corner fort.010","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[272,12,304],"size":[32,24,96]},{"position":[272,32,304],"size":[32,16,96]},{"position":[304,32,304],"size":[32,16,96]},{"position":[336,12,304],"size":[32,24,96]},{"position":[336,32,304],"size":[32,16,96]}]},{"id":"A0019","source":"Corner fort.011","shape":"gate","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[{"position":[272,12,-304],"size":[32,24,96]},{"position":[272,32,-304],"size":[32,16,96]},{"position":[304,32,-304],"size":[32,16,96]},{"position":[336,12,-304],"size":[32,24,96]},{"position":[336,32,-304],"size":[32,16,96]}]},{"id":"A0020","source":"District corner screen.008","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0021","source":"District corner screen.009","shape":"box","neon":false,"color":[0.373427,0.449204,0.537099],"colliders":[]},{"id":"A0022","source":"District corner screen.010","shape":"box","neon":false,"color":[0.373427,0.449204,0.Line truncated
|
||||
local selection = game:GetService("Selection"):Get()
|
||||
local model = workspace:FindFirstChild("HunterMonolithImport") or selection[1]
|
||||
assert(model and model:IsA("Model"), "Select the imported Hunter Monolith Model first")
|
||||
local parts = {}
|
||||
for _, p in model:GetDescendants() do
|
||||
if p:IsA("MeshPart") then
|
||||
local id = string.match(p.Name, "([AL]%d%d%d%d)")
|
||||
if id then assert(not parts[id], "Duplicate mesh ID "..id); parts[id] = p end
|
||||
end
|
||||
end
|
||||
local function sourcePart(prefix)
|
||||
for _, d in Data.meshes do
|
||||
if string.sub(d.source, 1, #prefix)==prefix then return assert(parts[d.id], "Missing "..d.id) end
|
||||
end
|
||||
error("Missing source anchor "..prefix)
|
||||
end
|
||||
for _,d in Data.meshes do assert(parts[d.id], "Import is incomplete: "..d.id) end
|
||||
local east,west = sourcePart("East enclosure"),sourcePart("West enclosure")
|
||||
local north,south = sourcePart("North enclosure"),sourcePart("South enclosure")
|
||||
local foundation=sourcePart("Foundation")
|
||||
local scale=(east.Position-west.Position).Magnitude/880
|
||||
assert(scale>0,"Invalid imported size")
|
||||
model:ScaleTo(model:GetScale()/scale)
|
||||
local right=(east.Position-west.Position).Unit
|
||||
local back=(south.Position-north.Position).Unit
|
||||
local up=back:Cross(right).Unit
|
||||
assert(up:Dot(Vector3.yAxis)>.98,"Model is not upright: correct import axis before setup")
|
||||
local frame=CFrame.fromMatrix(foundation.Position+up*4,right,up,back)
|
||||
local function vec(t) return Vector3.new(t[1],t[2],t[3]) end
|
||||
local function color(t) return Color3.new(t[1],t[2],t[3]) end
|
||||
local previous=model:FindFirstChild("HunterImportSetup")
|
||||
if previous then
|
||||
assert(previous:GetAttribute("GeneratedByHunterImport"),"Unexpected existing setup container")
|
||||
previous:Destroy()
|
||||
end
|
||||
local setup=Instance.new("Folder")
|
||||
setup.Name="HunterImportSetup";setup:SetAttribute("GeneratedByHunterImport",true)
|
||||
setup.Parent=model
|
||||
local collisions=Instance.new("Folder");collisions.Name="PassageCollisions";collisions.Parent=setup
|
||||
local lamps=Instance.new("Folder");lamps.Name="ColoredLights";lamps.Parent=setup
|
||||
local missingTextures={}
|
||||
local collisionCount=0
|
||||
for index,d in Data.meshes do
|
||||
local p=parts[d.id]
|
||||
p.Anchored=true;p.CanTouch=false
|
||||
p:SetAttribute("HunterSourceId",d.id)
|
||||
p.CanCollide=d.shape=="box" or d.shape=="wedge"
|
||||
p.CanQuery=p.CanCollide
|
||||
if p.CanCollide then p.CollisionFidelity=Enum.CollisionFidelity.Hull end
|
||||
local sa=p:FindFirstChildWhichIsA("SurfaceAppearance")
|
||||
local textured=(p.TextureID~="") or (sa and sa.ColorMap~="")
|
||||
if d.shape=="decor" then
|
||||
p.Color=color(d.color)
|
||||
if d.neon then p.Material=Enum.Material.Neon else p.Material=Enum.Material.SmoothPlastic end
|
||||
elseif textured then
|
||||
p.Color=Color3.new(1,1,1)
|
||||
else
|
||||
table.insert(missingTextures,d.id)
|
||||
end
|
||||
for _,b in d.colliders do
|
||||
local c=Instance.new("Part");c.Name=d.id.."_Collision"
|
||||
c.Size=vec(b.size);c.CFrame=frame*CFrame.new(vec(b.position))
|
||||
c.Anchored=true;c.Transparency=1;c.CanCollide=true;c.CanQuery=true;c.CanTouch=false
|
||||
c.Parent=collisions;collisionCount+=1
|
||||
end
|
||||
if index%40==0 then task.wait() end
|
||||
end
|
||||
for _,d in Data.lights do
|
||||
local p=Instance.new("Part");p.Name=d.name
|
||||
p.Size=Vector3.new(2,2,2);p.Transparency=1;p.Anchored=true
|
||||
p.CanCollide=false;p.CanTouch=false;p.CanQuery=false
|
||||
local pos=frame:PointToWorldSpace(vec(d.position))
|
||||
local dir=frame:VectorToWorldSpace(vec(d.direction))
|
||||
local stableUp=math.abs(dir:Dot(Vector3.yAxis))>.99 and Vector3.xAxis or Vector3.yAxis
|
||||
p.CFrame=CFrame.lookAt(pos,pos+dir,stableUp)
|
||||
local light=Instance.new("SpotLight")
|
||||
light.Name="Halogen";light.Color=color(d.color);light.Brightness=d.brightness
|
||||
light.Range=d.range;light.Angle=110;light.Face=Enum.NormalId.Front
|
||||
light.Shadows=vec(d.position).Magnitude<96
|
||||
light.Parent=p;p.Parent=lamps
|
||||
end
|
||||
model:SetAttribute("HunterMapSize",896)
|
||||
model:SetAttribute("HunterCentralLevels","0,48,96")
|
||||
model:SetAttribute("HunterImportPrepared",true)
|
||||
game:GetService("ChangeHistoryService"):SetWaypoint("Configure Hunter Monolith import")
|
||||
if #missingTextures>0 then warn("Missing textures on "..#missingTextures.." meshes; restore before playtest") end
|
||||
return {meshes=#Data.meshes,colliders=collisionCount,lights=#Data.lights,missingTextures=missingTextures}
|
||||
|
||||
Reference in new issue
Block a user