MMORPG大型游戏设计与开发(客户端架构 part3 of vegine)
无论在何处在什么地方,我们都或多或少的接触到数学知识。特别是在客户端中,从打开界面的那一刻起就有太多与数学扯上的关联,如打开窗口的大小,窗口的位置,窗口里面的元件对象,以及UI的坐标等等。而在进入游戏之后,不仅有这些坐标,还有了世界的坐标,以及场景坐标,还有粒子对象的各种属性值。但为什么要扩展ogre的数学库呢?就让我们看看有哪些类型的吧。
CODE
文件math/base.h
/**
* PAP Engine ( -- )
* $Id math.h
* @link -- for the canonical source repository
* @copyright Copyright (c) 2013-2014 viticm( viticm@126.com )
* @license
* @user viticm<viticm@126.com/viticm.ti@gmail.com>
* @date 2014-3-12 11:15:08
* @uses the base config macros and defines, also with system include
*/
#ifndef VENGINE_MATH_BASE_H_
#define VENGINE_MATH_BASE_H_ #include "vengine/config.h" namespace vengine_math { namespace base { struct VENGINE_API twofloat_vector_t {
public:
inline twofloat_vector_t& operator = (const twofloat_vector_t& vector) {
x = vector.x;
y = vector.y;
return *this;
} inline bool operator == (const twofloat_vector_t& vector) const {
return (x == vector.x && y == vector.y);
} inline bool operator != (const twofloat_vector_t& vector) const {
return ( x != vector.x || y != vector.y );
} inline twofloat_vector_t operator +
(const twofloat_vector_t& vector) const {
twofloat_vector_t sum;
sum.x = x + vector.x;
sum.y = y + vector.y;
return sum;
} inline twofloat_vector_t operator -
(const twofloat_vector_t& vector) const {
twofloat_vector_t diff;
diff.x = x - vector.x;
diff.y = y - vector.y;
return diff;
} inline twofloat_vector_t operator * (float scalar ) const {
twofloat_vector_t prod;
prod.x = scalar * x;
prod.y = scalar * y;
return prod;
} inline friend twofloat_vector_t operator *
(float scalar, const twofloat_vector_t& vector) {
twofloat_vector_t prod;
prod.x = scalar * vector.x;
prod.y = scalar * vector.y;
return prod;
} inline float length() const;
float normalise(float aimlength = 1.0f);
public:
twofloat_vector_t() : x(0.0f), y(0.0f) {}
twofloat_vector_t(float _x, float _y) : x(_x), y(_y) {}
public:
float x;
float y;
}; //tow int32_t vector struct
struct VENGINE_API twoint_vector_t {
public:
twoint_vector_t() : x(), y() {}
twoint_vector_t(int32_t _x, int32_t _y) : x(_x), y(_y) {}
public:
int32_t x;
int32_t y;
}; struct VENGINE_API threefloat_vector_t {
public:
inline threefloat_vector_t& operator =
(const threefloat_vector_t& vector) {
x = vector.x;
y = vector.y;
z = vector.z;
return *this;
} inline bool operator == ( const threefloat_vector_t& vector) const {
return (x == vector.x && y == vector.y && z == vector.z);
} inline bool operator != ( const threefloat_vector_t& vector ) const {
return (x != vector.x || y != vector.y || z != vector.z);
} inline threefloat_vector_t operator +
(const threefloat_vector_t& vector) const {
threefloat_vector_t sum;
sum.x = x + vector.x;
sum.y = y + vector.y;
sum.z = z + vector.z;
return sum;
} inline threefloat_vector_t operator -
(const threefloat_vector_t& vector) const {
threefloat_vector_t diff;
diff.x = x - vector.x;
diff.y = y - vector.y;
diff.z = z - vector.z;
return diff;
} inline threefloat_vector_t operator * (const float& mult) const {
threefloat_vector_t vector;
vector.x = x * mult;
vector.y = y * mult;
vector.z = z * mult;
return vector;
} inline float length() const; float normalise(float aimlength = 1.0f); public:
threefloat_vector_t() : x(0.0f), y(0.0f), z(0.0f) {}
threefloat_vector_t(float _x, float _y, float _z) : x(_x), y(_y), z(_z) {}
public:
float x;
float y;
float z;
}; struct VENGINE_API threeint_vector_t {
public:
threeint_vector_t() : x(), y(), z() {}
threeint_vector_t(int32_t _x, int32_t _y, int32_t _z) :
x(_x), y(_y), z(_z) {}
public:
int32_t x;
int32_t y;
int32_t z;
}; struct VENGINE_API floatray {
public:
threefloat_vector_t origin;
threefloat_vector_t direction;
}; }; //namespace base }; //namespace vengine_math #endif //VENGINE_MATH_BASE_H_
总结
从上面的代码中不难看出,扩展的数学库将二维坐标、三维坐标,以整型与浮点的形式进行了结构体的封装,而这些正是在3D游戏中经常用到的各种坐标数据类型。floatray为最后一个封装,是屏幕射线的结构,一个是起点坐标,一个是方向的坐标,两个坐标组成了一条线。学习过立体几何的都应该知道,在点与点之间这条直线自然就确定了一个方向。
这两节都讲的比较简单,接下来会讲一下客户端的性能接口模块,其实性能接口就是在引擎接口中实现了的,我们下节再说。
MMORPG大型游戏设计与开发(客户端架构 part3 of vegine)的更多相关文章
- MMORPG大型游戏设计与开发(客户端架构 part8 of vegine)
脚本模块是游戏设计中争论比较多的话题,那是因为作为脚本本身所带来的利弊.其实这都无关紧要,取舍是人必须学会的一项技能,如果你不会取舍那么就让趋势给你一个满意的答复.自从魔兽世界以及传奇(世界)问世以来 ...
- MMORPG大型游戏设计与开发(概述)updated
1.定义 MMORPG,是英文Massive(或Massively)Multiplayer Online Role-PlayingGame的缩写,即大型多人在线角色扮演游戏. 2.技术与知识 在这系列 ...
- MMORPG大型游戏设计与开发(UI SYSTEM SHOW)
接下来一段时间,这些文件可能不再更新,期间我会学习和掌握一些前端知识.虽然我非常欣赏剑侠网络版叁和九阴真经的画面,但是那是一个庞大的游戏引擎,一般人是无法窥伺的,除非你是天才而且要拥有机器毫无中断的毅 ...
- MMORPG大型游戏设计与开发(服务器 游戏场景 核心详述)
核心这个词来的是多么的高深,可能我们也因为这个字眼望而却步,也就很难去掌握这部分的知识.之所以将核心放在最前面讲解,也可以看出它真的很重要,希望朋友们不会错过这个一直以来让大家不熟悉的知识,同我一起进 ...
- MMORPG大型游戏设计与开发(游戏服务器 游戏场景 概述 updated)
我们在玩游戏的时候,我们进入游戏后第一眼往往都是看到游戏世界中的场景,当然除了个别例外,因为那些游戏将游戏场景隐藏了起来,如文字游戏中的地点一样.既然我们接触了游戏世界的核心,那么作为核心的场景又包括 ...
- MMORPG大型游戏设计与开发(客户端架构 part12 of vegine)
在游戏中的交互过程中输入是一个必不可少的过程,比如登陆的时候需要用户输入用户名与密码,就算是单机游戏很多时候也要求用户输入一个用户名作为存档的依据.网络游戏中没有了输入,只用鼠标来交互是不切实际的,因 ...
- MMORPG大型游戏设计与开发(客户端架构 part2 of vgui)
这一节我将讲解vgui的基础系统部分,也是该库提供给外部使用的一些重要接口.作为UI部分比较重要的部分,该节有着至关重要的部分,如果没有看到上一节内容,请留意下面的连接.我们现在可以猜想一下在客户端U ...
- MMORPG大型游戏设计与开发(客户端架构 part16 of vegine)
由于近来比较忙碌和有些困倦的原因,所以关于这部分的文章没有及时更新,一句话:让朋友们久等了!今天所讲的是客户端vengine(微引擎)中最后一个部分,就像上节所说,这一部分的内容比较多.可能有些朋友看 ...
- MMORPG大型游戏设计与开发(客户端架构 part9 of vegine)
时间在人们的生活中是多么重要的东西,如果打乱了时间,不知道这个时间会成什么样子.在客户端中,自然也有时间模块,因为不同的时间可能会处理不同的事情,特别是在追求高度自由化的同时,时间也成为了一个很重要的 ...
- MMORPG大型游戏设计与开发(客户端架构)
首先为所有等待的朋友说一声歉意,实在让大家等的太久.客户端的设计本来就是一个大的工程,而且工作的关系,也没有太多时间在这方面做研究.不过在私下有空的时间,我还是继续着这方面的研究,很遗憾没有用期望的o ...
随机推荐
- Bootstrap源码分析之dropdown
源码分析: Dropdowns.scss:下拉框模块 Javascripts/bootstrap/dropdown.js:实现下拉框响应 实现功能及原理: 下拉选项卡,默认不能实现显示选中项的功能 原 ...
- 优秀案例:12个精美的设计工作室 & 设计公司网站
如果你正在为自己的作品集网站设计寻找灵感,那么学习设计机构 & 设计公司的网站是如何制作的是一个良好的开端.在这篇稳重,我们已经聚集了一组设计机构的优秀作品集网站,你可以借鉴很多设计理念.当你 ...
- Ubuntu 各版本代号简介
起名字是件伤脑筋的事,但是程序猿们似乎最喜欢干伤脑筋的活.Android 的每个版本都有个甜点的别名,而 Ubuntu ,每个版本都有一个更为特色的名字,这个名字由一个形容词和一个动物名称组成,并且, ...
- python任务执行之线程,进程,与协程
一.线程 线程为程序中执行任务的最小单元,由Threading模块提供了相关操作,线程适合于IO操作密集的情况下使用 #!/usr/bin/env python # -*- coding:utf-8 ...
- 导入CSV格式的数据
导入CSV格式的数据 (参见http://dev.mysql.com/doc/refman/5.6/en/load-data.html) 1.数据库表(st_pptn_r) CREATE TABLE ...
- Java解析Soap XML
package com.jstrd.tipstock.webservice.jt.base; import java.io.ByteArrayInputStream; import java.util ...
- RxJava 和 RxAndroid 三(生命周期控制和内存优化)
rxjava rxandroid 赵彦军 前言:对Rxjava.Rxandroid不了解的同学可以先看看 RxJava 和 RxAndroid RxJava 和 RxAndroid 二(操作符的使用) ...
- 在Asp.net MVC使用jqGrid--代码少点再少点
本示例显示了如何动态生成前端jqGrid代码,一般情况仅一行代码: <%=Html.jqGrid<TestModel>(@"#jqT", "Test&q ...
- Redis客户端开发包:Jedis学习-入门
添加Jedis依赖 我们可以使用以下三种方式来添加Jedis依赖. 1.下载jar文件 从http://search.maven.org/下载最近的jedis包和Apache Commons Pool ...
- centos7 ssh 设置key认证
vi /etc/ssh/sshd_config 查找RSAAuthentication.StrictModes.PubkeyAuthentication.AuthorizedKeysFile把所在行修 ...