feat:Molecule-json #8

Merged
Clement merged 10 commits from feat/Molecule-json into develop 2024-01-12 10:38:06 +00:00
18 changed files with 355 additions and 2 deletions

8
Assets/script.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7f609c39b51d9e447a6a4a5964011b44
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/script/Atom.cs Normal file
View File

@ -0,0 +1,9 @@
[System.Serializable]
public class Atom
{
// nom de l'atom
public string element;
// coordonée XYZ
public float[] geometry;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9d3069c87e06b0c4c9a88c0695461936
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

9
Assets/script/Bond.cs Normal file
View File

@ -0,0 +1,9 @@
[System.Serializable]
public class Bond
{
// numéro des atome lier
public int[] atoms;
// nombre de liaison
public int order;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5ee91233baa5bef4288717efd423d4df
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,98 @@
{
"molecules":[
{
"name": "Dioxygène",
"formula": "O2",
"atoms": [
{
"element": "O",
"geometry": [0.0, 0.0, 0.0]
},
{
"element": "O",
"geometry": [1.2, 0.0, 0.0]
}
],
"bonds": [
{"atoms": [0, 1], "order": 2}
],
"properties": {
"molecularMass": 32.0,
"meltingPoint": -218.8,
"boilingPoint": -183.0
}
},
{
"name": "Ozone",
"formula": "O3",
"atoms": [
{"element": "O", "geometry": [0.0, 0.0, 0.0]},
{"element": "O", "geometry": [0.7, 0.0, 0.0]},
{"element": "O", "geometry": [1.4, 0.0, 0.0]}
],
"bonds": [
{"atoms": [0, 1], "order": 1},
{"atoms": [1, 2], "order": 1}
],
"properties": {
"molecularMass": 47.9982,
"meltingPoint": -192.5,
"boilingPoint": -110.0
}
},
{
"name": "Dioxyde de carbone",
"formula": "CO2",
"atoms": [
{"element": "C", "geometry": [0.0, 0.0, 0.0]},
{"element": "O", "geometry": [1.2, 0.0, 0.0]},
{"element": "O", "geometry": [-1.2, 0.0, 0.0]}
],
"bonds": [
{"atoms": [0, 1], "order": 2},
{"atoms": [0, 2], "order": 2}
],
"properties": {
"molecularMass": 44.0095,
"meltingPoint": -56.6,
"boilingPoint": -78.5
}
},
{
"name": "Butane",
"formula": "C4H10",
"atoms": [
{"element": "C", "geometry": [0.0, 0.0, 0.0]},
{"element": "C", "geometry": [1.5, 0.0, 0.0]},
{"element": "C", "geometry": [3.0, 0.0, 0.0]},
{"element": "C", "geometry": [4.5, 0.0, 0.0]},
{"element": "H", "geometry": [0.0, 1.5, 0.0]},
{"element": "H", "geometry": [0.0, -1.5, 0.0]},
{"element": "H", "geometry": [1.5, 1.5, 0.0]},
{"element": "H", "geometry": [1.5, -1.5, 0.0]},
{"element": "H", "geometry": [3.0, 1.5, 0.0]},
{"element": "H", "geometry": [3.0, -1.5, 0.0]},
{"element": "H", "geometry": [4.5, 1.5, 0.0]},
{"element": "H", "geometry": [4.5, -1.5, 0.0]}
],
"bonds": [
{"atoms": [0, 1], "order": 1},
{"atoms": [1, 2], "order": 1},
{"atoms": [2, 3], "order": 1},
{"atoms": [0, 4], "order": 1},
{"atoms": [0, 5], "order": 1},
{"atoms": [1, 6], "order": 1},
{"atoms": [1, 7], "order": 1},
{"atoms": [2, 8], "order": 1},
{"atoms": [2, 9], "order": 1},
{"atoms": [3, 10], "order": 1},
{"atoms": [3, 11], "order": 1}
],
"properties": {
"molecularMass": 58.1222,
"meltingPoint": -138.3,
"boilingPoint": -0.5
}
}
]
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3a11d0f923ae50c4d82ee1dda0f629a3
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using UnityEngine;
public class MoleculeFactory : MonoBehaviour{
public TextAsset jsonFile;
private static MoleculeFactory instance;
private Molecules moleculesInJson;
private Dictionary<string, Molecule> moleculesDictionary;
public MoleculeFactory(TextAsset jsonFile){
MoleculeFactory.instance = this;
moleculesDictionary = new Dictionary<string, Molecule>();
moleculesInJson = JsonUtility.FromJson<Molecules>(jsonFile.text);
foreach (var molecule in moleculesInJson.molecules){
moleculesDictionary.Add(molecule.formula, molecule);
}
}
public static MoleculeFactory getInstrance(){
if(MoleculeFactory.instance == null){
Debug.LogError("no Json file");
}
return MoleculeFactory.instance;
}
public static MoleculeFactory getInstrance(TextAsset jsonFile){
if(MoleculeFactory.instance == null){
MoleculeFactory.instance = new MoleculeFactory(jsonFile);
}
return MoleculeFactory.instance;
}
public GameObject createMolecule (string formula){
if(!moleculesDictionary.ContainsKey(formula)){
Debug.LogError("molecules does not existe in json");
}
Molecule molecule = moleculesDictionary[formula];
GameObject sortie = new GameObject(molecule.name);
foreach (Atom atom in molecule.atoms) {
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.parent = sortie.transform;
sphere.name = atom.element;
sphere.transform.localPosition = new Vector3(atom.geometry[0], atom.geometry[1], atom.geometry[2]);
//TODO: géré les laision
//TODO: géré la taille de l'atome
//TODO: géré la couleur de l'atome
}
return sortie;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 68834abede8b8d14d93f46876f40df3e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,27 @@
using System.Collections.Generic;
using System;
[System.Serializable]
public class Molecule
{
// nom molécules
public string name;
// formule melécule
public string formula;
// liste des atoms
public Atom[] atoms;
// liste des liason entre les atoms
public Bond[] bonds;
// prorpiété de la molécule
public Properties properties;
}
[System.Serializable]
public class Molecules
{
// liste des liason entre les atoms
public Molecule[] molecules;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 23d78ff2f0da0df4ba3f76aa522bfe4c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,10 @@
[System.Serializable]
public class Properties
{
// masse en g/mol
public float molecularMass;
// température de fusion (solid->liquide)
public float meltingPoint;
// température d'évaporation (liquide-> gaz)
public float boilingPoint;
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5df75892dfdcac7468e63229a5bd0ab8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ReadMolecule : MonoBehaviour
{
public TextAsset jsonFile;
void Start(){
Molecules moleculesInJson = JsonUtility.FromJson<Molecules>(jsonFile.text);
int molNum = 0;
int dist = 5;
foreach (Molecule molecule in moleculesInJson.molecules){
GameObject moleculeObj = new GameObject(molecule.name);
foreach (Atom atom in molecule.atoms){
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.parent = moleculeObj.transform;
sphere.name = atom.element;
sphere.transform.localPosition = new Vector3(atom.geometry[0], atom.geometry[1], atom.geometry[2]);
}
moleculeObj.transform.position = new Vector3(molNum*dist,0,0);
molNum++;
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f13310aa5828a5d47b5e83a3e9eb3fec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,5 +4,29 @@
EditorBuildSettings: EditorBuildSettings:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Scenes: [] m_Scenes:
m_configObjects: {} - enabled: 0
path: Assets/Scenes/MainMenu.unity
guid: 432255403d6f571478f1043c2afa99d5
- enabled: 1
path: Assets/Scenes/CompositionMenu.unity
guid: 82704785f4b327f4fb004845f7dfd005
m_configObjects:
Unity.XR.WindowsMR.Settings: {fileID: 11400000, guid: 744b813df90924c169af73489b8325de,
type: 2}
UnityEditor.XR.ARCore.ARCoreSettings: {fileID: 11400000, guid: 89a6d18d3df8d3e4fa917b0f9a963bc0,
type: 2}
UnityEditor.XR.ARKit.ARKitSettings: {fileID: 11400000, guid: de8a8e4f987434338a4b1062feb8d069,
type: 2}
com.unity.xr.arcore.PlayerSettings: {fileID: 11400000, guid: c2f7b8d7c0bff4d10874cbcf3f24af78,
type: 2}
com.unity.xr.arfoundation.simulation_settings: {fileID: 11400000, guid: a73d54d47cd632049bd22903052e8cf2,
type: 2}
com.unity.xr.arkit.PlayerSettings: {fileID: 11400000, guid: b27ec7d82a91a48e69fd689ad6808e5e,
type: 2}
com.unity.xr.magicleap.magic_leap_settings: {fileID: 11400000, guid: 1eb95d77acb39444e8cf44313496a874,
type: 2}
com.unity.xr.management.loader_settings: {fileID: 11400000, guid: 58f40b12bbc864f3c96c6505a9a1e1e3,
type: 2}
com.unity.xr.openxr.settings4: {fileID: 11400000, guid: 6bb381a8ba31f114d9724357633b4625,
type: 2}

1
QCAR/lh Normal file
View File

@ -0,0 +1 @@
SYa2¶q†[×"b<> %SúûïxŽe.

1
QCAR/somedata16 Normal file
View File

@ -0,0 +1 @@
AAABmYLL8/oCWYDVnt66QIDwPq6z4DN6r3/58aZWC0zcxYa43TCnvCp9IGuXZLgAObCqIm1fhMsWLttc6QAE6obPbuzCjEssQlT41wW38sIVuVhmsw6vfjVsXAQG/GQOgamARLtOkhTKi309FNa+3akhJu9wuEv5jF3vfRbPBoeMCWZuk4Pr8aP7mPH8+10geWHoSWbxgsaEEgrE0yO2xoQwTy2XOmCzZytqk+moWXU7VBu+0//q+koDSnWbjOkEGUfRwMmBJIK9J5TDJrSf/QZYBcEx1daR47cicuXzCb81VtaSvU5VIb9anoX6fukOHe/nCAfsltXFn+4G24NKlejZ568=