/**************************************************************************** Copyright (c) 2011-2013,WebJet Business Division,CYOU http://www.genesis-3d.com.cn Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ using System; using System.Runtime.CompilerServices; using ScriptRuntime; namespace ScriptRuntime { /// /// 图形系统类,包括与图形相关的操作, /// 如相机、视口、材质等 /// public static class GraphicSystem { /// /// 获得当前正在渲染的相机(已过期,请用GetRenderingCamera(),代替) /// /// 相机组件 [System.Obsolete("Please, use fuction GetRenderingCamera() instead.")] public static CameraComponent GetSceneCamera() { return ICall_GraphicSystem_GetSceneCamera(); } /// /// 获得当前正在渲染的相机 /// /// 相机组件 public static CameraComponent GetRenderingCamera() { return ICall_GraphicSystem_GetRenderingCamera(); } /// /// 以相机作为参数,渲染场景 /// /// 摄像机 public static void RenderCamera(Camera cam) { ICall_GraphicSystem_RenderCamera(cam); } /// /// 利用RenderToTexture和缓冲区清理标志位,设置渲染目标 /// /// RenderToTexture,输入参数 /// 渲染目标的缓冲区清理标志位 public static void SetRenderTarget(RenderToTexture target, int index) { ICall_GraphicSystem_SetRenderTarget(target, index); } //public static RenderResourceHandle CreateTexture(String path) //{ // return ICall_GraphicSystem_CreateTexture(path); //} /// /// 获得视口的宽度 /// /// 视口宽度 public static int GetWidth() { return ICall_GraphicSystem_GetWidth(); } /// /// 获得视口的高度 /// /// 视口高度 public static int GetHeight() { return ICall_GraphicSystem_GetHeight(); } /// /// 根据资源ID创建材质实例 /// /// 资源ID /// 返回材质实例 public static MaterialInstance CreateMaterial(String resID) { return ICall_GraphicSystem_CreateMaterial(resID); } /// /// 利用材质实例的特定通道,将指定纹理渲染至目标RenderToTexture /// /// 指定的纹理 /// 目标RenderToTexture /// 材质实例 /// 材质实例的通道 public static void BlitImage(Texture source, RenderToTexture destination, MaterialInstance material, int passIndex) { if (null == source) { ICall_GraphicSystem_BlitImage(IntPtr.Zero, destination, material, passIndex); } else { ICall_GraphicSystem_BlitImage(source.GetTextureHandlePtr(), destination, material, passIndex); } } [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static CameraComponent ICall_GraphicSystem_GetSceneCamera(); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static CameraComponent ICall_GraphicSystem_GetRenderingCamera(); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_GraphicSystem_RenderCamera(Camera render); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_GraphicSystem_SetRenderTarget(RenderToTexture target, int index); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static int ICall_GraphicSystem_GetWidth(); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static int ICall_GraphicSystem_GetHeight(); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static MaterialInstance ICall_GraphicSystem_CreateMaterial(String resID); [MethodImplAttribute(MethodImplOptions.InternalCall)] extern private static void ICall_GraphicSystem_BlitImage(IntPtr textureHandlePtr, RenderToTexture destination, MaterialInstance material, int passIndex); } }