• The Gene of Bitizens


     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": {  },

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

     

     

     

  • 相关阅读:
    win32com操作word(3):导入VBA常量
    win32com操作word(2):常用用法
    win32com操作word(1):几个重要的对象(28.35)
    文件操作:os模块与os.path模块
    python上下文管理器
    OpenStack基础知识-单元测试工具介绍
    python测试模块-pytest介绍
    Python包管理工具setuptools详解及entry point
    OpenStack基础知识-项目打包的步骤
    OpenStack基础知识-打包知识点
  • 原文地址:https://www.cnblogs.com/andycja/p/10631408.html
Copyright © 2020-2023  润新知