经验大分享:TheGeneofBitizens

简介: 经验大分享:TheGeneofBitizens

1. Summary

This document is about the general idea of the architectural design of the Bitizens game, the detail logic in the code may be more complicated than what is documented here, and also the actual logic may be somewhat different from what is documented here. For more details and the acurate logic, please refer to the code. Thx!

2. Face

2.1. UI

2.2. Data Structure

The actual data structure is far more complicated than what is demoed below, for details, please refer to the code in the project.

{

"GenePool": {

"Face": {

"00": "3DModel00",

"01": "3DModel01",

"02": "3DModel02"

},

"Eyes": {

"00": {

"Eye_L_1": { "PX": 0, "PY": 0, "PZ": 0 },

"Eye_R_1": { "PX": 0, "PY": 0, "PZ": 0 },

"Eye_L_2": { "PX": 0, "PY": 0, "PZ": 0 },

     ... ...

},

"01": {

},

   ... ...

},

"Nose": { },

"Mouth": { },

"Eyebrow": { },

"Cheeks": { },

"Jaw": { }//代码效果参考:http://www.ezhiqi.com/bx/art_5881.html,

"Chin": { }

}

}

2.3. Description

The data structure is in JSON format.

2.3.1. Face DNA

Each face part has a gene, which is a 2-digit number, so we have 100 possibilities for each part (Considering that we can have more than one 3D models, the number of possibilities for each face part is actually "100 x the number of models"). The whole DNA for an avatar face is a combination of each gene from each face part.

Face DNA is a 30-digit number, we may use the first say 18 digits for the moment, and the left 12 digits will be reserved for future extension. The last 12 digits that are not used should be placed with twelve 0s.

So the DNA for an avatar face may be like: 000201902214296466 + twelve 0s

Face00Eyes02Nose01Mouth90Eyebrow22Cheeks14Jaw29Chin64Brow66 + twelve 0s

2.3.2. Gene Pool

Our artists need to list out all the possible genes for each face part in a data file using the structure above.

On the UI, each gene for a face part is represented by an icon. We can name the image file of an icon to be “face part name plus a 2-digit”. For example: Nose99.jpg

"Nose_2": The name of a specific bone.

"PX", "PY", "PZ": XYZ values for each axis of the bone position.

"SX", "SY", "SZ": XYZ values for each axis of the bone scale.

2.3.3. Main Workflow

Loading

○ User hasn’t created an avatar before

First we generate a random DNA number, then find the corresponding settings in our gene pool file. Finally we use the settings to update the UI and the avatar.

Note: Say we may have only 7 different types of noses as designed (even though 2 digits allow 100 possible options), and suppose that the 2 digits generated randomly for the nose gene are 83. To map 83 to a nose type, we do 83 % 7 = 6. So this avatar would have the 06 gene for the nose.

○ User has created an avatar before

First, we access Blockchain for the data of the current user, and then use the DNA number from Blockchain to find the corresponding settings in our gene pool file. Finally we use the settings to update the UI and the avatar.

Customizing

When user clicks on a face part icon on the UI, first we find the icon name, say Nose09.jpg, then we strip out the gene number 09, finally we look up the gene pool file to find the 09 gene data, and use the data to update the corresponding bones in the face model.

Save

Find out all the gene numbers for all face parts user has selected on the UI, then combine them to be a complete DNA and save it on Blockchain.

2.4. Whole DNA

The whole DNA of an avatar will be a 76-digit number, which consists of 4 parts: Face DNA, Body DNA, Skin DNA, Gender DNA.

DNA of an avatar will be stored on Blockchain.

2.4.1. Face DNA

Face DNA is a x-digit number.

2.4.2. Body DNA

Body DNA is a y-digit number.

2.4.3. Skin DNA

Skin DNA is a z-digit number.

2.4.4. Gender DNA

Gender DNA is represented by 1-digit. 0 represents female, 1 represents male.

3. MVC Pattern

andycja

相关文章
|
6天前
经验大分享:OpenFOAM中的边界条件(一)
经验大分享:OpenFOAM中的边界条件(一)
18 0
经验大分享:OpenFOAM中的边界条件(一)
|
4天前
经验大分享:sdfdsf
经验大分享:sdfdsf
|
5天前
|
JSON 网络协议 Linux
经验大分享:serval
经验大分享:serval
|
6天前
|
机器学习/深度学习
经验大分享:Sicily1153
经验大分享:Sicily1153
|
4天前
|
图形学
技术经验解读:【学习笔记】恶梦射手NightmaresShooter(一)
技术经验解读:【学习笔记】恶梦射手NightmaresShooter(一)
|
2月前
|
安全 前端开发 开发者
干货!6个方面,32条总结教你提升职场经验
本文提出了职场成长的建议,包括不要依赖“新人”身份,撰写技术博客促进成长,阅读《金字塔原理》和《高效能人士的七个习惯》等书籍,积极解决问题,不沉迷于忙碌,长远看待得失,拓宽知识领域,保持好奇和热爱。日常工作要注重质量,主动规划,良好沟通,避免传播负面情绪,理解和尊重上级,学会被管理。培养定义问题的能力,以价值、结果和问题为导向思考,控制情绪,以及成为他人的追随者而非仅仅管理者。
|
小程序 程序员 Windows
学习经验
写写自己的学习经验
|
测试技术 Linux Go
|
存储 算法 Ubuntu
学习 C++ 的一点浅薄经验
工作所需,需要学习下 C++,今天就谈一下自己是怎么快速学习 C++,并且在工作中实际上手开发的,希望能够给大家一些启发。
132 0