CN107913519B - 2D game rendering method and mobile terminal - Google Patents
2D game rendering method and mobile terminal Download PDFInfo
- Publication number
- CN107913519B CN107913519B CN201710754745.0A CN201710754745A CN107913519B CN 107913519 B CN107913519 B CN 107913519B CN 201710754745 A CN201710754745 A CN 201710754745A CN 107913519 B CN107913519 B CN 107913519B
- Authority
- CN
- China
- Prior art keywords
- game
- rendering
- game screen
- library
- game picture
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Classifications
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F13/00—Video games, i.e. games using an electronically generated display having two or more dimensions
- A63F13/50—Controlling the output signals based on the game progress
- A63F13/52—Controlling the output signals based on the game progress involving aspects of the displayed game scene
-
- A—HUMAN NECESSITIES
- A63—SPORTS; GAMES; AMUSEMENTS
- A63F—CARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
- A63F2300/00—Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
- A63F2300/60—Methods for processing data by generating or executing the game program
- A63F2300/66—Methods for processing data by generating or executing the game program for rendering three dimensional images
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Processing Or Creating Images (AREA)
Abstract
本发明公开了一种2D游戏的渲染方法,所述方法包括:获取2D游戏画面数据,分析2D游戏画面元件的初始坐标;基于所述初始坐标构建所述2D游戏画面元件的实际坐标系;基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中;接收2D游戏的运行指令;及根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。本发明还提供一种移动终端及计算机可读存储介质。本发明提供的移动终端、2D游戏的渲染方法及计算机可读存储介质通过采用游戏画面由2D向3D映射的方式,开启GPU渲染,能够迅速提升游戏的渲染速度。
The invention discloses a 2D game rendering method. The method includes: acquiring 2D game screen data, analyzing the initial coordinates of the 2D game screen elements; constructing the actual coordinate system of the 2D game screen elements based on the initial coordinates; In the actual coordinate system, the 2D game screen is mapped into a 3D game screen, and the data of the mapped 3D game screen is cached in a buffer; an operation instruction of the 2D game is received; and the buffer is called according to the operation instruction The data of the 3D game screen in the 3D game screen triggers the 3D game screen rendering mechanism. The present invention also provides a mobile terminal and a computer-readable storage medium. The mobile terminal, 2D game rendering method and computer-readable storage medium provided by the present invention can rapidly improve the rendering speed of the game by enabling GPU rendering by using the method of mapping game images from 2D to 3D.
Description
技术领域technical field
本发明涉及通信技术领域,尤其涉及一种2D游戏的渲染方法及移动终端。The present invention relates to the technical field of communication, in particular to a rendering method of 2D games and a mobile terminal.
背景技术Background technique
随着移动终端的逐步普及,在移动终端进行游戏娱乐已经成为了一种趋势。目前在游戏的运营活动中的游戏引擎主要使用的是HTML5的canvas(尤其是2D游戏),但是canvas对硬件平台的要求比较高,所以在手机这种移动终端上的渲染速度非常慢,很难达到在电脑上使用时的帧率,进而非常影响用户的体验,进而限制了移动终端上游戏产业的发展。With the gradual popularization of mobile terminals, playing games and entertainment on mobile terminals has become a trend. At present, the game engine in the game operation activities mainly uses HTML5 canvas (especially 2D games), but the canvas has relatively high requirements on the hardware platform, so the rendering speed on mobile terminals such as mobile phones is very slow, and it is difficult to Reaching the frame rate when used on a computer greatly affects the user experience, thereby limiting the development of the game industry on mobile terminals.
发明内容Contents of the invention
有鉴于此,本发明提出一种2D游戏的渲染方法及移动终端,能够通过采用游戏画面由2D向3D映射的方式,开启GPU渲染,能够迅速提升游戏的渲染速度。In view of this, the present invention proposes a 2D game rendering method and a mobile terminal, which can enable GPU rendering by adopting the method of mapping the game screen from 2D to 3D, and can rapidly increase the rendering speed of the game.
首先,为实现上述目的,本发明提出一种移动终端,所述移动终端包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的2D游戏的渲染程序,所述2D游戏的渲染程序被所述处理器执行时实现如下步骤:First, in order to achieve the above object, the present invention proposes a mobile terminal, which includes a memory, a processor, and a rendering program of a 2D game stored on the memory and operable on the processor. When the rendering program of the game is executed by the processor, the following steps are implemented:
获取2D游戏画面数据,分析2D游戏画面元件的初始坐标;Obtain 2D game screen data and analyze the initial coordinates of 2D game screen components;
基于所述初始坐标构建所述2D游戏画面元件的实际坐标系;Constructing an actual coordinate system of the 2D game screen element based on the initial coordinates;
基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中;Mapping the 2D game screen into a 3D game screen based on the actual coordinate system, and buffering the data of the mapped 3D game screen into a buffer;
接收2D游戏的运行指令;及Receive running commands for 2D games; and
根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。According to the operation instruction, the data of the 3D game picture in the buffer is called, and the rendering mechanism of the 3D game picture is triggered.
可选地,所述基于所述初始坐标构建所述2D游戏画面元件的实际坐标系的步骤,具体包括:Optionally, the step of constructing the actual coordinate system of the 2D game screen element based on the initial coordinates specifically includes:
构建CSS库,所述CSS库包括至少一个转换标签;constructing a CSS library, the CSS library including at least one conversion tag;
构建JS库;及Build JS libraries; and
基于所述初始坐标,根据所述CSS库的转换标签以及所述JS库构建所述2D游戏画面元件的实际坐标系。Based on the initial coordinates, the actual coordinate system of the 2D game screen element is constructed according to the conversion tag of the CSS library and the JS library.
可选地,所述2D游戏的渲染程序被所述处理器执行时还实现如下步骤:Optionally, when the rendering program of the 2D game is executed by the processor, the following steps are also implemented:
调取图形处理单元(GPU)对所述3D游戏画面进行渲染;及calling a graphics processing unit (GPU) to render the 3D game screen; and
控制所述移动终端的显示屏幕实时显示渲染后的3D游戏画面。The display screen of the mobile terminal is controlled to display the rendered 3D game picture in real time.
可选地,所述调取图形处理单元(GPU)对所述3D游戏画面进行渲染的步骤,具体包括:对所述3D游戏画面进行顶点处理、光栅化计算、纹理帖图及像素处理。Optionally, the step of invoking a graphics processing unit (GPU) to render the 3D game screen specifically includes: performing vertex processing, rasterization calculation, texture mapping and pixel processing on the 3D game screen.
此外,为实现上述目的,本发明还提供一种2D游戏的渲染方法,该方法应用于移动终端,所述方法包括:In addition, in order to achieve the above object, the present invention also provides a 2D game rendering method, which is applied to a mobile terminal, and the method includes:
获取2D游戏画面数据,分析2D游戏画面元件的初始坐标;Obtain 2D game screen data and analyze the initial coordinates of 2D game screen components;
基于所述初始坐标构建所述2D游戏画面元件的实际坐标系;Constructing an actual coordinate system of the 2D game screen element based on the initial coordinates;
基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中;Mapping the 2D game screen into a 3D game screen based on the actual coordinate system, and buffering the data of the mapped 3D game screen into a buffer;
接收2D游戏的运行指令;及Receive running commands for 2D games; and
根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。According to the operation instruction, the data of the 3D game picture in the buffer is called, and the rendering mechanism of the 3D game picture is triggered.
可选地,所述基于所述初始坐标构建所述2D游戏画面元件的实际坐标系的步骤,具体包括:Optionally, the step of constructing the actual coordinate system of the 2D game screen element based on the initial coordinates specifically includes:
构建CSS库,所述CSS库包括至少一个转换标签;constructing a CSS library, the CSS library including at least one conversion tag;
构建JS库;及Build JS libraries; and
基于所述初始坐标,根据所述CSS库的转换标签以及所述JS库构建所述2D游戏画面元件的实际坐标系。Based on the initial coordinates, the actual coordinate system of the 2D game screen element is constructed according to the conversion tag of the CSS library and the JS library.
可选地,所述方法还包括:Optionally, the method also includes:
调取图形处理单元(GPU)对所述3D游戏画面进行渲染;及calling a graphics processing unit (GPU) to render the 3D game screen; and
控制所述移动终端的显示屏幕实时显示渲染后的3D游戏画面。The display screen of the mobile terminal is controlled to display the rendered 3D game picture in real time.
可选地,所述调取图形处理单元(GPU)对所述3D游戏画面进行渲染的步骤,具体包括:对所述3D游戏画面进行顶点处理、光栅化计算、纹理帖图及像素处理。Optionally, the step of invoking a graphics processing unit (GPU) to render the 3D game screen specifically includes: performing vertex processing, rasterization calculation, texture mapping and pixel processing on the 3D game screen.
可选地,所述移动终端包括至少两个不同位置的麦克风装置,所述方法还包括:Optionally, the mobile terminal includes at least two microphone devices in different positions, and the method further includes:
根据所述麦克风装置空间位置的变化,相应的改变各个麦克风装置的声音;及According to the change of the spatial position of the microphone device, correspondingly change the sound of each microphone device; and
在对所述3D游戏画面进行渲染的过程中,将调整后的麦克风的声音与渲染后的3D游戏画面进行同步。In the process of rendering the 3D game picture, the adjusted sound of the microphone is synchronized with the rendered 3D game picture.
进一步地,为实现上述目的,本发明还提供一种计算机可读存储介质,所述计算机可读存储介质存储有2D游戏的渲染程序,所述2D游戏的渲染程序可被至少一个处理器执行,以使所述至少一个处理器执行如上述的2D游戏的渲染方法的步骤。Further, in order to achieve the above object, the present invention also provides a computer-readable storage medium, the computer-readable storage medium stores a 2D game rendering program, and the 2D game rendering program can be executed by at least one processor, To make the at least one processor execute the steps of the above-mentioned 2D game rendering method.
相较于现有技术,本发明所提出的移动终端、2D游戏的渲染方法及计算机可读存储介质,首先,获取2D游戏画面数据,分析2D游戏画面元件的初始坐标;然后,基于所述初始坐标构建所述2D游戏画面元件的实际坐标系;接着,基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中;以及,接收2D游戏的运行指令;最后,根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。这样,能够通过采用游戏画面由2D向3D映射的方式,开启GPU渲染,能够迅速提升游戏的渲染速度。Compared with the prior art, the mobile terminal, 2D game rendering method and computer-readable storage medium proposed by the present invention, firstly, acquire 2D game screen data, and analyze the initial coordinates of 2D game screen elements; then, based on the initial Coordinate constructing the actual coordinate system of the 2D game screen element; then, based on the actual coordinate system, map the 2D game screen into a 3D game screen, and cache the data of the mapped 3D game screen into the buffer; and, receiving A 2D game running instruction; finally, according to the running instruction, the data of the 3D game screen in the buffer is called to trigger the rendering mechanism of the 3D game screen. In this way, GPU rendering can be enabled by using the method of mapping the game screen from 2D to 3D, which can quickly increase the rendering speed of the game.
附图说明Description of drawings
图1是实现本发明各个实施例的一种移动终端的硬件结构示意图;FIG. 1 is a schematic diagram of a hardware structure of a mobile terminal implementing various embodiments of the present invention;
图2是本发明实施例提供的一种通信网络系统架构图;FIG. 2 is a system architecture diagram of a communication network provided by an embodiment of the present invention;
图3是本发明2D游戏的渲染程序第一及第二实施例的程序模块图;3 is a program module diagram of the first and second embodiments of the rendering program of the 2D game of the present invention;
图4是本发明2D游戏的渲染程序第三实施例的程序模块图;4 is a program module diagram of the third embodiment of the rendering program of the 2D game of the present invention;
图5为本发明2D游戏的渲染程序第四实施例的程序模块图;5 is a program module diagram of the fourth embodiment of the rendering program of the 2D game of the present invention;
图6为本发明2D游戏的渲染方法第一实施例的流程图;6 is a flow chart of the first embodiment of the rendering method of the 2D game of the present invention;
图7为本发明2D游戏的渲染方法第二实施例的流程图;7 is a flow chart of the second embodiment of the rendering method of the 2D game of the present invention;
图8为本发明2D游戏的渲染方法第三实施例的流程图;FIG. 8 is a flow chart of the third embodiment of the rendering method of the 2D game of the present invention;
图9为本发明2D游戏的渲染方法第四实施例的流程图。FIG. 9 is a flow chart of a fourth embodiment of a rendering method for a 2D game according to the present invention.
本发明目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization of the purpose of the present invention, functional characteristics and advantages will be further described in conjunction with the embodiments and with reference to the accompanying drawings.
具体实施方式Detailed ways
应当理解,此处所描述的具体实施例仅用以解释本发明,并不用于限定本发明。It should be understood that the specific embodiments described here are only used to explain the present invention, not to limit the present invention.
在后续的描述中,使用用于表示元件的诸如“模块”、“部件”或“单元”的后缀仅为了有利于本发明的说明,其本身没有特定的意义。因此,“模块”、“部件”或“单元”可以混合地使用。In the following description, use of suffixes such as 'module', 'part' or 'unit' for denoting elements is only for facilitating description of the present invention and has no specific meaning by itself. Therefore, 'module', 'part' or 'unit' may be used in combination.
终端可以以各种形式来实施。例如,本发明中描述的终端可以包括诸如手机、平板电脑、笔记本电脑、掌上电脑、个人数字助理(Personal Digital Assistant,PDA)、便捷式媒体播放器(Portable Media Player,PMP)、导航装置、可穿戴设备、智能手环、计步器等移动终端,以及诸如数字TV、台式计算机等固定终端。Terminals may be implemented in various forms. For example, the terminals described in the present invention may include mobile phones, tablet computers, notebook computers, palmtop computers, personal digital assistants (Personal Digital Assistant, PDA), portable media players (Portable Media Player, PMP), navigation devices, portable Mobile terminals such as wearable devices, smart bracelets, and pedometers, and fixed terminals such as digital TVs and desktop computers.
后续描述中将以移动终端为例进行说明,本领域技术人员将理解的是,除了特别用于移动目的的元件之外,根据本发明的实施方式的构造也能够应用于固定类型的终端。In the following description, a mobile terminal will be taken as an example, and those skilled in the art will understand that, in addition to elements specially used for mobile purposes, the configurations according to the embodiments of the present invention can also be applied to fixed-type terminals.
请参阅图1,其为实现本发明各个实施例的一种移动终端的硬件结构示意图,该移动终端100可以包括:RF(Radio Frequency,射频)单元101、WiFi模块102、音频输出单元103、A/V(音频/视频)输入单元104、传感器105、显示单元106、用户输入单元107、接口单元108、存储器109、处理器110、以及电源111等部件。本领域技术人员可以理解,图1中示出的移动终端结构并不构成对移动终端的限定,移动终端可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Please refer to FIG. 1 , which is a schematic diagram of the hardware structure of a mobile terminal implementing various embodiments of the present invention. The
下面结合图1对移动终端的各个部件进行具体的介绍:Each component of the mobile terminal is specifically introduced below in combination with FIG. 1:
射频单元101可用于收发信息或通话过程中,信号的接收和发送,具体的,将基站的下行信息接收后,给处理器110处理;另外,将上行的数据发送给基站。通常,射频单元101包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器、双工器等。此外,射频单元101还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于GSM(Global System of Mobile communication,全球移动通讯系统)、GPRS(General Packet Radio Service,通用分组无线服务)、CDMA2000(CodeDivision Multiple Access 2000,码分多址2000)、WCDMA(Wideband Code DivisionMultiple Access,宽带码分多址)、TD-SCDMA(Time Division-Synchronous CodeDivision Multiple Access,时分同步码分多址)、FDD-LTE(Frequency DivisionDuplexing-Long Term Evolution,频分双工长期演进)和TDD-LTE(Time DivisionDuplexing-Long Term Evolution,分时双工长期演进)等。The
WiFi属于短距离无线传输技术,移动终端100通过WiFi模块102可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图1示出了WiFi模块102,但是可以理解的是,其并不属于移动终端的必须构成,完全可以根据需要在不改变发明的本质的范围内而省略。WiFi is a short-distance wireless transmission technology. The
音频输出单元103可以在移动终端100处于呼叫信号接收模式、通话模式、记录模式、语音识别模式、广播接收模式等等模式下时,将射频单元101或WiFi模块102接收的或者在存储器109中存储的音频数据转换成音频信号并且输出为声音。而且,音频输出单元103还可以提供与移动终端100执行的特定功能相关的音频输出(例如,呼叫信号接收声音、消息接收声音等等)。音频输出单元103可以包括扬声器、蜂鸣器等等。The
A/V输入单元104用于接收音频或视频信号。A/V输入单元104可以包括图形处理器(Graphics Processing Unit,GPU)1041和麦克风1042,图形处理器1041对在视频捕获模式或图像捕获模式中由图像捕获装置(如摄像头)获得的静态图片或视频的图像数据进行处理。处理后的图像帧可以显示在显示单元106上。经图形处理器1041处理后的图像帧可以存储在存储器109(或其它存储介质)中或者经由射频单元101或WiFi模块102进行发送。麦克风1042可以在电话通话模式、记录模式、语音识别模式等等运行模式中经由麦克风1042接收声音(音频数据),并且能够将这样的声音处理为音频数据。处理后的音频(语音)数据可以在电话通话模式的情况下转换为可经由射频单元101发送到移动通信基站的格式输出。麦克风1042可以实施各种类型的噪声消除(或抑制)算法以消除(或抑制)在接收和发送音频信号的过程中产生的噪声或者干扰。The A/
移动终端100还包括至少一种传感器105,比如光传感器、运动传感器以及其他传感器。具体地,光传感器包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板1061的亮度,接近传感器可在移动终端100移动到耳边时,关闭显示面板1061和/或背光。作为运动传感器的一种,加速计传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于手机还可配置的指纹传感器、压力传感器、虹膜传感器、分子传感器、陀螺仪、气压计、湿度计、温度计、图像感测器、红外线传感器等其他传感器,在此不再赘述。The
显示单元106用于显示由用户输入的信息或提供给用户的信息。显示单元106可包括显示面板1061,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板1061。The
用户输入单元107可用于接收输入的数字或字符信息,以及产生与移动终端的用户设置以及功能控制有关的键信号输入。具体地,用户输入单元107可包括触控面板1071以及其他输入设备1072。触控面板1071,也称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板1071上或在触控面板1071附近的操作),并根据预先设定的程式驱动相应的连接装置。触控面板1071可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器110,并能接收处理器110发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板1071。除了触控面板1071,用户输入单元107还可以包括其他输入设备1072。具体地,其他输入设备1072可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种,具体此处不做限定。The
进一步的,触控面板1071可覆盖显示面板1061,当触控面板1071检测到在其上或附近的触摸操作后,传送给处理器110以确定触摸事件的类型,随后处理器110根据触摸事件的类型在显示面板1061上提供相应的视觉输出。虽然在图1中,触控面板1071与显示面板1061是作为两个独立的部件来实现移动终端的输入和输出功能,但是在某些实施例中,可以将触控面板1071与显示面板1061集成而实现移动终端的输入和输出功能,具体此处不做限定。Further, the
接口单元108用作至少一个外部装置与移动终端100连接可以通过的接口。例如,外部装置可以包括有线或无线头戴式耳机端口、外部电源(或电池充电器)端口、有线或无线数据端口、存储卡端口、用于连接具有识别模块的装置的端口、音频输入/输出(I/O)端口、视频I/O端口、耳机端口等等。接口单元108可以用于接收来自外部装置的输入(例如,数据信息、电力等等)并且将接收到的输入传输到移动终端100内的一个或多个元件或者可以用于在移动终端100和外部装置之间传输数据。The
存储器109可用于存储软件程序以及各种数据。存储器109可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据手机的使用所创建的数据(比如音频数据、电话本等)等。此外,存储器109可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The
处理器110是移动终端的控制中心,利用各种接口和线路连接整个移动终端的各个部分,通过运行或执行存储在存储器109内的软件程序和/或模块,以及调用存储在存储器109内的数据,执行移动终端的各种功能和处理数据,从而对移动终端进行整体监控。处理器110可包括一个或多个处理单元;优选的,处理器110可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器110中。The
移动终端100还可以包括给各个部件供电的电源111(比如电池),优选的,电源111可以通过电源管理系统与处理器110逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。The
尽管图1未示出,移动终端100还可以包括蓝牙模块等,在此不再赘述。Although not shown in FIG. 1 , the
为了便于理解本发明实施例,下面对本发明的移动终端所基于的通信网络系统进行描述。In order to facilitate understanding of the embodiments of the present invention, the following describes the communication network system on which the mobile terminal of the present invention is based.
请参阅图2,图2为本发明实施例提供的一种通信网络系统架构图,该通信网络系统为通用移动通信技术的LTE系统,该LTE系统包括依次通讯连接的UE(User Equipment,用户设备)201,E-UTRAN(Evolved UMTS Terrestrial Radio Access Network,演进式UMTS陆地无线接入网)202,EPC(Evolved Packet Core,演进式分组核心网)203和运营商的IP业务204。Please refer to FIG. 2. FIG. 2 is a structure diagram of a communication network system provided by an embodiment of the present invention. The communication network system is an LTE system of general mobile communication technology, and the LTE system includes UEs (User Equipment, User Equipment) connected in sequence ) 201, E-UTRAN (Evolved UMTS Terrestrial Radio Access Network, Evolved UMTS Terrestrial Radio Access Network) 202, EPC (Evolved Packet Core, Evolved Packet Core Network) 203 and the operator's
具体地,UE201可以是上述终端100,此处不再赘述。Specifically, the
E-UTRAN202包括eNodeB2021和其它eNodeB2022等。其中,eNodeB2021可以通过回程(backhaul)(例如X2接口)与其它eNodeB2022连接,eNodeB2021连接到EPC203,eNodeB2021可以提供UE201到EPC203的接入。
EPC203可以包括MME(Mobility Management Entity,移动性管理实体)2031,HSS(Home Subscriber Server,归属用户服务器)2032,其它MME2033,SGW(Serving Gate Way,服务网关)2034,PGW(PDN Gate Way,分组数据网络网关)2035和PCRF(Policy andCharging Rules Function,政策和资费功能实体)2036等。其中,MME2031是处理UE201和EPC203之间信令的控制节点,提供承载和连接管理。HSS2032用于提供一些寄存器来管理诸如归属位置寄存器(图中未示)之类的功能,并且保存有一些有关服务特征、数据速率等用户专用的信息。所有用户数据都可以通过SGW2034进行发送,PGW2035可以提供UE 201的IP地址分配以及其它功能,PCRF2036是业务数据流和IP承载资源的策略与计费控制策略决策点,它为策略与计费执行功能单元(图中未示)选择及提供可用的策略和计费控制决策。EPC203 may include MME (Mobility Management Entity, Mobility Management Entity) 2031, HSS (Home Subscriber Server, Home Subscriber Server) 2032, other MME2033, SGW (Serving Gate Way, Serving Gateway) 2034, PGW (PDN Gate Way, packet data Network Gateway) 2035 and PCRF (Policy and Charging Rules Function, Policy and Charging Functional Entity) 2036, etc. Wherein, MME2031 is a control node that processes signaling between UE201 and EPC203, and provides bearer and connection management. HSS2032 is used to provide some registers to manage functions such as home location register (not shown in the figure), and save some user-specific information about service features and data rates. All user data can be sent through SGW2034, PGW2035 can provide
IP业务204可以包括因特网、内联网、IMS(IP Multimedia Subsystem,IP多媒体子系统)或其它IP业务等。The
虽然上述以LTE系统为例进行了介绍,但本领域技术人员应当知晓,本发明不仅仅适用于LTE系统,也可以适用于其他无线通信系统,例如GSM、CDMA2000、WCDMA、TD-SCDMA以及未来新的网络系统等,此处不做限定。Although the LTE system is taken as an example above, those skilled in the art should know that the present invention is not only applicable to the LTE system, but also applicable to other wireless communication systems, such as GSM, CDMA2000, WCDMA, TD-SCDMA and future new wireless communication systems. The network system, etc., are not limited here.
基于上述移动终端100硬件结构以及通信网络系统,提出本发明方法各个实施例。Based on the above hardware structure of the
首先,本发明提出一种2D游戏的渲染程序300。First, the present invention proposes a 2D game rendering program 300 .
参阅图3所示,是本发明2D游戏的渲染程序300第一实施例的程序模块图。本实施例中,所述的2D游戏的渲染程序300可以被分割成一个或多个模块,所述一个或者多个模块被存储于所述移动终端100的存储器109中,并由一个或多个处理器(本实施例中为所述处理器110)所执行,以完成本发明。例如,在图3中,所述的2D游戏的渲染程序300可以被分割成获取模块301、建立模块302、映射模块303、接收模块304以及触发模块305。本发明所称的程序模块是指能够完成特定功能的一系列计算机程序指令段,比程序更适合于描述所述2D游戏的渲染程序300在所述移动终端100中的执行过程。以下将就各功能模块301-305的功能进行详细描述。Referring to FIG. 3 , it is a program module diagram of the first embodiment of the 2D game rendering program 300 of the present invention. In this embodiment, the rendering program 300 of the 2D game can be divided into one or more modules, and the one or more modules are stored in the
所述获取模块301,用于获取2D游戏画面数据,分析2D游戏画面元件的初始坐标。The acquiring module 301 is configured to acquire 2D game screen data, and analyze initial coordinates of 2D game screen elements.
所述建立模块302,用于基于所述初始坐标构建所述2D游戏画面元件的实际坐标系。所述基于所述初始坐标构建所述2D游戏画面元件的实际坐标系的具体步骤将在下文进行详述。The establishing module 302 is configured to construct an actual coordinate system of the 2D game screen element based on the initial coordinates. The specific steps of constructing the actual coordinate system of the 2D game screen element based on the initial coordinates will be described in detail below.
所述映射模块303,用于基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中。The mapping module 303 is configured to map the 2D game screen into a 3D game screen based on the actual coordinate system, and cache the data of the mapped 3D game screen into a buffer.
所述接收模块304,用于接收2D游戏的运行指令。The receiving module 304 is configured to receive the running instruction of the 2D game.
具体地,用户通过移动终端100的客户端操作游戏画面,所述接收模块304,接收所述移动终端100的客户端发送的关于2D游戏的运行指令。Specifically, the user operates the game screen through the client terminal of the
所述触发模块305,用于当所述接收模块304接收到关于所述2D游戏的运行指令后,根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。The triggering module 305 is configured to, after the receiving module 304 receives the running instruction about the 2D game, call the data of the 3D game screen in the buffer according to the running command, and trigger the 3D game screen rendering mechanism.
通过上述程序模块301-305,本发明所提出的2D游戏的渲染程序300,首先,所述移动终端100获取2D游戏画面数据,分析2D游戏画面元件的初始坐标,其次,基于所述初始坐标构建所述2D游戏画面元件的实际坐标系,接着,当基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中;最后接收2D游戏的运行指令;并根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。通过移动终端100通过采用游戏画面由2D向3D映射的方式,开启GPU渲染,能够迅速提升游戏的渲染速度。Through the above program modules 301-305, the 2D game rendering program 300 proposed by the present invention, first, the
进一步地,基于本发明2D游戏的渲染程序300的上述第一实施例,提出本发明的第二实施例(如图3所示)。本实施例中,所述建立模块302还用于:Further, based on the above-mentioned first embodiment of the 2D game rendering program 300 of the present invention, a second embodiment of the present invention (as shown in FIG. 3 ) is proposed. In this embodiment, the establishment module 302 is also used for:
构建CSS库以及JS库,所述CSS库包括至少一个转换标签。A CSS library and a JS library are constructed, the CSS library includes at least one conversion tag.
本实施例中,所述建立模块302还用于基于所述2D游戏画面元件的初始坐标,根据所述CSS库的转换标签以及所述JS库构建所述2D游戏画面元件的实际坐标系。In this embodiment, the establishment module 302 is further configured to construct the actual coordinate system of the 2D game screen element based on the initial coordinates of the 2D game screen element, according to the conversion tag of the CSS library and the JS library.
具体地,所述转换标签包括transform-origin、transform-style、perspective。transform-origin:origin(起源,起点),也即变形的起点,在数学上可以理解为坐标原点。transform-origin属性值可以是百分比、em、px等具体的值,也可以是top、right、bottom、left和center这样的关键词。transform-style:指定嵌套元素如何在3D空间中呈现。转换标签transform-style有两个属性值:flat和preserve-3d。其中flat值为默认值,表示所有子元素在2D平面呈现。preserve-3d表示所有子元素在3D空间中呈现。如果对一个元素设置了transform-style的值为flat,则该元素的所有子元素都将被平展到该元素的2D平面中进行呈现。沿着X轴或Y轴方向旋转该元素将导致位于正或者负Z轴位置的子元素显示在该元素的平面上,而不是它的前面或者后面。反之,如果对一个元素设置了transform-style的值为preserve-3d,它表示不执行平展操作,它的所有子元素位于3D空间中。transform-style属性需要设置在父元素中,并且高于任何嵌套的变形元素。即transform-style的值为flat时,其子元素并不会受到rotateX(旋转)等的影响,而是直接与父元素叠加在一起,和父元素处于同一平面上。当transform-style的值为preserve-3d时,子元素与父元素分离,受单独的属性控制。Specifically, the transformation tags include transform-origin, transform-style, perspective. transform-origin: origin (origin, starting point), that is, the starting point of deformation, can be understood as the origin of coordinates in mathematics. The transform-origin attribute value can be specific values such as percentage, em, px, etc., or keywords such as top, right, bottom, left, and center. transform-style: Specifies how nested elements are rendered in 3D space. The transformation tag transform-style has two attribute values: flat and preserve-3d. The flat value is the default value, indicating that all child elements are presented on a 2D plane. preserve-3d means that all child elements are rendered in 3D space. If the value of transform-style is set to flat for an element, all child elements of the element will be flattened to the 2D plane of the element for presentation. Rotating the element along the X or Y axis will cause child elements at positive or negative Z positions to appear in the plane of the element, rather than in front of or behind it. Conversely, if a transform-style value is set to preserve-3d for an element, it means that no flattening operation is performed, and all its child elements are located in 3D space. The transform-style attribute needs to be set on the parent element, above any nested transform elements. That is, when the value of transform-style is flat, its child elements will not be affected by rotateX (rotation), etc., but will be directly superimposed on the parent element and be on the same plane as the parent element. When the value of transform-style is preserve-3d, the child element is separated from the parent element and controlled by a separate attribute.
本实施例中,所述JS库包括实际显示屏的环境参数,游戏场景参数,游戏元素的移动参数等等。所述建立模块302基于2D游戏画面的元件初始坐标,CSS库的转换标签以及JS库提供的环境参数,游戏场景参数,游戏元素的移动参数构建2D游戏画面的元件的实际坐标系。In this embodiment, the JS library includes environmental parameters of the actual display screen, game scene parameters, movement parameters of game elements, and the like. The building module 302 constructs the actual coordinate system of the elements of the 2D game screen based on the initial coordinates of the elements of the 2D game screen, the conversion tags of the CSS library and the environmental parameters provided by the JS library, the game scene parameters, and the movement parameters of the game elements.
本实施例中,JS库还依据生成的实际坐标系进行游戏画面元件的碰撞检测,具体的碰撞检测方法属于现有技术,此处不再多做赘述。In this embodiment, the JS library also performs collision detection of game screen elements according to the generated actual coordinate system. The specific collision detection method belongs to the prior art and will not be repeated here.
通过上述程序模块301-305,本发明所提出的2D游戏的渲染程序300,能够基于所述2D游戏画面元件的初始坐标,根据所述CSS库的转换标签以及所述JS库构建所述2D游戏画面元件的实际坐标系,且通过所述JS库完成碰撞检测。Through the above program modules 301-305, the 2D game rendering program 300 proposed by the present invention can construct the 2D game based on the initial coordinates of the 2D game screen elements, according to the conversion tags of the CSS library and the JS library The actual coordinate system of the screen element, and the collision detection is completed through the JS library.
进一步地,基于本发明2D游戏的渲染程序300的上述第一实施例,提出本发明的第三实施例(如图4所示)。本实施例中,所述的2D游戏的渲染程序300还包括渲染显示模块306,其中:Further, based on the above-mentioned first embodiment of the 2D game rendering program 300 of the present invention, a third embodiment of the present invention (as shown in FIG. 4 ) is proposed. In this embodiment, the 2D game rendering program 300 also includes a rendering display module 306, wherein:
所述渲染显示模块306用于:The rendering display module 306 is used for:
调取图形处理单元(graphic processing unit,GPU)对所述3D游戏画面进行渲染;及控制所述移动终端的显示屏幕实时显示渲染后的3D游戏画面。calling a graphic processing unit (graphic processing unit, GPU) to render the 3D game picture; and controlling the display screen of the mobile terminal to display the rendered 3D game picture in real time.
本实施例中,所述渲染显示模块306对所述3D游戏画面进行顶点处理、光栅化计算、纹理帖图及像素处理以实现对所述3D游戏画面进行渲染。下面对顶点处理、光栅化计算、纹理帖图及像素处理进行详述。In this embodiment, the rendering and display module 306 performs vertex processing, rasterization calculation, texture mapping and pixel processing on the 3D game screen to render the 3D game screen. Vertex processing, rasterization calculation, texture mapping and pixel processing are described in detail below.
1.顶点处理,这阶段GPU读取映射后3D图形外观在实际坐标系中顶点数据确定3D图形的形状及位置关系,进而建立起3D图形的骨架。在支持DX8和DX9规格的GPU中,这些工作由硬件实现的Vertex Shader(定点着色器)完成。1. Vertex processing. At this stage, after the GPU reads the mapped 3D graphics appearance, the vertex data in the actual coordinate system determines the shape and position relationship of the 3D graphics, and then establishes the skeleton of the 3D graphics. In GPUs that support DX8 and DX9 specifications, these tasks are done by the hardware-implemented Vertex Shader (fixed-point shader).
2.光栅化计算,显示器实际显示的图像是由像素组成的,我们需要将上面生成的图形上的点和线通过一定的算法转换到相应的像素点。把一个矢量图形转化为一系列像素点的过程就是光栅化。例如,一条数学表示的斜线段,最终被转化成阶梯状的连续像素点。2. Rasterization calculation, the image actually displayed on the display is composed of pixels, we need to convert the points and lines on the above generated graphics to corresponding pixel points through a certain algorithm. The process of converting a vector graphic into a series of pixels is called rasterization. For example, a slanted line represented by mathematics is finally transformed into stepped continuous pixels.
3.纹理帖图,顶点单元生成的多边形只构成了3D物体的轮廓,而纹理映射(texture mapping)工作完成对多边形表面的帖图,通俗的说,就是将多边形的表面贴上相应的图片,从而生成“真实”的图形。TMU(Texture mapping unit)即是用来完成此项工作。3. Texture map, the polygon generated by the vertex unit only constitutes the outline of the 3D object, and the texture mapping (texture mapping) work completes the map of the polygon surface. In layman's terms, it is to paste the corresponding picture on the surface of the polygon. Thus generating a "real" graph. TMU (Texture mapping unit) is used to complete this work.
4.像素处理,这阶段(在对每个像素进行光栅化处理期间)GPU完成对像素的计算和处理。当侦测到游戏画面停止操作的时候,比如一定时间没有接收到触发指令操作时,判断游戏画面停止。此时,结束2D画面向3D画面的实时映射,同时擦除3D画面的映射数据,并停止调用GPU。4. Pixel processing, at this stage (during the rasterization of each pixel) the GPU completes the calculation and processing of the pixels. When it is detected that the game screen stops operating, for example, when no trigger command operation is received for a certain period of time, it is determined that the game screen is stopped. At this time, the real-time mapping of the 2D picture to the 3D picture is ended, and at the same time, the mapping data of the 3D picture is erased, and the calling of the GPU is stopped.
通过上述程序模块306,本发明所提出的2D游戏的渲染程序300,通过调取图形处理单元(GPU)对所述3D游戏画面进行顶点处理、光栅化计算、纹理帖图及像素处理以对所述3D游戏画面进行渲染;并控制所述移动终端的显示屏幕实时显示渲染后的3D游戏画面,从而对所述游戏画面完成从2D向3D渲染的机制。即通过2D向3D映射的方式,开启游戏画面的GPU渲染,能够迅速提升游戏的渲染速度。Through the above-mentioned program module 306, the rendering program 300 of the 2D game proposed by the present invention performs vertex processing, rasterization calculation, texture map and pixel processing on the 3D game screen by calling a graphics processing unit (GPU) to process all The 3D game screen is rendered; and the display screen of the mobile terminal is controlled to display the rendered 3D game screen in real time, thereby completing the mechanism of rendering the game screen from 2D to 3D. That is, through 2D to 3D mapping, the GPU rendering of the game screen is turned on, which can quickly increase the rendering speed of the game.
进一步地,基于本发明2D游戏的渲染程序300的上述第一至第三实施例,提出本发明的第四实施例(如图5所示)。本实施例中,所述的2D游戏的渲染程序300还包括权调整模块307,其中:Furthermore, based on the above-mentioned first to third embodiments of the 2D game rendering program 300 of the present invention, a fourth embodiment of the present invention (as shown in FIG. 5 ) is proposed. In this embodiment, the rendering program 300 of the 2D game further includes a weight adjustment module 307, wherein:
本实施例中,所述移动终端100还包括至少2个不同位置的麦克风装置。In this embodiment, the
所述调整模块307用于:根据所述麦克风装置空间位置的变化,相应的改变各个麦克风装置的声音;及在调用GPU对所述3D游戏画面进行渲染的过程中,将调整后的麦克风的声音与渲染后的3D游戏画面进行同步。The adjustment module 307 is used to: change the sound of each microphone device correspondingly according to the change of the spatial position of the microphone device; Synchronize with the rendered 3D game screen.
具体地,所述移动终端100还包括至少2个不同位置的麦克风装置,在上述将游戏画面由2D映射成3D的过程中,根据麦克风装置空间位置的变化,相应的改变各个麦克风装置的声音,进而营造出立体声效果。而在调用GPU对所述3D游戏画面进行渲染的过程中,将调整后的麦克风的声音与渲染后的3D游戏画面进行同步,以让用户有更好的体验。Specifically, the
通过上述程序模块307,本发明所提出的2D游戏的渲染程序300,能够根据麦克风装置空间位置的变化,相应的改变各个麦克风装置的声音,进而营造出立体声效果,且在调用GPU对所述3D游戏画面进行渲染的过程中,将调整后的麦克风的声音与渲染后的3D游戏画面进行同步,以让用户有更好的体验。Through the above program module 307, the rendering program 300 of the 2D game proposed by the present invention can change the sound of each microphone device correspondingly according to the change of the spatial position of the microphone device, thereby creating a stereo effect, and calling the GPU to control the 3D game. During the rendering of the game screen, the adjusted sound of the microphone is synchronized with the rendered 3D game screen, so that the user can have a better experience.
此外,本发明还提出一种2D游戏的渲染方法。In addition, the present invention also proposes a rendering method for 2D games.
参阅图6所示,是本发明2D游戏的渲染方法第一实施例的流程图。在本实施例中,根据不同的需求,图6所示的流程图中的步骤的执行顺序可以改变,某些步骤可以省略。Referring to FIG. 6 , it is a flow chart of the first embodiment of the 2D game rendering method of the present invention. In this embodiment, according to different requirements, the execution order of the steps in the flowchart shown in FIG. 6 may be changed, and some steps may be omitted.
步骤S601,获取2D游戏画面数据,分析2D游戏画面元件的初始坐标。Step S601, acquiring 2D game screen data, and analyzing the initial coordinates of the 2D game screen components.
步骤S602,根据所述初始坐标构建所述2D游戏画面元件的实际坐标系。所述基于所述初始坐标构建所述2D游戏画面元件的实际坐标系的具体步骤将在下文(本发明2D游戏的渲染方法第二实施例,图7)进行详述。Step S602, constructing an actual coordinate system of the 2D game screen element according to the initial coordinates. The specific steps of constructing the actual coordinate system of the 2D game screen component based on the initial coordinates will be described in detail below (the second embodiment of the rendering method of the 2D game of the present invention, FIG. 7 ).
步骤S603,基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中。Step S603, based on the actual coordinate system, map the 2D game screen into a 3D game screen, and cache the data of the mapped 3D game screen into a buffer.
步骤S604,接收2D游戏的运行指令。Step S604, receiving a running command of the 2D game.
具体地,用户通过移动终端100的客户端操作游戏画面,所述移动终端100接收来自客户端发送的关于2D游戏的运行指令。Specifically, the user operates the game screen through the client terminal of the
步骤S605,根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。Step S605, calling the data of the 3D game screen in the buffer according to the execution instruction, and triggering the rendering mechanism of the 3D game screen.
具体地,移动终端100获取2D游戏画面数据,分析2D游戏画面元件的初始坐标,根据所述初始坐标构建所述2D游戏画面元件的实际坐标系;基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中,接收2D游戏的运行指令及根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。Specifically, the
通过上述步骤S601-605,本发明所提出的2D游戏的渲染方法,首先,移动终端100获取2D游戏画面数据,分析2D游戏画面元件的初始坐标,其次,根据所述初始坐标构建所述2D游戏画面元件的实际坐标系;接着,基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中,然后,接收2D游戏的运行指令,最后,根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。通过移动终端100通过采用游戏画面由2D向3D映射的方式,开启GPU渲染,能够迅速提升游戏的渲染速度。Through the above steps S601-605, the rendering method of the 2D game proposed by the present invention, firstly, the
如图7所示,是本发明2D游戏的渲染方法的第二实施例的流程图。在本实施例中,所述基于所述初始坐标构建所述2D游戏画面元件的实际坐标系的步骤,具体包括:As shown in FIG. 7 , it is a flow chart of the second embodiment of the 2D game rendering method of the present invention. In this embodiment, the step of constructing the actual coordinate system of the 2D game screen element based on the initial coordinates specifically includes:
步骤S701,构建CSS库以及JS库。本实施例中,所述CSS库包括至少一个转换标签。Step S701, building a CSS library and a JS library. In this embodiment, the CSS library includes at least one conversion tag.
步骤S702,基于所述2D游戏画面元件的初始坐标,根据所述CSS库的转换标签以及所述JS库构建所述2D游戏画面元件的实际坐标系。Step S702, based on the initial coordinates of the 2D game screen component, construct the actual coordinate system of the 2D game screen component according to the conversion tag of the CSS library and the JS library.
具体地,所述转换标签包括transform-origin、transform-style、perspective。transform-origin:origin(起源,起点),也即变形的起点,在数学上可以理解为坐标原点。transform-origin属性值可以是百分比、em、px等具体的值,也可以是top、right、bottom、left和center这样的关键词。transform-style:指定嵌套元素如何在3D空间中呈现。转换标签transform-style有两个属性值:flat和preserve-3d。其中flat值为默认值,表示所有子元素在2D平面呈现。preserve-3d表示所有子元素在3D空间中呈现。如果对一个元素设置了transform-style的值为flat,则该元素的所有子元素都将被平展到该元素的2D平面中进行呈现。沿着X轴或Y轴方向旋转该元素将导致位于正或者负Z轴位置的子元素显示在该元素的平面上,而不是它的前面或者后面。反之,如果对一个元素设置了transform-style的值为preserve-3d,它表示不执行平展操作,它的所有子元素位于3D空间中。transform-style属性需要设置在父元素中,并且高于任何嵌套的变形元素。即transform-style的值为flat时,其子元素并不会受到rotateX(旋转)等的影响,而是直接与父元素叠加在一起,和父元素处于同一平面上。当transform-style的值为preserve-3d时,子元素与父元素分离,受单独的属性控制。Specifically, the transformation tags include transform-origin, transform-style, perspective. transform-origin: origin (origin, starting point), that is, the starting point of deformation, can be understood as the origin of coordinates in mathematics. The transform-origin attribute value can be specific values such as percentage, em, px, etc., or keywords such as top, right, bottom, left, and center. transform-style: Specifies how nested elements are rendered in 3D space. The transformation tag transform-style has two attribute values: flat and preserve-3d. The flat value is the default value, indicating that all child elements are presented on a 2D plane. preserve-3d means that all child elements are rendered in 3D space. If the value of transform-style is set to flat for an element, all child elements of the element will be flattened to the 2D plane of the element for presentation. Rotating the element along the X or Y axis will cause child elements at positive or negative Z positions to appear in the plane of the element, rather than in front of or behind it. Conversely, if the value of transform-style is set to preserve-3d for an element, it means that no flattening operation is performed, and all its child elements are located in 3D space. The transform-style attribute needs to be set on the parent element, above any nested transform elements. That is, when the value of transform-style is flat, its child elements will not be affected by rotateX (rotation), etc., but will be directly superimposed on the parent element and be on the same plane as the parent element. When the value of transform-style is preserve-3d, the child element is separated from the parent element and controlled by a separate attribute.
本实施例中,所述JS库包括实际显示屏的环境参数,游戏场景参数,游戏元素的移动参数等等。所述移动终端100基于2D游戏画面的元件初始坐标,CSS库的转换标签以及JS库提供的环境参数,游戏场景参数,游戏元素的移动参数构建2D游戏画面的元件的实际坐标系。In this embodiment, the JS library includes environmental parameters of the actual display screen, game scene parameters, movement parameters of game elements, and the like. The
本实施例中,JS库还依据生成的实际坐标系进行游戏画面元件的碰撞检测,具体的碰撞检测方法属于现有技术,此处不再多做赘述。In this embodiment, the JS library also performs collision detection of game screen elements according to the generated actual coordinate system. The specific collision detection method belongs to the prior art and will not be repeated here.
通过上述步骤S701-S702,本发明所提出的2D游戏的渲染方法,能够基于所述2D游戏画面元件的初始坐标,根据所述CSS库的转换标签以及所述JS库构建所述2D游戏画面元件的实际坐标系,且通过所述JS库完成碰撞检测。Through the above steps S701-S702, the 2D game rendering method proposed by the present invention can construct the 2D game screen component based on the initial coordinates of the 2D game screen component, according to the conversion tag of the CSS library and the JS library The actual coordinate system, and the collision detection is completed through the JS library.
基于本发明2D游戏的渲染方法的上述第一实施例,提出本发明2D游戏的渲染方法的第三实施例。Based on the above-mentioned first embodiment of the rendering method of the 2D game of the present invention, a third embodiment of the rendering method of the 2D game of the present invention is proposed.
如图8所示,是本发明2D游戏的渲染方法的第三实施例的流程图。在本实施例中,根据不同的需求,图8所示的流程图中的步骤的执行顺序可以改变,某些步骤可以省略。As shown in FIG. 8 , it is a flow chart of the third embodiment of the rendering method of the 2D game of the present invention. In this embodiment, according to different requirements, the execution order of the steps in the flowchart shown in FIG. 8 may be changed, and some steps may be omitted.
步骤S801,获取2D游戏画面数据,分析2D游戏画面元件的初始坐标。Step S801, acquiring 2D game screen data, and analyzing the initial coordinates of the 2D game screen components.
步骤S802,根据所述初始坐标构建所述2D游戏画面元件的实际坐标系。Step S802, constructing an actual coordinate system of the 2D game screen element according to the initial coordinates.
步骤S803,基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中。Step S803, based on the actual coordinate system, map the 2D game screen into a 3D game screen, and cache the data of the mapped 3D game screen into a buffer.
步骤S804,接收2D游戏的运行指令。Step S804, receiving a running command of the 2D game.
具体地,用户通过移动终端100的客户端操作游戏画面,所述移动终端100接收来自客户端发送的关于2D游戏的运行指令。Specifically, the user operates the game screen through the client terminal of the
步骤S805,根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。Step S805, calling the data of the 3D game screen in the buffer according to the execution instruction, and triggering the rendering mechanism of the 3D game screen.
步骤S806,调取图形处理单元(graphic processing unit,GPU)对所述3D游戏画面进行渲染。Step S806, calling a graphics processing unit (graphic processing unit, GPU) to render the 3D game screen.
步骤S807,控制所述移动终端的显示屏幕实时显示渲染后的3D游戏画面。Step S807, controlling the display screen of the mobile terminal to display the rendered 3D game screen in real time.
本实施例中,所述移动终端100对所述3D游戏画面进行顶点处理、光栅化计算、纹理帖图及像素处理以实现对所述3D游戏画面进行渲染。下面对顶点处理、光栅化计算、纹理帖图及像素处理进行详述。In this embodiment, the
1.顶点处理,这阶段GPU读取映射后3D图形外观在实际坐标系中顶点数据确定3D图形的形状及位置关系,进而建立起3D图形的骨架。在支持DX8和DX9规格的GPU中,这些工作由硬件实现的Vertex Shader(定点着色器)完成。1. Vertex processing. At this stage, after the GPU reads the mapped 3D graphics appearance, the vertex data in the actual coordinate system determines the shape and position relationship of the 3D graphics, and then establishes the skeleton of the 3D graphics. In GPUs that support DX8 and DX9 specifications, these tasks are done by the hardware-implemented Vertex Shader (fixed-point shader).
2.光栅化计算,显示器实际显示的图像是由像素组成的,我们需要将上面生成的图形上的点和线通过一定的算法转换到相应的像素点。把一个矢量图形转化为一系列像素点的过程就是光栅化。例如,一条数学表示的斜线段,最终被转化成阶梯状的连续像素点。2. Rasterization calculation, the image actually displayed on the display is composed of pixels, we need to convert the points and lines on the above generated graphics to corresponding pixel points through a certain algorithm. The process of converting a vector graphic into a series of pixels is called rasterization. For example, a slanted line represented by mathematics is finally transformed into stepped continuous pixels.
3.纹理帖图,顶点单元生成的多边形只构成了3D物体的轮廓,而纹理映射(texture mapping)工作完成对多边形表面的帖图,通俗的说,就是将多边形的表面贴上相应的图片,从而生成“真实”的图形。TMU(Texture mapping unit)即是用来完成此项工作。3. Texture map, the polygon generated by the vertex unit only constitutes the outline of the 3D object, and the texture mapping (texture mapping) work completes the map of the polygon surface. In layman's terms, it is to paste the corresponding picture on the surface of the polygon. Thus generating a "real" graph. TMU (Texture mapping unit) is used to complete this work.
4.像素处理,这阶段(在对每个像素进行光栅化处理期间)GPU完成对像素的计算和处理。当侦测到游戏画面停止操作的时候,比如一定时间没有接收到触发指令操作时,判断游戏画面停止。此时,结束2D画面向3D画面的实时映射,同时擦除3D画面的映射数据,并停止调用GPU。4. Pixel processing, at this stage (during the rasterization of each pixel) the GPU completes the calculation and processing of the pixels. When it is detected that the game screen stops operating, for example, when no trigger command operation is received for a certain period of time, it is determined that the game screen is stopped. At this time, the real-time mapping of the 2D picture to the 3D picture is ended, and at the same time, the mapping data of the 3D picture is erased, and the calling of the GPU is stopped.
通过上述步骤S801-S807,本发明所提出的2D游戏的渲染方法,能够通过调取图形处理单元(GPU)对所述3D游戏画面进行顶点处理、光栅化计算、纹理帖图及像素处理以对所述3D游戏画面进行渲染;并控制所述移动终端的显示屏幕实时显示渲染后的3D游戏画面,从而对所述游戏画面完成从2D向3D渲染的机制。即通过2D向3D映射的方式,开启游戏画面的GPU渲染,能够迅速提升游戏的渲染速度。Through the above steps S801-S807, the 2D game rendering method proposed by the present invention can perform vertex processing, rasterization calculation, texture map and pixel processing on the 3D game screen by calling a graphics processing unit (GPU) to The 3D game picture is rendered; and the display screen of the mobile terminal is controlled to display the rendered 3D game picture in real time, thereby completing the mechanism of rendering the game picture from 2D to 3D. That is, through 2D to 3D mapping, the GPU rendering of the game screen is turned on, which can quickly increase the rendering speed of the game.
进一步地,基于本发明2D游戏的渲染方法的上述第一至第三实施例,提出本发明2D游戏的渲染方法的第四实施例。Further, based on the above-mentioned first to third embodiments of the 2D game rendering method of the present invention, a fourth embodiment of the 2D game rendering method of the present invention is proposed.
如图9所示,是本发明2D游戏的渲染方法的第四实施例的流程图。本实施例中,所述移动终端100还包括至少2个不同位置的麦克风装置,具体包括:As shown in FIG. 9 , it is a flow chart of the fourth embodiment of the 2D game rendering method of the present invention. In this embodiment, the
步骤S901,获取2D游戏画面数据,分析2D游戏画面元件的初始坐标。Step S901, acquiring 2D game screen data, and analyzing the initial coordinates of the 2D game screen components.
步骤S902,根据所述初始坐标构建所述2D游戏画面元件的实际坐标系。Step S902, constructing an actual coordinate system of the 2D game screen element according to the initial coordinates.
步骤S903,基于所述实际坐标系,将2D游戏画面映射成3D游戏画面,并将映射的3D游戏画面的数据缓存到缓存器中。Step S903, based on the actual coordinate system, map the 2D game screen into a 3D game screen, and cache the data of the mapped 3D game screen into a buffer.
步骤S904,接收2D游戏的运行指令。Step S904, receiving a running command of the 2D game.
步骤S905,根据所述运行指令调取所述缓存器中3D游戏画面的数据,触发所述3D游戏画面渲染机制。Step S905, calling the data of the 3D game screen in the buffer according to the execution instruction, and triggering the rendering mechanism of the 3D game screen.
步骤S906,根据所述麦克风装置空间位置的变化,相应的改变各个麦克风装置的声音。Step S906, changing the sound of each microphone device correspondingly according to the change of the spatial position of the microphone device.
步骤S907,在对所述3D游戏画面进行渲染的过程中,将调整后的麦克风的声音与渲染后的3D游戏画面进行同步。Step S907, in the process of rendering the 3D game screen, synchronizing the adjusted sound of the microphone with the rendered 3D game screen.
具体地,所述移动终端100还包括至少2个不同位置的麦克风装置,在上述将游戏画面由2D映射成3D的过程中,根据麦克风装置空间位置的变化,相应的改变各个麦克风装置的声音,进而营造出立体声效果。而在调用GPU对所述3D游戏画面进行渲染的过程中,将调整后的麦克风的声音与渲染后的3D游戏画面进行同步,以让用户有更好的体验。Specifically, the
通过上述步骤S901-S907,本发明所提出的2D游戏的渲染方法,能够根据麦克风装置空间位置的变化,相应的改变各个麦克风装置的声音,进而营造出立体声效果,且在调用GPU对所述3D游戏画面进行渲染的过程中,将调整后的麦克风的声音与渲染后的3D游戏画面进行同步,以让用户有更好的体验。Through the above steps S901-S907, the 2D game rendering method proposed by the present invention can change the sound of each microphone device correspondingly according to the change of the spatial position of the microphone device, thereby creating a stereo effect, and calling the GPU for the 3D game During the rendering of the game screen, the adjusted sound of the microphone is synchronized with the rendered 3D game screen, so that the user can have a better experience.
上述本发明实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the above embodiments of the present invention are for description only, and do not represent the advantages and disadvantages of the embodiments.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM/RAM、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本发明各个实施例所述的方法。Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general-purpose hardware platform, and of course also by hardware, but in many cases the former is better implementation. Based on such an understanding, the essence of the technical solution of the present invention or the part that contributes to the prior art can be embodied in the form of software products, and the computer software products are stored in a storage medium (such as ROM/RAM, disk, CD) contains several instructions to make a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in various embodiments of the present invention.
以上仅为本发明的优选实施例,并非因此限制本发明的专利范围,凡是利用本发明说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本发明的专利保护范围内。The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the description of the present invention and the contents of the accompanying drawings, or directly or indirectly used in other related technical fields , are all included in the scope of patent protection of the present invention in the same way.
Claims (8)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710754745.0A CN107913519B (en) | 2017-08-29 | 2017-08-29 | 2D game rendering method and mobile terminal |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201710754745.0A CN107913519B (en) | 2017-08-29 | 2017-08-29 | 2D game rendering method and mobile terminal |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN107913519A CN107913519A (en) | 2018-04-17 |
| CN107913519B true CN107913519B (en) | 2022-11-04 |
Family
ID=61898745
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201710754745.0A Expired - Fee Related CN107913519B (en) | 2017-08-29 | 2017-08-29 | 2D game rendering method and mobile terminal |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN107913519B (en) |
Families Citing this family (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN109343837A (en) * | 2018-09-12 | 2019-02-15 | Oppo广东移动通信有限公司 | Game rendering method and related equipment |
| CN109701275B (en) * | 2018-12-11 | 2022-04-22 | 北京像素软件科技股份有限公司 | Operation interaction method and device based on network game shadow role |
| CN113426113B (en) * | 2021-07-05 | 2024-06-25 | 未来科技(襄阳)有限公司 | 3D game starter and 3D starting method of 2D game |
Family Cites Families (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| KR101501592B1 (en) * | 2012-08-31 | 2015-03-11 | 연세대학교 산학협력단 | A method for stereoscopic rendering by producing a stereoscopic sprite and an apparatus for the same |
| KR101911906B1 (en) * | 2012-09-26 | 2018-10-25 | 에스케이플래닛 주식회사 | Apparatus for 3D object creation and thereof Method |
-
2017
- 2017-08-29 CN CN201710754745.0A patent/CN107913519B/en not_active Expired - Fee Related
Also Published As
| Publication number | Publication date |
|---|---|
| CN107913519A (en) | 2018-04-17 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN109215007B (en) | Image generation method and terminal equipment | |
| WO2019174628A1 (en) | Photographing method and mobile terminal | |
| EP3731506B1 (en) | PICTURE DISPLAY METHOD AND MOBILE DEVICE | |
| CN112363785A (en) | Terminal display method, terminal and computer readable storage medium | |
| WO2016173427A1 (en) | Method, device and computer readable medium for creating motion blur effect | |
| CN107977144A (en) | A kind of screenshotss processing method and mobile terminal | |
| US9760998B2 (en) | Video processing method and apparatus | |
| CN108513671B (en) | Display method and terminal for 2D application in VR equipment | |
| CN107979667B (en) | Dual-screen display method, mobile terminal and computer-readable storage medium | |
| CN108682040A (en) | A kind of sketch image generation method, terminal and computer readable storage medium | |
| CN108320263A (en) | A kind of method, device and mobile terminal of image procossing | |
| CN106127829A (en) | A processing method, device and terminal for augmented reality | |
| CN107730460A (en) | A kind of image processing method and mobile terminal | |
| CN107153500B (en) | Method and equipment for realizing image display | |
| CN107913519B (en) | 2D game rendering method and mobile terminal | |
| CN108762709B (en) | Terminal control method, terminal and computer readable storage medium | |
| CN110908517B (en) | Image editing method, device, electronic device and medium | |
| CN108595070A (en) | A kind of icon display control method and terminal | |
| CN108845785A (en) | A kind of display methods and terminal | |
| CN109683778B (en) | Flexible screen control method and device and computer readable storage medium | |
| CN113457143A (en) | Video game fusion processing method and device and computer readable storage medium | |
| CN110493451B (en) | Data transmission method, electronic equipment and terminal | |
| CN109842722B (en) | Image processing method and terminal equipment | |
| CN112532786B (en) | Image display method, terminal device, and storage medium | |
| CN115469955A (en) | A real-time background blurring processing method, device and computer-readable storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| TA01 | Transfer of patent application right |
Effective date of registration: 20180601 Address after: 518000 Room 201, building A, No. 1, Qian Wan Road, Qianhai Shenzhen Hong Kong cooperation zone, Shenzhen, Guangdong (Shenzhen Qianhai business secretary Co., Ltd.) Applicant after: ONECONNECT FINANCIAL TECHNOLOGY Co.,Ltd. (SHANGHAI) Address before: 200030 Xuhui District, Shanghai Kai Bin Road 166, 9, 10 level. Applicant before: ONECONNECT FINANCIAL TECHNOLOGY Co.,Ltd. (SHANGHAI) |
|
| TA01 | Transfer of patent application right | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20221104 |
