second life代码初研究

second life这种非拘束的 允许客户上传物体从而建立一个庞大的虚拟世界的游戏是很有前途的.这里开始初步分析其代码.其client已经go public

second life 的client 端的通信代码是包装在
llmessage项目里的各个类
然后如果是命令的话
在不同的实际功能的类里包含了不同的 packmessage 与unpackmessage的方法,
要进行同步对象的话则包装了pack 和unpack的方法

其中最重要的人物是通过agent类来进行管理的在 newview项目里的llagent类.
这个是客户自身可以操作的类

// forward declarations

//

class LLAgent : public LLObservable
{

 

}
从agent的teleportViaLandmark可以知道server是怎么存储和管理不同的
场景的.每个场景都有一个uuid

// Landmark ID = LLUUID::null means teleport home
void LLAgent::teleportViaLandmark(const LLUUID& landmark_id)
{
 LLViewerRegion *regionp = getRegion();
 if(regionp && teleportCore())
 {
  LLMessageSystem* msg = gMessageSystem;
  msg->newMessageFast(_PREHASH_TeleportLandmarkRequest);
  msg->nextBlockFast(_PREHASH_Info);
  msg->addUUIDFast(_PREHASH_AgentID, getID());
  msg->addUUIDFast(_PREHASH_SessionID, getSessionID());
  msg->addUUIDFast(_PREHASH_LandmarkID, landmark_id);
  sendReliableMessage();
 }
}


//对于大量的资源文件是通过一个独立的虚拟文件系统vfs来操作的.这里
每个image通过一个独立的uuid来表示.在这里上层系统从vfs里得到要操作的image

//BOOL LLViewerImage::loadLocalImage(const LLUUID &image_id)
{
 LLMemType mt1(LLMemType::MTYPE_APPFMTIMAGE);
 
 // first look for this image in the static VFS
 LLAssetType::EType asset_type = LLAssetType::AT_NONE;
 // Try TGA first
 if (gStaticVFS->getExists(image_id, LLAssetType::AT_TEXTURE_TGA))
 {
  asset_type = LLAssetType::AT_TEXTURE_TGA;
  //RN: force disable discards for TGA files because they can't decode at different quality levels
  dontDiscard();
  mDataCodec = IMG_CODEC_TGA;
 }
 else if (gStaticVFS->getExists(image_id, LLAssetType::AT_TEXTURE))
 {
  // then try for a J2C version
  asset_type = LLAssetType::AT_TEXTURE;
  mDataCodec = IMG_CODEC_J2C;
  LLImageJ2C* imagej2c = new LLImageJ2C();
  setFormattedImage(imagej2c);
 }

 if (asset_type != LLAssetType::AT_NONE)
 {
  S32 size = gStaticVFS->getSize(image_id, asset_type);
  U8* buffer = new U8[size];
  BOOL success = LLVFSThread::sLocal->readImmediate(gStaticVFS, image_id, asset_type, buffer, 0, size);

  if (!success)
  {
   llwarns << "loadLocalImage() - vfs read failed" << llendl;
   return FALSE;
  }

  mInStaticVFS = TRUE;
  mFullyLoaded = TRUE;
  setNeedsDecode(TRUE); // Loading a local image
  mID = image_id;
  setDecodeData(buffer, size);
  mTotalBytes = size;
  mLastBytesProcessed = size;
  return TRUE;
 }

 return FALSE;
}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值