MMORPG大型游戏设计与开发(客户端架构 part3 of vegine)

时间:2021-12-24 20:19:26

无论在何处在什么地方,我们都或多或少的接触到数学知识。特别是在客户端中,从打开界面的那一刻起就有太多与数学扯上的关联,如打开窗口的大小,窗口的位置,窗口里面的元件对象,以及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)的更多相关文章

  1. MMORPG大型游戏设计与开发(客户端架构 part8 of vegine)

    脚本模块是游戏设计中争论比较多的话题,那是因为作为脚本本身所带来的利弊.其实这都无关紧要,取舍是人必须学会的一项技能,如果你不会取舍那么就让趋势给你一个满意的答复.自从魔兽世界以及传奇(世界)问世以来 ...

  2. MMORPG大型游戏设计与开发(概述)updated

    1.定义 MMORPG,是英文Massive(或Massively)Multiplayer Online Role-PlayingGame的缩写,即大型多人在线角色扮演游戏. 2.技术与知识 在这系列 ...

  3. MMORPG大型游戏设计与开发(UI SYSTEM SHOW)

    接下来一段时间,这些文件可能不再更新,期间我会学习和掌握一些前端知识.虽然我非常欣赏剑侠网络版叁和九阴真经的画面,但是那是一个庞大的游戏引擎,一般人是无法窥伺的,除非你是天才而且要拥有机器毫无中断的毅 ...

  4. MMORPG大型游戏设计与开发(服务器 游戏场景 核心详述)

    核心这个词来的是多么的高深,可能我们也因为这个字眼望而却步,也就很难去掌握这部分的知识.之所以将核心放在最前面讲解,也可以看出它真的很重要,希望朋友们不会错过这个一直以来让大家不熟悉的知识,同我一起进 ...

  5. MMORPG大型游戏设计与开发(游戏服务器 游戏场景 概述 updated)

    我们在玩游戏的时候,我们进入游戏后第一眼往往都是看到游戏世界中的场景,当然除了个别例外,因为那些游戏将游戏场景隐藏了起来,如文字游戏中的地点一样.既然我们接触了游戏世界的核心,那么作为核心的场景又包括 ...

  6. MMORPG大型游戏设计与开发(客户端架构 part12 of vegine)

    在游戏中的交互过程中输入是一个必不可少的过程,比如登陆的时候需要用户输入用户名与密码,就算是单机游戏很多时候也要求用户输入一个用户名作为存档的依据.网络游戏中没有了输入,只用鼠标来交互是不切实际的,因 ...

  7. MMORPG大型游戏设计与开发(客户端架构 part2 of vgui)

    这一节我将讲解vgui的基础系统部分,也是该库提供给外部使用的一些重要接口.作为UI部分比较重要的部分,该节有着至关重要的部分,如果没有看到上一节内容,请留意下面的连接.我们现在可以猜想一下在客户端U ...

  8. MMORPG大型游戏设计与开发(客户端架构 part16 of vegine)

    由于近来比较忙碌和有些困倦的原因,所以关于这部分的文章没有及时更新,一句话:让朋友们久等了!今天所讲的是客户端vengine(微引擎)中最后一个部分,就像上节所说,这一部分的内容比较多.可能有些朋友看 ...

  9. MMORPG大型游戏设计与开发(客户端架构 part9 of vegine)

    时间在人们的生活中是多么重要的东西,如果打乱了时间,不知道这个时间会成什么样子.在客户端中,自然也有时间模块,因为不同的时间可能会处理不同的事情,特别是在追求高度*化的同时,时间也成为了一个很重要的 ...

  10. MMORPG大型游戏设计与开发(客户端架构)

    首先为所有等待的朋友说一声歉意,实在让大家等的太久.客户端的设计本来就是一个大的工程,而且工作的关系,也没有太多时间在这方面做研究.不过在私下有空的时间,我还是继续着这方面的研究,很遗憾没有用期望的o ...

随机推荐

  1. KnockoutJS 3&period;X API 第三章 计算监控属性&lpar;1&rpar; 使用计算监控属性

    计算监控属性(Computed Observables) 如果你有一个监控属性firstName,和另一个lastName,你要显示的全名?可以使用计算监控属性来实现-它依赖于一个或多个其他监控属性, ...

  2. Python的平凡之路(3)

     一.函数基本语法及特性 面向对象:(华山派)—类 —class 面向过程:(少林派)—过程 —df 函数式编程:逍遥派    —函数— df 一般的,在一个变化过程中,如果有两个变量x和y,并且对于 ...

  3. Application&comma;Session&comma;Cookie&comma;ViewState和Cache区别

    在ASP.NET中,有很多种保存信息的内置对象,如:Application,Session,Cookie,ViewState和Cache等.下面分别介绍它们的用法和区别. 方法 信息量大小 作用域和保 ...

  4. Xmanager连接CentOS的远程桌面

    本文主要介绍通过Xmanager连接CentOS远程桌面时,在CentOS系统上需要做的一些配置. 1. Xmanager简介 Xmanager是一个运行于 Windows平台上的高性能的X Serv ...

  5. 【枚举&plus;贪心】【ZOJ3715】【Kindergarten Electiond】

    题目大意: n 个人 在选取班长 1号十分想当班长,他已经知道其他人选择了谁,但他可以贿赂其他人改选他,问贿赂的最小值 ps.他自己也要投一个人 要处理一个问题是,他自己投谁 其实这个问题在这种局面下 ...

  6. undo&lowbar;retention:确定最优的撤销保留时间

    使用下面的公式来计算undo_retention参数的值: undo_retention=undo size/(db_block_size * undo_block_per_sec) 可以通过提交下面 ...

  7. 【Flex】读取本地XML,然后XML数据转成JSON数据

    干了一年H5,最近被要求写编辑器,Electron等级还不够,写不了,只有重新拿起as3,用flex,最近写到数据表编辑模块,有这部分功能,基本完成 . package utils { /** * 模 ...

  8. 白帽子之路首章:Footprinting&comma; TARGET ACQUISITION

    *Disclaimer: All materials provided on this blog are for educational purposes only. The author and o ...

  9. 201521123010 《Java程序设计》第8周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 2. 书面作业 本次作业题集集合 ①List中指定元素的删除(题目4-1) 1.1 实验总结 A: 这道题是老 ...

  10. zabbix&lowbar;agent YUM源配置

    wget http://repo.zabbix.com/zabbix/3.0/rhel/5/x86_64/zabbix-release-3.0-1.el5.noarch.rpm rpm -ivh za ...