加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
鉴于前一个帖子反响不好……我就再来一个……
---
首先我们需要用某种语言重写RPG Maker自带的脚本和RGSS的基础类……
比如RPG Maker自带脚本用C#写,RGSS的一些图形类用MDX或者XNA或者Monogame或者Cocos-2d for XNA
总之要能够读取RM的数据……
然后用SliverLight包装,把数据渲染到RenderTarget……
同时为了减少服务器负担,必须设立缓存……
我们都知道RPG Maker的脚本里有一个Cache Module,放到C#里以后:
[box=PaleTurquois] 读取一个png
如果png已经缓存
返回png
否则
返回特定的未知贴图
把下载png加入缓存队列
结束[/box]
当然以上过程如果可以吧缓存的内容加密当然更加安全
那么这个SliverLight程序就是公用的脚本……对于一般的RPG游戏应该是应付的过来的
---
关于实现……
如果使用的是XNA的话,渲染到RenderTarget2D中,然后获取贴图,转换成SliverLight的贴图(其实就是拷贝……)
对于VA、VX、XP的小界面640x480,这个过程可以达到60fps……
640(Width)*480(Height)*4(Color,RGBA)*1(Byte Size)*60(Expect FPS)=73728000
可以看做复杂度O(73728000),基本可以……
---
论拷贝
protected Texture2D FillTexture(ref System.Drawing.Bitmap bitmap) { Texture2D tmpTex = new Texture2D(DGE.Graphics.Device, (int)bitmap.Width, (int)bitmap.Height); System.Drawing.Imaging.BitmapData colorMapTex = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Byte[] colorMap = new Byte[tmpTex.Width * tmpTex.Height * 4]; int bound = Math.Abs(colorMapTex.Stride) * colorMapTex.Height; IntPtr ptr = colorMapTex.Scan0; System.Runtime.InteropServices.Marshal.Copy(ptr, colorMap, 0, bound); tmpTex.SetData<Byte>(colorMap); return tmpTex; }
protected Texture2D FillTexture(ref System.Drawing.Bitmap bitmap)
{
Texture2D tmpTex = new Texture2D(DGE.Graphics.Device, (int)bitmap.Width, (int)bitmap.Height);
System.Drawing.Imaging.BitmapData colorMapTex = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Byte[] colorMap = new Byte[tmpTex.Width * tmpTex.Height * 4];
int bound = Math.Abs(colorMapTex.Stride) * colorMapTex.Height;
IntPtr ptr = colorMapTex.Scan0;
System.Runtime.InteropServices.Marshal.Copy(ptr, colorMap, 0, bound);
tmpTex.SetData<Byte>(colorMap);
return tmpTex;
}
---
论转换
GraphicsDevice graphicsDevice = GraphicsDevice; RenderTarget2D rt = new RenderTarget2D(graphicsDevice,640,480); RenderTargetBinding[] old = graphicsDevice.GetRenderTargets(); graphicsDevice.SetRenderTarget(rt); graphicsDevice.Clear(ClearOptions.Target, Color.Transparent, 0, 0); SpriteBatch spriteBatch = new SpriteBatch(graphicsDevice); spriteBatch.Begin(); //Do Sth... spriteBatch.End(); spriteBatch.Dispose(); graphicsDevice.SetRenderTargets(old); graphicsDevice.Clear(Color.Transparent); RenderTargetBinding binding = new RenderTargetBinding(rt); return binding.RenderTarget as Texture2D;
GraphicsDevice graphicsDevice = GraphicsDevice;
RenderTarget2D rt = new RenderTarget2D(graphicsDevice,640,480);
RenderTargetBinding[] old = graphicsDevice.GetRenderTargets();
graphicsDevice.SetRenderTarget(rt);
graphicsDevice.Clear(ClearOptions.Target, Color.Transparent, 0, 0);
SpriteBatch spriteBatch = new SpriteBatch(graphicsDevice);
spriteBatch.Begin();
//Do Sth...
spriteBatch.End();
spriteBatch.Dispose();
graphicsDevice.SetRenderTargets(old);
graphicsDevice.Clear(Color.Transparent);
RenderTargetBinding binding = new RenderTargetBinding(rt);
return binding.RenderTarget as Texture2D;
---
额呵呵…… |