シーンチェンジ
公開スクリプトの追加方法は、追加方法・留意点の項目を参照して下さい。
また、スクリプトを公開される方は、必ず同ページのスクリプト記載ルールをご確認ください。
名称 | 製作者 | 説明 | 出典/最終更新 |
---|---|---|---|
回転(分割) | ゆうき | 画像などが分割されて、それぞれが回転しながらシーンチェンジします。 2012/01/08 かなり改良 |
2012/01/08 |
ラスター | 白水 | 画面にラスターをかけながらシーンチェンジを行います。 加減速は簡易的なものなので期待通りの動作をしない場合があります。 |
2012/02/15 |
ワイプ(グラデーション幅、角度指定) | rakka | 標準のワイプ(横、縦)にグラデーション幅、角度を指定できるようにした感じです。(一時保存読込EXTが必要になります。) →説明動画 | 2013/08/20 |
--回転(分割)
@回転(分割)
--track0:回転数,-5,5,1,1
--track1:分割数,1,50,3,1
--dialog:分割角度,div_angle=90;回転の中心[%],rc=0;初期ZOOM,zoom0=100;初期アルファ,alpha0=100;視野角,perse_angle=0;裏面同一方向/chk,same_dir=0;裏表切り替え/chk,card=1;裏表背景画像,filename="";
--[[
・回転数
開始点と終了点で、すこしずらすとちょっと面白いかも
・裏表切り替え
回転時に発生する隙間は裏表背景画像で指定します
空白にした場合は、黒背景になります
回転の中心が0%以外では、純粋な裏表にはなりません
・ファイルを指定する場合は、\ を / に置き換えてください
]]
local t = obj.getvalue("scenechange")
if(t <= 0)then
--古いシーンを描画
obj.draw()
return
elseif(t >= 1)then
--新しいシーンを描画
obj.load("framebuffer")
obj.draw()
return
end
rc = rc / 200 + 0.5
perse_angle = math.max(0, math.min(120, perse_angle))
local zoom = 1 + (zoom0 / 100 - 1) * (1 - t)
local alpha = 1 + (alpha0 / 100 - 1) * (1 - t)
local angle = obj.track0 --floor しない!!
local div = math.floor(obj.track1)
if(card == 1)then
angle = (angle * 2 - 1) * (1 - t) * 180
local angle__ = ((angle % 360) + 360) % 360
if(90 < angle__ and angle__ <= 270)then
angle = angle + 180
rc = 1 - rc
obj.copybuffer("tmp", "obj") --古いシーンが表, 古いシーンを退避
else
obj.copybuffer("tmp", "frm") --新しいシーンが表, 新しいシーンを退避
end
if(not filename or filename == "")then
obj.load("figure", "背景", 0x000000)
else
obj.load("image", filename)
end
obj.draw()
obj.load("tempbuffer") --シーンをロード
else
angle = (angle * 2 - 1) * (1 - t) * 90
if(same_dir == 1)then
local angle__ = ((angle % 360) + 360) % 360
if(90 < angle__ and angle__ <= 270)then
angle = angle + 180
rc = 1 - rc
end
end
obj.copybuffer("tmp", "frm") --新しいシーンを退避
obj.draw() --古いシーンを描画
obj.load("tempbuffer") --新しいシーンをロード
end
local M = {}
M.mt = function(rx, ry, rz)
local sinZ = 0
local cosZ = 1
local sinY = 0
local cosY = 1
local sinX = 0
local cosX = 1
if(rz and rz~=0)then
local rz_ = rz * math.pi / 180
sinZ = math.sin(rz_)
cosZ = math.cos(rz_)
end
if(ry and ry~=0)then
local ry_ = ry * math.pi / 180
sinY = math.sin(ry_)
cosY = math.cos(ry_)
end
if(rx and rx~=0)then
local rx_ = rx * math.pi / 180
sinX = math.sin(rx_)
cosX = math.cos(rx_)
end
local sinYsinX=sinY*sinX
local sinYcosX=sinY*cosX
return {cosZ*cosY, -sinZ*cosY, sinY, sinZ*cosX + cosZ*sinYsinX, cosZ*cosX - sinZ*sinYsinX, -cosY*sinX, sinZ*sinX - cosZ*sinYcosX, cosZ*sinX + sinZ*sinYcosX, cosY*cosX}
end
M.rotate = function(pos, mat)
local x=pos[1]
local y=pos[2]
local z=pos[3] or 0
return {x*mat[1]+y*mat[2]+z*mat[3], x*mat[4]+y*mat[5]+z*mat[6], x*mat[7]+y*mat[8]+z*mat[9]}
end
local function perse(pos, cx, cy, angle)
cx = cx or 0
cy = cy or 0
angle = (angle == 0 and math.deg(math.atan(obj.screen_h * 0.5 / 1024)) * 2) or angle
local x, y, z = unpack(pos)
local f = obj.screen_h * 0.5 / math.tan(math.rad(angle * 0.5))
z = z + f
return {f * (x - cx) / z + cx, f * (y - cy) / z + cy, 0}
end
local w, h = obj.w, obj.h
local w0, h0 = w, h
local mat1 = M.mt(angle, 0, 0)
local mat2 = M.mt(0, 0, div_angle)
local mat3 = M.mt(0, 0, -div_angle)
local points = {
M.rotate({-w / 2, -h / 2, 0}, mat3),
M.rotate({ w / 2, -h / 2, 0}, mat3),
M.rotate({ w / 2, h / 2, 0}, mat3),
M.rotate({-w / 2, h / 2, 0}, mat3)
}
w = math.max(points[1][1], points[2][1], points[3][1], points[4][1]) - math.min(points[1][1], points[2][1], points[3][1], points[4][1])
h = math.max(points[1][2], points[2][2], points[3][2], points[4][2]) - math.min(points[1][2], points[2][2], points[3][2], points[4][2])
local px = h / div
obj.setoption("dst", "tmp", w, h)
obj.draw(0, 0, 0, 1, 1, 0, 0, -div_angle)
obj.load("tempbuffer")
obj.setoption("dst", "frm")
--obj.setoption("culling", culling) --裏面非表示
for i = 1, div do
local u1 = 0
local v1 = px * (i - 1)
local u2 = w
local v2 = v1
local u3 = u2
local v3 = px * i
local u4 = u1
local v4 = v3
local cy = v1 * (1 - rc) + v4 * (rc) - h / 2
local points = { --X回転
M.rotate({u1 - w/2, v1 - h/2 - cy, 0}, mat1),
M.rotate({u2 - w/2, v2 - h/2 - cy, 0}, mat1),
M.rotate({u3 - w/2, v3 - h/2 - cy, 0}, mat1),
M.rotate({u4 - w/2, v4 - h/2 - cy, 0}, mat1)
}
local cx_, cy_ = 0, 0
for i = 1, 4 do
points[i][2] = points[i][2] + cy
points[i] = M.rotate(points[i], mat2) --Z回転
for j = 1, 3 do
points[i][j] = points[i][j] * zoom
end
cx_ = cx_ + points[i][1]
cy_ = cy_ + points[i][2]
end
cx_ = cx_ / 4
cy_ = cy_ / 4
for i = 1, 4 do
points[i] = perse(points[i], cx_, cy_, perse_angle)
end
obj.drawpoly(points[1][1], points[1][2], points[1][3], points[2][1], points[2][2], points[2][3], points[3][1], points[3][2], points[3][3], points[4][1], points[4][2], points[4][3], u1, v1, u2, v2, u3, v3, u4, v4, alpha)
end
ラスター
@ラスター
--track0:高さ,0,1000,100
--track1:加減速,0,2,2,1
--dialog:逆方向/chk,isrev=0;
--check0:縦ラスター,0
t = obj.getvalue("scenechange")
if (obj.track1==0)then
t = t-0.5
else -- 簡易なので完全な加減速ではない
t = t^obj.track1
t = -math.cos(math.rad(t*180))/2
end
if (isrev==0)then
rev = 1
else
rev = -1
end
if (obj.check0) then
x = 0
l = 1
w = obj.h
if (t<0) then
ef = (0.5+t) * w
y = ( ef ) * rev
else
ef = (0.5-t) * w
y = ( w-ef) * rev
end
else
y = 0
l = 0
w = obj.w
if (t<0) then
ef = (0.5+t) * w
x = (-ef ) * rev
else
ef = (0.5-t) * w
x = (-w+ef) * rev
end
end
obj.effect("ラスター",
"横幅", ef, "高さ", obj.track0,
"周期", 0, "縦ラスター", l
)
obj.draw(x,y)
ワイプ(グラデーション幅、角度指定)
@ワイプ(線形)
--track0:グラデ幅,0,1000,100
--track1:角度,-90,90,-90
gradW = obj.track0
deg = obj.track1
rad = math.rad(deg)
cos = math.cos(rad)
sin = math.sin(rad)
local ROT=function(x,y,cos,sin)
return x*cos-y*sin, x*sin+y*cos
end
sw = obj.screen_w
sh = obj.screen_h
sw2 = sw / 2
sh2 = sh / 2
tlX, tlY = ROT(-sw2, -sh2, cos, sin)
trX, trY = ROT(sw2, -sh2, cos, sin)
blX, blY = ROT(-sw2, sh2, cos, sin)
brX, brY = ROT(sw2, sh2, cos, sin)
minY = math.min(tlY, trY, blY, brY)
maxY = math.max(tlY, trY, blY, brY)
len = maxY - minY
tt = obj.getvalue("scenechange")
offsetD = - (len + gradW) / 2 + (len + gradW) * tt
offsetX, offsetY = ROT(0, offsetD, cos, sin)
require("extbuffer")
id1 = extbuffer.freeid()
extbuffer.write(id1) -- obj(シーンチェンジ前の画像)を id1 面にコピー
-- アルファ値として適用するグラデーション画像(角度が-90の場合、左側が黒で、右側が白)を作成
-- 角度が-90の場合、tt=0のとき真っ白で、tt=0.5のとき左半分が黒、右半分が白で、tt=1のとき真っ黒になる。
obj.load("figure","四角形",0xffffff,100)
obj.effect("リサイズ", "X", sw, "Y", sh, "ドット数でサイズ指定", 1)
obj.effect("グラデーション", "中心X", offsetX, "中心Y", offsetY, "角度", deg, "幅", gradW, "color", 0x000000, "color2", 0xffffff)
-- グラデーション画像を userdata にコピー
id2 = extbuffer.freeid()
extbuffer.write(id2)
userdata = extbuffer.read2(id2)
extbuffer.clear(id2)
-- userdata(グラデーション画像)の輝度をアルファ値として id1 面(シーンチェンジ前の画像)に上書き
extbuffer.mix(id1, userdata, sw, sh, "gray_alpha_overwrite")
-- id1 面(シーンチェンジ前の画像)をobjに読み込んで、シーンチェンジ後の画像の上に描画
extbuffer.read(id1)
obj.draw()
extbuffer.clear(id1)
サンプル
@サンプル
--track0:テスト,0,100,40
test
- 最終更新:2013-08-23 11:49:28