惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
量子位
V
Visual Studio Blog
博客园 - Franky
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
罗磊的独立博客
小众软件
小众软件
V
V2EX
GbyAI
GbyAI
B
Blog RSS Feed
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
有赞技术团队
有赞技术团队
月光博客
月光博客
Recent Announcements
Recent Announcements
雷峰网
雷峰网
F
Fortinet All Blogs
M
MIT News - Artificial intelligence

Cyberia

复活吧微软边缘 - Cyberia 从零开始的EAC抓轨教程 - Cyberia Apophenia, 新时代补全工具 - Cyberia 浅谈博客设计 - Cyberia 爱软TV之GitHub - Cyberia 排印演进 - Cyberia EAC相关工具集合 - Cyberia 《C(金钱掌控)》观后感 - Cyberia C#在Windows UI开发中的衰落 - Cyberia 存储退潮 字体padding计算器 开源已死 如何写出优雅完整的音频元数据 自动化EAC音频抓取 起夜级家庭网络正在变得越来越重要 优化Powershell的启动时间 无JavaScript其实没有很重要 你不需要一个电纸书阅读器 文件分享的难题 为什么我不敢看都市 某科学的 SSH 算号指南 时代的辉夜姬 为什么 Pixi 是神 关于神椿的过去,当下以及未来,我的一点看法 Tahoe 的图标令人难评 The EVE of PUSHING LIMITS 在 Word 中通过制表符实现居中对齐等操作 编码之殇:前 Unicode 时代的 WAV 处理 sHELL 即地狱 WR1800K AX NAND 路由器刷入 Immortalwrt
Extra Decal Pre Processor
Nullpinter · 2024-06-08 · via Cyberia

Prerequisite#

  1. Cities: Skylines 2
  2. ExtraAssetsImporter
  3. PowerShell 7

WINDOWS EMBEDED POWERSHELL IS OUTDATED

The powershell that comes with windows is powershell 5, which doesn’t fully realize the functionality of 7!

Step#

  1. Setup Mod toolchain in CS2, basically check it in game.
  2. Follow the tutorial to create mods that depend on EAI, this article does not focus on these.
  3. Build decals.

Let’s assume a scenario where you have a folder for all your HD decals (.png) and you need to create uniform decals and thumbnails based on these decals.

So you have:

D:\lorem

├─blahblah

│ a.png

│ b1.png

│ b2.png

│ b3.png

│ b4.png

│ b1.png

│ b2.png

decal.json can be obtained from the EAI example.

Place build.ps1 and decal.json to this directory. Then:

D:\lorem

├─blahblah

│ build.ps1

│ decal.json

│ a.png

│ b1.png

│ b2.png

│ b3.png

│ b4.png

│ b1.png

│ b2.png

Content in build.ps1#

function GenerateIconAndMesh {

param(

$file

)

try {

$originalImage = [System.Drawing.Image]::FromFile($file.FullName)

$maxSize = [Math]::Max($originalImage.Width, $originalImage.Height)

$aspectRatio = $originalImage.Width / $originalImage.Height

$squareImage = New-Object System.Drawing.Bitmap $maxSize, $maxSize

$graphics = [System.Drawing.Graphics]::FromImage($squareImage)

$graphics.Clear([System.Drawing.Color]::Transparent)

$x = ($maxSize - $originalImage.Width) / 2

$y = ($maxSize - $originalImage.Height) / 2

$graphics.DrawImage($originalImage, $x, $y, $originalImage.Width, $originalImage.Height)

$resizedImage = New-Object System.Drawing.Bitmap 128, 128

$resizeGraphics = [System.Drawing.Graphics]::FromImage($resizedImage)

$resizeGraphics.InterpolationMode = [System.Drawing.Drawing2D.InterpolationMode]::HighQualityBicubic

$resizeGraphics.DrawImage($squareImage, 0, 0, 128, 128)

$resizeGraphics.Dispose()

$newFilePath = [IO.Path]::Combine($file.DirectoryName, "icon.png")

$resizedImage.Save($newFilePath)

Write-Host "Saved icon to $newFilePath"

$jsonPath = Join-Path $file.DirectoryName "decal.json"

if (Test-Path $jsonPath) {

$json = Get-Content $jsonPath -Raw | ConvertFrom-Json

$json.Vector.colossal_MeshSize.x = $aspectRatio * 1.5

$json.Vector.colossal_MeshSize.z = 1.5

$json | ConvertTo-Json -Depth 10 | Set-Content $jsonPath

Write-Host "Aspect Ratio = $aspectRatio"

}

else {

Write-Warning "decal.json not found in the directory of $($file.DirectoryName)"

}

}

catch {

Write-Warning "Error processing file $($file.FullName): $_"

}

finally {

# dispose

if ($null -ne $graphics) {

$graphics.Dispose()

}

if ($null -ne $squareImage) {

$squareImage.Dispose()

}

if ($null -ne $resizedImage) {

$resizedImage.Dispose()

}

if ($null -ne $originalImage) {

$resizedImage.Dispose()

}

}

}

Get-ChildItem | Foreach-Object {

if ($_.Extension -eq ".png") {

$folder = "./$($_.BaseName)"

mkdir $folder -ErrorAction SilentlyContinue

$base = "./$($_.BaseName)/_BaseColorMap.png"

Copy-Item $_.FullName -Destination $base

# $icon = "./$($_.BaseName)/icon.png"

# Copy-Item $_.FullName -Destination $icon

if (Test-Path ./decal.json) {

Copy-Item ./decal.json -Destination $folder

}

else {

Write-Warning "decal.json not found"

}

GenerateIconAndMesh(Get-Item $base)

}

}

Run this script in a terminal. A quick way to open a terminal is to type pwsh in explorer’s bar.

Now you’ve got everything done.