The Gene of Bitizens

来源:https://www.cnblogs.com/andycja/archive/2019/03/31/10631408.html
-Advertisement-
Play Games

1. Summary The document is about the general idea of the architecture design of the Bitizens game, the detail logic is more complicated than what is d ...


 1.          Summary

The document is about the general idea of the architecture design of the Bitizens game, the detail logic is more complicated than what is documented here, and the actual logic will be somewhat different from what is documented here. For details and the acurate logic, please refer to the code.

 2.          Face

               2.1.          UI

 

               2.2.          Data Structure

The actual 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": {

           },

           "02": {

           }

       },

       "Nose": {

           "00": {

               "Nose": { "SX": 0, "SY": 0, "SZ": 0 },

               "Nose_1": { "SX": 0, "PY": 0, "PZ": 0 },

               "Nose_2": { "SX": 0, "PY": 0, "PZ": 0 },

               "Nose_3": { "SX": 0, "PY": 0, "PZ": 0 }

           }

       },

       "Mouth": {

           "00": {

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

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

               "Mouth_T": { "SX": 0, "PY": 0, "PZ": 0 },

               "Mouth_B": { "SX": 0, "PY": 0, "PZ": 0 }

           }

       },

       "Eyebrow": {

           "00": {

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

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

           }

       },

       "Cheeks": {

           "00": {

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

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

           }

       },

       "Jaw": {

           "00": {

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

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

           }

       },

       "Chin": {

           "00": {

               "Chin": { "SX": 0, "PY": 0, "PZ": 0 }

           }

       },

       "Brow": {

           "00": {

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

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

           }

       }

   }

}

               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 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 above structure.

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 click 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

 

 

 

 

 


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...