exports api via extern “C”
Entity Clip
实体包围盒在视锥外会被剔除
Drawing
1.DrawLine
r_efx.h
tri.cpp
util
//set rendermode so that color4ub could work
gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
gEngfuncs.pTriAPI->Brightness(1.0);
gEngfuncs.pTriAPI->Begin(TRI_LINES);
gEngfuncs.pTriAPI->Color4ub(255, 255, 2, 255);
gEngfuncs.pTriAPI->Vertex3fv(arr);
gEngfuncs.pTriAPI->Color4ub(255, 255, 2, 255);
gEngfuncs.pTriAPI->Vertex3fv(pos[0]);
gEngfuncs.pTriAPI->End();
typedef struct ColoredPos
{
float pos[3];
colorVec color;
}ColoredPos_t;
如果想绘制不被遮挡的图元,目前的做法是在渲染流程判断是否在绘制V模,(引擎在绘制V模 禁用了深度检测?改变深度?)在V模的渲染流程里把buffered图元绘制出来。
Ragdoll
1.ClientRagdoll
just simulate on client side.
2.Ragdoll
this is server side ragdoll, every key bones info will send to client for rendering.
on StudioRenderer, make your custom animation code for model.
check if this is a ragdoll, if true, use data recieved from server to setup bones.
ModelRenderer
- 只在游戏进程打开时初始化一次(
void CStudioModelRenderer::Init( void )
)
GameLoop
public static void Main()
{
InitEverything();
while(!Exit)
{
ProcessInput();
#region physics update
Simulating();
Render();//physics world debug draw
#endregion
RenderEveryEntityOnList()//goldsrc render
{
SetupBones()
{
#region physics setup bones
if(currentEntity.isPlayer||isDead)
SetupBonesPhysically();//call physics module set the player pose
#endregion
};
DrawMeshs();
...
};
}
}
DebugDraw
本系统的debugDraw进一步地封装了一次,实现BufferedDraw。BufferedDraw将多次绘制调用缓存起来,最后用在具体的DrawContext绘制出来。
Hosting CLR
need a better way to host clr
metahost
mscoree
MotionState与移动物体
Bullet在刚体 进入simulation之前调用MotionState的getWorldTransform设置刚体的初始位置(实际上是在构造刚体时new RigidBody(rbInfo))
Bullet还使用MotionState的getWorldTransform获取kinematic body的transform来更新它在物理世界中的位置
Bullet使用MotionState的setWorldTransform设置你的渲染物体的transform(在每一帧物理演算后,渲染之前)
/
If you plan to animate or move static objects, you should flag them as kinematic. Also disable the
sleeping/deactivation for them during the animation. This means Bullet dynamics world will get the
new worldtransform from the btMotionState every simulation frame.
body->setCollisionFlags( body->getCollisionFlags() |
btCollisionObject::CF_KINEMATIC_OBJECT);
body->setActivationState(DISABLE_DEACTIVATION);
/
刚体只在创建时使用MotionState的GetWorldTransform来设置刚体的世界变换,现在想让刚体在后续的操作中还能使用MotionState的GetWorldTransform来设置刚体的世界变换。
不行的话就手动设置刚体变换
//使用MotionState设置刚体的世界变换
Matrix boneTrans = Matrix.Identity;
var motionState = (Body.MotionState as BoneMotionState);
motionState.BoneTransform=boneTrans;
Body.WorldTransform = motionState.WorldTransform;