设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 20898|回复: 33
打印 上一主题 下一主题

[RMVX发布] RMVX 动画数据库 -> XP 动画数据库

 关闭 [复制链接]

Lv1.梦旅人

66RPG站长

梦石
0
星屑
54
在线时间
615 小时
注册时间
2005-10-10
帖子
5734

RMVX自由创作大赛亚军第2届短篇游戏比赛亚军第5届短篇游戏比赛冠军

跳转到指定楼层
1
发表于 2008-1-16 07:24:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
VX的动画数据库还是很华丽的,一流华丽,这里提供一个转给XP用户使用的方法。这个算法简单说就是,由于VX使用两张图来制作动画素材,而XP只能用一张,所以我在运算的时候直接把两张图合成为一张图了。此外编号也重调过。如果本来VX两张图的色相有较大诧异可能会转换结果不完美,不过好在默认数据库没有这种情况,就暂时不考虑了。

注,XP转VX的在这里:http://rpg.blue/viewthread.php?tid=72045

我想其他数据库应该没有互转的必要了。应该说,其他的数据库表VX都远胜XP,只要eval(.memo)就可以了。所以我也不转了,有需要时候再说了。

使用方法:

1、在VX完整版中执行脚本段落1,这个过程很慢,大约10多分钟,并且这个过程中必须让窗口焦点保持在运行窗口上,建议吃饭前执行(生成图片速度很慢)。

2、在XP新建一个工程,把刚才生成的vx_ani.6R考到game.exe所在位置,把所有素材图考到Graphics/Animations,再去VX的RTP安装目录把所有声效考过来。

3、在XP工程中执行脚本段落2,瞬间完成。关闭XP工程,重新打开,则所有VX动画可以使用了。

脚本段落1、
  1. # 将bitmap对象输出成bmp文件 By MOMOMO
  2. # 翻译:bbschat 来自:www.66rpg.com
  3. # 将Bitmap对象
  4. # 转换成位图文件(24bit)输出。
  5. #
  6. # Bmp_File.make_bmp_file(bitmap, name[, path])
  7. # bitmap:Bitmap对象
  8. # name:保存文件名
  9. # path:保存路径
  10. #
  11. # 或者,对Bitmap对象直接使用
  12. # bitmap_obj.make_bmp_file(name[, path])
  13. # 也可以达成同样的机能。


  14. module Bmp_File
  15. module_function
  16. # 生成BMP文件
  17. def make_bmp_file(bitmap, name, path="")
  18.   file_header = make_bmp_file_header(bitmap)
  19.   info_header = make_bmp_info_header(bitmap)
  20.   bitmap_data = make_bitmap_data(bitmap)
  21.   make_dir(path) if path != ""
  22.   file = File.open(path + name + ".bmp", "wb")
  23.   file.write(file_header)
  24.   file.write(info_header)
  25.   file.write(bitmap_data)
  26.   file.close
  27. end
  28. # 生成保存路径
  29. def make_dir(path)
  30.   dir = path.split("/")
  31.   for i in 0...dir.size
  32.     unless dir == "."
  33.       add_dir = dir[0..i].join("/")
  34.       begin
  35.         Dir.mkdir(add_dir)
  36.       rescue
  37.       end
  38.     end
  39.   end
  40. end
  41. # 从Bitmap对象中生成文件头
  42. def make_bmp_file_header(bitmap)
  43.   bf_type = ["BM"].pack("a2")
  44.   bf_size = [get_bf_size(bitmap)].pack("L")
  45.   bf_Reserved1 = [0].pack("S")
  46.   bf_Reserved2 = [0].pack("S")
  47.   bf_OffBits = [54].pack("L")
  48.   
  49.   file_header = bf_type + bf_size + bf_Reserved1 + bf_Reserved2 + bf_OffBits
  50.   return file_header
  51. end
  52. # 从Bitmap对象中生成情报头
  53. def make_bmp_info_header(bitmap)
  54.   bi_size = [40].pack("L")
  55.   bi_width = [get_bi_width(bitmap)].pack("L")
  56.   bi_height = [get_bi_height(bitmap)].pack("L")
  57.   bi_planes = [1].pack("S")
  58.   bi_bitcount = [24].pack("S")
  59.   bi_copmression = [0].pack("L")
  60.   bi_sizeimage = [0].pack("L")
  61.   bi_x_pixpermeter = [0].pack("L")
  62.   bi_y_pixpermeter = [0].pack("L")
  63.   bi_clrused = [0].pack("L")
  64.   bi_cirimportant = [0].pack("L")
  65.   
  66.   info_header = bi_size + bi_width + bi_height + bi_planes + bi_bitcount +
  67.                 bi_copmression + bi_sizeimage + bi_x_pixpermeter +
  68.                 bi_y_pixpermeter + bi_clrused + bi_cirimportant
  69.   
  70.   return info_header
  71. end
  72. # 从Bitmap对象中生成图像数据
  73. def make_bitmap_data(bitmap)
  74.   w = bitmap.width
  75.   h = bitmap.height
  76.   w = (w / 4 + 1) * 4 if w % 4 != 0
  77.   data = []
  78.   for y in 0...h
  79.     for x in 0...w
  80.       color = bitmap.get_pixel(x, (h - 1) - y)
  81.       data.push(color.blue)
  82.       data.push(color.green)
  83.       data.push(color.red)
  84.     end
  85.   end
  86.   return data.pack("C*")
  87. end
  88. def get_bf_size(bitmap)
  89.   w = bitmap.width
  90.   w = (w / 4 + 1) * 4 if w % 4 != 0
  91.   h = bitmap.height
  92.   return w * h * 3
  93. end
  94. def get_bi_width(bitmap)
  95.   return bitmap.width
  96. end
  97. def get_bi_height(bitmap)
  98.   return bitmap.height
  99. end
  100. end
  101. class Bitmap
  102. def make_bmp_file(name, path="")
  103.   Bmp_File.make_bmp_file(self, name, path)
  104. end
  105. end
  106. #==============================================================================
  107. #               本脚本出自www.66rpg.com,转载请注明。
  108. #==============================================================================
  109. =begin
  110. ==============================================================================
  111.                         Bitmap to PNG By 轮回者
  112. ==============================================================================

  113. 对Bitmap对象直接使用

  114. bitmap_obj.make_png(name[, path])

  115. name:保存文件名
  116. path:保存路径

  117. 感谢66、夏娜、金圭子的提醒和帮助!
  118.    
  119. ==============================================================================
  120. =end

  121. module Zlib
  122.   class Png_File < GzipWriter
  123.     #--------------------------------------------------------------------------
  124.     # ● 主处理
  125.     #--------------------------------------------------------------------------
  126.     def make_png(bitmap_Fx,mode)
  127.       @mode = mode
  128.       @bitmap_Fx = bitmap_Fx
  129.       self.write(make_header)
  130.       self.write(make_ihdr)
  131.       self.write(make_idat)
  132.       self.write(make_iend)
  133.     end
  134.     #--------------------------------------------------------------------------
  135.     # ● PNG文件头数据块
  136.     #--------------------------------------------------------------------------
  137.     def make_header
  138.       return [0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a].pack("C*")
  139.     end
  140.     #--------------------------------------------------------------------------
  141.     # ● PNG文件情报头数据块(IHDR)
  142.     #--------------------------------------------------------------------------
  143.     def make_ihdr
  144.       ih_size = [13].pack("N")
  145.       ih_sign = "IHDR"
  146.       ih_width = [@bitmap_Fx.width].pack("N")
  147.       ih_height = [@bitmap_Fx.height].pack("N")
  148.       ih_bit_depth = [8].pack("C")
  149.       ih_color_type = [6].pack("C")
  150.       ih_compression_method = [0].pack("C")
  151.       ih_filter_method = [0].pack("C")
  152.       ih_interlace_method = [0].pack("C")
  153.       string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
  154.                ih_compression_method + ih_filter_method + ih_interlace_method
  155.       ih_crc = [Zlib.crc32(string)].pack("N")
  156.       return ih_size + string + ih_crc
  157.     end
  158.     #--------------------------------------------------------------------------
  159.     # ● 生成图像数据(IDAT)
  160.     #--------------------------------------------------------------------------
  161.     def make_idat
  162.       header = "\x49\x44\x41\x54"
  163.       case @mode # 请54~
  164.       when 1
  165.         data = make_bitmap_data#1
  166.       else
  167.         data = make_bitmap_data
  168.       end
  169.       data = Zlib::Deflate.deflate(data, 8)
  170.       crc = [Zlib.crc32(header + data)].pack("N")
  171.       size = [data.length].pack("N")
  172.       return size + header + data + crc
  173.     end
  174.     #--------------------------------------------------------------------------
  175.     # ● 从Bitmap对象中生成图像数据 mode 1(请54~)
  176.     #--------------------------------------------------------------------------
  177.     def make_bitmap_data1
  178.       w = @bitmap_Fx.width
  179.       h = @bitmap_Fx.height
  180.       data = []
  181.       for y in 0...h
  182.         data.push(0)
  183.         for x in 0...w
  184.           color = @bitmap_Fx.get_pixel(x, y)
  185.           red = color.red
  186.           green = color.green
  187.           blue = color.blue
  188.           alpha = color.alpha
  189.           data.push(red)
  190.           data.push(green)
  191.           data.push(blue)
  192.           data.push(alpha)
  193.         end
  194.       end
  195.       return data.pack("C*")
  196.     end
  197.     #--------------------------------------------------------------------------
  198.     # ● 从Bitmap对象中生成图像数据 mode 0
  199.     #--------------------------------------------------------------------------
  200.     def make_bitmap_data
  201.       gz = Zlib::GzipWriter.open('hoge.gz')
  202.       t_Fx = 0
  203.       w = @bitmap_Fx.width
  204.       h = @bitmap_Fx.height
  205.       data = []
  206.       for y in 0...h
  207.         data.push(0)
  208.         for x in 0...w
  209.           t_Fx += 1
  210.           if t_Fx % 10000 == 0
  211.             Graphics.update
  212.           end
  213.           if t_Fx % 100000 == 0
  214.             s = data.pack("C*")
  215.             gz.write(s)
  216.             data.clear
  217.             #GC.start
  218.           end
  219.           color = @bitmap_Fx.get_pixel(x, y)
  220.           red = color.red
  221.           green = color.green
  222.           blue = color.blue
  223.           alpha = color.alpha
  224.           data.push(red)
  225.           data.push(green)
  226.           data.push(blue)
  227.           data.push(alpha)
  228.         end
  229.       end
  230.       s = data.pack("C*")
  231.       gz.write(s)
  232.       gz.close   
  233.       data.clear
  234.       gz = Zlib::GzipReader.open('hoge.gz')
  235.       data = gz.read
  236.       gz.close
  237.       File.delete('hoge.gz')
  238.       return data
  239.     end
  240.     #--------------------------------------------------------------------------
  241.     # ● PNG文件尾数据块(IEND)
  242.     #--------------------------------------------------------------------------
  243.     def make_iend
  244.       ie_size = [0].pack("N")
  245.       ie_sign = "IEND"
  246.       ie_crc = [Zlib.crc32(ie_sign)].pack("N")
  247.       return ie_size + ie_sign + ie_crc
  248.     end
  249.   end
  250. end
  251. #==============================================================================
  252. # ■ Bitmap
  253. #------------------------------------------------------------------------------
  254. #  关联到Bitmap。
  255. #==============================================================================
  256. class Bitmap
  257.   #--------------------------------------------------------------------------
  258.   # ● 关联
  259.   #--------------------------------------------------------------------------
  260.   def make_png(name="like", path="",mode=0)
  261.     make_dir(path) if path != ""
  262.     Zlib::Png_File.open("temp.gz") {|gz|
  263.       gz.make_png(self,mode)
  264.     }
  265.     Zlib::GzipReader.open("temp.gz") {|gz|
  266.       $read = gz.read
  267.     }
  268.     f = File.open(path + name + ".png","wb")
  269.     f.write($read)
  270.     f.close
  271.     File.delete('temp.gz')
  272.     end
  273.   #--------------------------------------------------------------------------
  274.   # ● 生成保存路径
  275.   #--------------------------------------------------------------------------
  276.   def make_dir(path)
  277.     dir = path.split("/")
  278.     for i in 0...dir.size
  279.       unless dir == "."
  280.         add_dir = dir[0..i].join("/")
  281.         begin
  282.           Dir.mkdir(add_dir)
  283.         rescue
  284.         end
  285.       end
  286.     end
  287.   end
  288. end
  289. #==============================================================================
  290. #               本脚本出自www.66rpg.com,转载请注明。
  291. #==============================================================================
  292. module RPG
  293.   class Animation2
  294.     def initialize
  295.       @id = 0
  296.       @name = ""
  297.       @animation1_name = ""
  298.       @animation1_hue = 0
  299.       @animation2_name = ""
  300.       @animation2_hue = 0
  301.       @position = 1
  302.       @frame_max = 1
  303.       @frames = [RPG::Animation::Frame.new]
  304.       @timings = []
  305.     end
  306.     attr_accessor :id
  307.     attr_accessor :name
  308.     attr_accessor :animation_name
  309.     attr_accessor :animation_hue
  310.     attr_accessor :position
  311.     attr_accessor :frame_max
  312.     attr_accessor :frames
  313.     attr_accessor :timings                 
  314.   end
  315. end

  316. module RPG
  317.   class Animation2
  318.     class Timing
  319.       def initialize
  320.         @frame = 0
  321.         @se = RPG::SE.new("", 80)
  322.         @se_name = ""
  323.         @se_volume = 80
  324.         @se_pitch = 100
  325.         @flash_scope = 0
  326.         @flash_color = Color.new(255,255,255,255)
  327.         @flash_duration = 5
  328.       end
  329.       attr_accessor :frame
  330.       attr_accessor :se
  331.       attr_accessor :se_name
  332.       attr_accessor :se_volume
  333.       attr_accessor :se_pitch
  334.       attr_accessor :flash_scope
  335.       attr_accessor :flash_color
  336.       attr_accessor :flash_duration
  337.     end
  338.   end
  339. end

  340. $data_animations    = load_data("Data/Animations.rvdata")
  341. $vx_ani = []

  342. $sprite = Sprite.new
  343. $sprite.bitmap = Bitmap.new(500, 400)
  344. number = 1
  345. for ani in $data_animations
  346.   number += 1
  347.   next if ani==nil
  348.   $sprite.bitmap.clear
  349.   $sprite.bitmap.draw_text(0, 0, 500, 400, number.to_s + " / " + $data_animations.size.to_s, 1)
  350.   tani = RPG::Animation2.new
  351.   tani.id = ani.id
  352.   tani.name = ani.name
  353.   tani.animation_name = ani.animation1_name+"66RPG"+ani.animation2_name
  354.   tani.animation_hue = ani.animation1_hue
  355.   width = 960
  356.   bmp1 = Cache.animation(ani.animation1_name, ani.animation1_hue)
  357.   bmp2 = Cache.animation(ani.animation2_name, ani.animation2_hue)
  358.   height = bmp1.height + bmp2.height
  359.   bmp = Bitmap.new(width, height)
  360.   bmp.blt(0, 0, bmp1, bmp1.rect)
  361.   bmp.blt(0, bmp1.height, bmp2, bmp2.rect)
  362.   bmp.make_png(ani.animation1_name+"66RPG"+ani.animation2_name)
  363.   tani.position = ani.position
  364.   tani.frame_max = ani.frame_max
  365.   tani.frames = ani.frames
  366.   for i in 0..15
  367.     for fram in tani.frames
  368.       fram.cell_data[i, 0] -= (100 - bmp1.height * 5/ 192) if fram.cell_data[i, 0] != nil and fram.cell_data[i, 0] > 100
  369.     end
  370.   end
  371.   tani.timings = []
  372.   for timing in ani.timings
  373.     tm = RPG::Animation2::Timing.new
  374.     tm.frame = timing.frame
  375.     tm.se_name = timing.se.name
  376.     tm.se_volume = timing.se.volume
  377.     tm.se_pitch = timing.se.pitch
  378.     tm.flash_scope = timing.flash_scope
  379.     tm.flash_color = timing.flash_color
  380.     tm.flash_duration = timing.flash_duration
  381.     tani.timings.push(tm)
  382.   end
  383.   $vx_ani.push(tani)
  384. end

  385. save_data($vx_ani, "vx_ani.6R")
  386. p "done"
复制代码


脚本段落2:
  1. module RPG
  2.   class Animation2
  3.     def initialize
  4.       @id = 0
  5.       @name = ""
  6.       @animation1_name = ""
  7.       @animation1_hue = 0
  8.       @animation2_name = ""
  9.       @animation2_hue = 0
  10.       @position = 1
  11.       @frame_max = 1
  12.       @frames = [RPG::Animation::Frame.new]
  13.       @timings = []
  14.     end
  15.     attr_accessor :id
  16.     attr_accessor :name
  17.     attr_accessor :animation_name
  18.     attr_accessor :animation_hue
  19.     attr_accessor :position
  20.     attr_accessor :frame_max
  21.     attr_accessor :frames
  22.     attr_accessor :timings                 
  23.   end
  24. end


  25. module RPG
  26.   class SE
  27.     def initialize(i1, i2)
  28.       @i1 = i1
  29.       @i2 = i2
  30.     end
  31.   end
  32. end


  33. module RPG
  34.   class Animation2
  35.     class Timing
  36.       def initialize
  37.         @frame = 0
  38.         @se = RPG::SE.new("", 80)
  39.         @se_name = ""
  40.         @se_volume = 80
  41.         @se_pitch = 100
  42.         @flash_scope = 0
  43.         @flash_color = Color.new(255,255,255,255)
  44.         @flash_duration = 5
  45.       end
  46.       attr_accessor :frame
  47.       attr_accessor :se
  48.       attr_accessor :se_name
  49.       attr_accessor :se_volume
  50.       attr_accessor :se_pitch
  51.       attr_accessor :flash_scope
  52.       attr_accessor :flash_color
  53.       attr_accessor :flash_duration
  54.     end
  55.   end
  56. end

  57. $data_animations    = load_data("Data/Animations.rxdata")
  58. $ani    = load_data("vx_ani.6R")

  59. for ani in $ani
  60.   tani = RPG::Animation.new
  61.   tani.id = ani.id
  62.   tani.name = ani.name
  63.   tani.animation_name = ani.animation_name
  64.   tani.animation_hue = ani.animation_hue
  65.   tani.position = ani.position
  66.   tani.frame_max = ani.frame_max
  67.   tani.frames = ani.frames
  68.   tani.timings = []
  69.   for timing in ani.timings
  70.     tm = RPG::Animation::Timing.new
  71.     tm.frame = timing.frame
  72.     tm.se = RPG::AudioFile.new(timing.se_name, timing.se_volume, timing.se_pitch)
  73.     tm.flash_scope = timing.flash_scope
  74.     tm.flash_color = timing.flash_color
  75.     tm.flash_duration = timing.flash_duration
  76.     tani.timings.push(tm)
  77.   end
  78.   $data_animations.push(tani)
  79. end

  80. save_data($data_animations, "Data/Animations.rxdata")
  81. p "done"
复制代码


              [本贴由 御灵 于 2008-1-17 23:44:17 进行了编辑]

Lv1.梦旅人

66RPG站长

梦石
0
星屑
54
在线时间
615 小时
注册时间
2005-10-10
帖子
5734

RMVX自由创作大赛亚军第2届短篇游戏比赛亚军第5届短篇游戏比赛冠军

2
 楼主| 发表于 2008-1-16 07:29:34 | 只看该作者
回复 支持 反对

使用道具 举报

Lv1.梦旅人

风雪夜不归人

梦石
0
星屑
50
在线时间
276 小时
注册时间
2006-3-7
帖子
6721

贵宾

3
发表于 2008-1-16 07:56:41 | 只看该作者
期待个,VX和XP都是好兄弟啊。有素材同用~~~~
有些人,到了七八月份就会诈尸。
宫斗,是女生永远的爱。
冷门,是本人不变的欲。
作弊,是玩家自由的痛。
练级,是橙光割舍的情。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
142
在线时间
264 小时
注册时间
2006-11-22
帖子
1057
4
发表于 2008-1-17 03:27:12 | 只看该作者
很好很強大
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
0 小时
注册时间
2007-8-10
帖子
399
5
发表于 2008-1-18 23:52:24 | 只看该作者
8分钟完成,感谢柳大~~~
话说我这台笔记本运行VX居然稳定在60fps,啊啊啊,太有爱了~~~{/tp}
少跟我装神秘,你当你是夜神月?
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
0 小时
注册时间
2008-1-6
帖子
573
6
发表于 2008-1-18 23:54:30 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
0 小时
注册时间
2007-12-16
帖子
171
7
发表于 2008-1-19 02:21:11 | 只看该作者
很好很强大,可就是我看不见...
2年多了   第一次来这还是初中的时候  现在却已经在上班了。。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

龙皇

梦石
0
星屑
50
在线时间
83 小时
注册时间
2007-8-8
帖子
2956
8
发表于 2008-1-20 06:14:13 | 只看该作者
                              该发言已自我屏蔽!


                签名图来自:無限のファンタジア
                 我的RMXP专题空间--龙使传说
回复 支持 反对

使用道具 举报

Lv3.寻梦者 (暗夜天使)

精灵族の天使

梦石
0
星屑
1697
在线时间
3038 小时
注册时间
2007-3-16
帖子
33731

开拓者贵宾

9
发表于 2008-1-20 18:22:40 | 只看该作者
太有用了……这样我的素材就会更加华丽的多了。……
p.s.我把以前的默认vx的rtp的动画素材直接拷贝进animationa里面,发现里面也居然可以拼……感动……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

鬼神

梦石
0
星屑
55
在线时间
23 小时
注册时间
2007-12-24
帖子
498
10
发表于 2008-2-8 22:41:18 | 只看该作者
以下引用柳柳于2008-1-15 23:24:35的发言:

本帖需要VIP点 29 才能浏览!

- -
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-19 14:48

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表