aboutsummaryrefslogtreecommitdiff
path: root/po/pl/minetest.po
diff options
context:
space:
mode:
Diffstat (limited to 'po/pl/minetest.po')
0 files changed, 0 insertions, 0 deletions
3' href='#n53'>53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
local pole_texture = "advtrains_signals_japan_mast.png"
local signal_face_texture = "advtrains_hud_bg.png^[colorize:#000000:255"
local pole_radius = 1/16
local pole_box = {-pole_radius,-1/2,-pole_radius,pole_radius,1/2,pole_radius}
local light_radius = 1/20
local signal_width = 6*light_radius
local signal_thickness = pole_radius*3
local signal_height = {}
local signal_box = {}
local light_red = "advtrains_hud_bg.png^[colorize:red:255"
local light_yellow = "advtrains_hud_bg.png^[colorize:orange:255"
local light_green = "advtrains_hud_bg.png^[colorize:lime:255"
local light_purple = "advtrains_hud_bg.png^[colorize:purple:255"
local light_distant = light_purple
local light_off = signal_face_texture

do
	local model_path_prefix = table.concat({minetest.get_modpath("advtrains_signals_japan"), "models", "advtrains_signals_japan_"}, DIR_DELIM)

	local function vertex(x, y, z)
		return string.format("v %f %f %f", x, y, z)
	end
	local function texture(u, v)
		return string.format("vt %f %f", u, v)
	end
	local function face_element(v, vt)
		if vt then
			return string.format("%d/%d", v, vt)
		end
		return tonumber(v)
	end
	local function face_elements(...)
		local st = {"f"}
		local args = {...}
		local len = #args
		for i = 1, len, 2 do
			st[(i+3)/2] = face_element(args[i], args[i+1])
		end
		return table.concat(st, " ")
	end
	local function sequential_elements(v0, vt0, count)
		local st = {}
		for i = 1, count do
			st[i] = face_element(v0+i, vt0+i)
		end
		return table.concat(st, " ")
	end
	local function mod_lower(min, a, b)
		return min + (a-min)%b
	end
	local function connect_circular(v0, vt0, count)
		return "f " .. sequential_elements(v0, vt0, count)
	end
	local function connect_cylindrical(v0, vt0, count)
		local st = {}
		for i = 0, count-1 do
			local j = (i+1)%count
			local v1 = v0+i+1
			local v2 = v1+count
			local v3 = v0+j+1
			local v4 = v3+count
			local vt1 = vt0+i+1
			local vt2 = vt1+count+1
			st[i+1] = face_elements(v1, vt1, v3, vt1+1, v4, vt2+1, v2, vt2)
		end
		return table.concat(st, "\n")
	end
	local function circular_textures(u0, v0, r, count, total, angular_offset, direction)
		local st = {}
		if not angular_offset then
			angular_offset = 0
		end
		if not total then
			total = count
		end
		if not direction then
			direction = 1
		end
		for i = 0, count-1 do
			local theta = angular_offset + direction*i/total*2*math.pi
			local u, v = r*math.cos(theta), r*math.sin(theta)
			st[i+1] = texture(u0+u, v0+v)
		end
		return table.concat(st, "\n")
	end
	local function rectangular_textures(u0, v0, u1, v1, count)
		local st = {}
		local width = u1-u0
		for i = 0, count do
			local u = u0+i/count*width
			st[i+1] = texture(u, v0)
			st[i+count+2] = texture(u, v1)
		end
		return table.concat(st, "\n")
	end

	-- generate pole model
	local pole_npolygon = 32
	local pole_vertex_count = pole_npolygon*2
	local pole_uv_count = pole_npolygon*3+2
	local pole_vertices = {}
	local pole_objdef = {
		"g pole",
		"usemtl pole",
		connect_circular(0, 0, pole_npolygon),
		connect_circular(pole_npolygon, 0, pole_npolygon),
		connect_cylindrical(0, pole_npolygon, pole_npolygon),
	}
	local pole_uv = {
		circular_textures(0.5, 0.5, 0.5, pole_npolygon),
		rectangular_textures(0, 0, 1, 1, pole_npolygon),
	}
	for i = 0, pole_npolygon-1 do
		local theta = i*2/pole_npolygon*math.pi
		local r = pole_radius
		local x, z = r*math.sin(theta), r*math.cos(theta)
		local lower_index = i+1
		local upper_index = lower_index+pole_npolygon
		pole_vertices[lower_index] = vertex(x, -0.5, z)
		pole_vertices[upper_index] = vertex(x, 0.5, z)
	end
	pole_vertices = table.concat(pole_vertices, "\n")
	pole_objdef = table.concat(pole_objdef, "\n")
	pole_uv = table.concat(pole_uv, "\n")
	minetest.safe_file_write(model_path_prefix .. "pole.obj", table.concat({pole_vertices, pole_uv, pole_objdef}, "\n"))

	-- generate signals
	for lightcount = 5, 6 do
		for rotname, rot in pairs {["0"] = 0, ["30"] = 26.5, ["45"] = 45, ["60"] = 63.5} do
			local rot = math.rad(rot)
			local lightradius = 0.05
			local lightspacing = 0.04
			local halfwidth = signal_width/2
			local halfheight = (2+lightcount)*lightradius+(lightcount-1)*lightspacing/2
			local halfthickness = signal_thickness/2
			local half_npolygon = pole_npolygon/2
			local quarter_npolygon = pole_npolygon/4
			local boxside = math.max(halfwidth, halfthickness*2)
			signal_height[lightcount] = halfheight*2
			signal_box[lightcount] = {-boxside, -halfheight, -boxside, boxside, halfheight, boxside}

			local _vertex = vertex
			local rv = vector.new(0, rot, 0)
			local function vertex(x, y, z)
				local v = vector.rotate(vector.new(x, y, z), rv)
				return _vertex(v.x, v.y, v.z)
			end

			-- generate signal face
			local face_vertices = {}
			local face_uv = {
				circular_textures(0.5, 0.5+halfheight-3*lightradius, halfwidth, half_npolygon+1, pole_npolygon),
				circular_textures(0.5, 0.5-halfheight+3*lightradius, halfwidth, half_npolygon+1, pole_npolygon, math.pi),
				rectangular_textures(0, 0, 1, 1, 2+pole_npolygon),
			}
			local face_objdef = {
				"g face",
				"usemtl face",
				connect_circular(pole_vertex_count+2+pole_npolygon, pole_uv_count, 2+pole_npolygon),
				connect_circular(pole_vertex_count, pole_uv_count, 2+pole_npolygon),
				connect_cylindrical(pole_vertex_count, pole_uv_count+2+pole_npolygon, 2+pole_npolygon),
			}
			local face_vertex_count = 4*half_npolygon+4
			local face_uv_count = 2*(half_npolygon+1) + 2*(pole_npolygon+3)
			for i = 0, half_npolygon do
				local theta = i/half_npolygon*math.pi
				local r = halfwidth
				local x, y = r*math.cos(theta), halfheight-3*lightradius+r*math.sin(theta)
				face_vertices[i+1] = vertex(x, y, -halfthickness)
				face_vertices[i+2+half_npolygon] = vertex(-x, -y, -halfthickness)
				face_vertices[i+3+2*half_npolygon] = vertex(x, y, halfthickness)
				face_vertices[i+4+3*half_npolygon] = vertex(-x, -y, halfthickness)
			end

			-- generate lights
			local light_vertices = {}
			local light_vertex_count = 8*(half_npolygon+1)+pole_npolygon
			local light_uv = {rectangular_textures(0, 0, 1, 1, half_npolygon)}
			local light_uv_count = 2*(half_npolygon+1)+pole_npolygon*lightcount
			local light_objdef_face = {}
			local light_objdef_main = {
				"g light",
				"usemtl light",
			}
			for i = 1, lightcount do
				local x0, y0 = 0, -halfheight + (2*i+1)*lightradius + (i-1)*lightspacing
				local v0 = light_vertex_count*(i-1)
				for j = 0, half_npolygon do
					local theta = j/half_npolygon*math.pi
					local xs, ys = math.cos(theta), math.sin(theta)
					for k, v in pairs {
						{xm = -1, ym = 1, rm = 1, z = 1},
						{xm = 1, ym = 1, rm = 0.8, z = 1},
						{xm = -1, ym = 1, rm = 1, z = 2},
						{xm = 1, ym = 1, rm = 0.8, z = 2},
						{xm = 1, ym = -1, rm = 1, z = 1},
						{xm = -1, ym = -1, rm = 0.8, z = 1},
						{xm = 1, ym = -1, rm = 1, z = 1.5},
						{xm = -1, ym = -1, rm = 0.8, z = 1.5},
					} do
						local x = x0+xs*lightradius*v.xm*v.rm