游戏网络物理模型

 

挺好的文章:http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/

Age of Empires: http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php

 

 


2010年的主要是讲2011年的第四种网络模型:Authority Scheme

 

2011:GDC Networked Physics 2011  

总结:

网络模型:

  • Pure client/server
    • Client does not run any game logic
    • Client send input to the server
    • Server sends render stat back to client
      • Client需要记录server送过来的位置等信息,并且根据客户端时间做interpolation,来达到平滑的目的
    • 优势:
      • Simple
      • Secure
      • Late join is easy
    • 缺点
      • Round trip delay between player input and physics response
  • Client side prediction
    • Special treatment of local player object
    • Client simulates local player object ahead without waiting for server round trip
    • Server sends correctioni to client if it disagrees with client state
    • Exapmles:
      • Halo
      • Quake
      • Unreal
      • CounterStrike
      • TF2
      • Left4Dead
      • Portal 2?
    • 优势:
      • No round trip delay
      • Almost as secure as pure client/server
      • Late join is still relatively easy to implement
    • 缺点
      • Expensive to rewind and replay physics
      • Collision between player objects are poorly defined
  • Deterministic lockstep
    • Each machine runs same game code
    • Wait for input from all players before advancing to next frame
    • Rely on determinism to stay in sync
    • Examples:
      • Every RTS ever made
      • Halo COOP story mode
      • Little Big Planet(soft body physics + fluids)
      • PixelJunk Shooter2(fluuid sim)
      • Most fighting games(SF4, GGPO)
    • Physics engine must be deterministic
    • 优势
      • Only need to send player inputs
      • Handles interactions between players well
      • Everything "just works"
    • 缺点
      • Low player counts only (2-4)
      • Floating point determinism
      • Lat join can be difficult or impossible
      • Forking simulation is very expensive
  • Authority scheme
    • Split up the simulation and run parts of the world on different machines
    • Design the split to suport networking goals, eg. latency hiding, conveniene
    • Authority Rules:
      • Player Authority: Player always have authority over the object they are controlling
      • Tie-Break Authority: in areas of overlap, for grey cubes with default authority -- lowest player id wins.
      • Interaction Authority: Players take authority over objects they interact with -- effectively becoming the server for that bject, until it returns to rest and becomes grey again. This last technique hide latency for the higher player ids in areas of overlap.
    • Examples:
      • Mercenaries 2
      • Insomniac games "sync host"
      • Many Many other console games
    • Apply to physics
      • Take authority over objects you interact with. Become the server for thest objects
      • Resolve conflicts when multiple players want authority over the same object
    • 优点
      • Does not require 100% determinism
      • Does not wait for most lagged player
      • No need to rewind & replay or fork simulation to hide latency
    • 缺点
      • Trusting the client (cheating) -- Use the tech in coop game only.
      • Difficult to handle interactions between multiple players
      • Late join is difficult

How to choose?

  • 如果延迟不是问题:pure client/server, 简单
  • 如果有很多状态要发送,那么就用Deterministic lockstep,因为这种方法只要发送input即可,可以用Fork simulation来had lag
  • 如果游戏引擎本身不是deterministic的,或者有很多玩家,那么用client side prediction或者authority scheme
    • client side prediction is basically an anti-cheat measure for FPS
    • if you cannot afford it, do a COOP game with authority scheme instead, but in this case we need to validate authority physics on dedicated server.

转载于:https://www.cnblogs.com/dbbs/archive/2012/12/10/2804702.html

Physics Modelling for Game Programmers 游戏编程中的物理建模(中文删节版) 后记】 我将这本书界定成 3D 游戏开发的入门书籍,其实一直来我都有一个疑问,起初的时候我看 了很多 3D 开发方面的书籍也做了一些例子程序,但是对 3D开发还是有许多未知,自从我 见到这书以后,我终于明白我缺少的是什么了?其实就是需要一条线把我所学过的这些知识 全部串起来,反观当下无论是纸皮书还是电子书往往都是将 3D 开发分成若干块,专门讲一 块或是几块,开发是一个整体,所以我看了那么多书似乎前面还是有一层纱捅不破。 如果你是个新手,那绝对在此书会找到很多你感兴趣的东西,如果对于 DirectX 你已经足够 了解但就是不知从何开始,这本书可以整理你的思路,带你走出山谷奔向另一座高峰。 大概因为作者是一名老师的缘故,论述有些拖泥带水,文中涉及到的 c++以及 Direct3D 基 础知识我都没有翻出,我相信你轻易就能找到相应的替代品,对于 15 章和 16 章的实例分 析没有翻,我想任何具备高中物理程度的人都不难推导出这些公式,所以传言说老外的应用 科学的普及教育做得奇差,大概是真的。 本书只能作为免费传播,请勿用于商业,谢谢,最后我非常希望我的努力能换来你的赞许, 如果真是这样,那我将会很荣幸! 底层模式:HAL 和HEL(删除) 高层模式:DirectX 组件(删除) COM对象(删除) 使用DirectX 初始化 DirectX 的硬件方法 使用DirectX 向导初始化 Direct3D 使用物理建模框架初始化 Direct3D 小结(删除) 第三节:3D 编程和物理学的数学工具(删除) 三角几何(删除) 2D坐标系(删除) 3D和4D坐标系(删除) 物理单位(删除) 矢量 代码中实现的矢量:物理建模的数学库 矢量与标量的乘除法 点积 叉积 单位化矢量 投影 Direct3D 中的矢量 矩阵 特性 加法和减法 乘法和除法 矩阵相乘 转置 行列式 逆矩阵 小结(删除) 第四节:2D 变换和渲染 2D变换 主动和被动变换 平移 旋转 缩放 组合变换 变换实现:一个三角形的自旋 使用物理建模的框架 设定几何体 更新帧(Frame) 渲染帧 将所有的步骤放置到一起(删除) 小结(删除) 第五节:3D 变换和渲染 3D变换 齐次坐标 平移 缩放 旋转 3D管道 局部坐标转世界坐标 世界坐标转观察坐标 观察坐标转投影坐标 投影坐标转屏幕坐标 3D渲染 例子1:3D 自旋三角形 例子2:自旋的圆椎 小结(删除) 第六节:网格(Mesh)和 X 文件 纹理 从文件创建纹理 设定纹理 材质 装载一个网格 获取纹理和材质 渲染网格 清除网格 d3d_mesh类 载入一个网格 渲染一个网格 d3d_mesh类中的引用计数 小结(删除) 第二部分:3D 对象,运动和碰撞 第七节:动态粒子 点状粒子 一维运动力学 速度(删除) 速度的导数求法(删除) 加速度(删除) 力 2D 和 3D 运动力学(删除) 质点模型 介绍d3d_point_mass类 使用d3d_point_mass类 游戏中的质点 小结(删除) 第八节:粒子碰撞 碰撞检测 包围球 包围圆柱 包围盒 空间分隔的优化 碰撞响应 动量守恒 能量 弹性碰撞 刚性碰撞 补偿系数 2D和3D 的粒子碰撞 球的碰撞 实现 小结(删除) 第九节:刚体动力 刚体 重心 2D 刚体旋转 2D 刚体的粒子 转矩和惯性力矩 3D刚体 3D转矩 3D 的平行轴定理 主轴线 定向 3D 刚体的实现 d3d_rigid_body类 初始化 d3d_rigid_body对象 更新d3d_rigid_body对象 渲染d3d_rigid_body对象 小结(删除) 第十节:刚体碰撞 碰撞检测 粗糙近似 碰撞检测的改进 碰撞响应 线性碰撞响应 角度碰撞响应 组合碰撞响应 更新物理建模框架 小结(删除) 第十一节:重力和抛射体 牛顿万有引力法则 抛射体轨迹 抛射体运动模型 冲力与恒力之间的差异 滚动 小结(删除) 第十二节:质量与弹力系统 实现弹力所需的事 头发与马尾辫 织物 一切从周期运动开始 胡克定律 衰减周期运动 实现织物 升级质点 弹力 织物类 初始化织物 更新和渲染织物 进行调整 增加织物的表现力 小结(删除) 第十三节:水体与波纹 水体与浮力 水的特性 浮力产生的原理 求取压强和密度 运动阻力 对摩擦力的观察 粘性阻力 水体的流向 波 实现水体 低开销实现的技巧 3D水体 在水体中放置对象 为刚体增加浮力 它会浮起来吗? 小结(删除) 第三部分:3D 模拟 第十四节:为游戏开发需做的准备 重新设计物理建模的框架 简单程序的初始化 添加一个游戏类 设置高效的矩阵变换 恢复丢失的设备对象 使用质点重新定义刚体 网格原点和重心 DirectInput 介绍(删除) 初始化 DirectInput(删除) 获取键盘和鼠标输入(删除) 关闭DirectInput(删除) DirectX 中的摄像机运动(删除) 小结(删除) 第十五节:汽车,气垫船,船只以及小舟(删除整章) 汽车 能量,力,加速度和摩擦 车辆的空气阻力 制动 车辆拐弯 实现一个基本的车辆模型 气垫船和无引力飞船 气垫船是如何工作的 气垫船的空气阻力 气垫船拐弯 船只和小舟 船只和小舟的包围边界 船体容积的计算 船只和小舟的续航能力 质量和有效质量 阻力和小舟 空气阻力 流速和波 小结 第十六节:飞机和宇宙飞船(删除整章) 飞行模拟的简单方法 低空飞行或是无物理影响 实现一个简单的飞行模拟 与飞机相关的物理学 飞机的主要部件 基本的动力 飞机建模:具备适合的地点和动力 与宇宙飞船相关的物理学 宇宙中的空战 火箭 月球着陆器 其他行星已知的物理学 其他行星待论证的物理学 结束语(删除) 附录 A 术语(删除) 附录 B C++的一个简明介绍(删除) 附录 C window编程基础(删除) 索引(删除)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值