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