Skip to content
Snippets Groups Projects
Commit 16d75ba6 authored by nollet's avatar nollet
Browse files

initial commit

parent 51b39934
No related branches found
No related tags found
No related merge requests found
# Flocking Simulator # Flocking Simulator
Projet Individuel (UE PJI) de NOLLET Antoine en Master 1 Informatique mention Réalité Virtuelle et Augmentée (M1 RVA) durant l'année 2021-2022
## Getting started
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.univ-lille.fr/antoine.nollet.etu/flocking-simulator.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.univ-lille.fr/antoine.nollet.etu/flocking-simulator/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description ## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &437517194170826549
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3255089734447956989}
- component: {fileID: 1274723212690861014}
- component: {fileID: 6428507427308703938}
- component: {fileID: 2073586004525875113}
m_Layer: 0
m_Name: Cylinder
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &3255089734447956989
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 437517194170826549}
m_LocalRotation: {x: -0.5192311, y: 0.4799991, z: 0.5192311, w: 0.4799991}
m_LocalPosition: {x: 0.02, y: -0.11, z: -0.03}
m_LocalScale: {x: 0.44719383, y: 1.7489846, z: 0.4350196}
m_Children: []
m_Father: {fileID: 8965968834670266038}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: -94.496994, y: 89.99999, z: 0}
--- !u!33 &1274723212690861014
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 437517194170826549}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &6428507427308703938
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 437517194170826549}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!136 &2073586004525875113
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 437517194170826549}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.50000036
m_Height: 2
m_Direction: 1
m_Center: {x: 0.000000029802326, y: 0, z: -0.00000005960467}
--- !u!1 &6503597824548460142
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7021844916232508048}
- component: {fileID: 3037028539180812241}
- component: {fileID: 7478878501271007588}
- component: {fileID: 5023922831713910363}
m_Layer: 0
m_Name: Capsule
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7021844916232508048
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6503597824548460142}
m_LocalRotation: {x: 0.49605432, y: 0.50391483, z: 0.49605432, w: 0.50391483}
m_LocalPosition: {x: -0.07, y: -0.01, z: 0.418}
m_LocalScale: {x: 0.09107, y: 0.33664638, z: 0.5}
m_Children: []
m_Father: {fileID: 8965968834670266038}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 90.00001, z: 89.09901}
--- !u!33 &3037028539180812241
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6503597824548460142}
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &7478878501271007588
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6503597824548460142}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!136 &5023922831713910363
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6503597824548460142}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.50000024
m_Height: 2
m_Direction: 1
m_Center: {x: -0.000000029802347, y: 0, z: 0.00000002980234}
--- !u!1 &8965968834670266037
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8965968834670266038}
- component: {fileID: 8965968834670266033}
- component: {fileID: 8965968834670266032}
- component: {fileID: 8965968834670266039}
- component: {fileID: 8965968834670266034}
m_Layer: 0
m_Name: Boid
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &8965968834670266038
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8965968834670266037}
m_LocalRotation: {x: 0, y: -0.7071068, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0.21321096, y: 1, z: -0.17667253}
m_LocalScale: {x: 0.5, y: 0.5, z: 1.2}
m_Children:
- {fileID: 3255089734447956989}
- {fileID: 7021844916232508048}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: -90, z: 0}
--- !u!33 &8965968834670266033
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8965968834670266037}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!23 &8965968834670266032
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8965968834670266037}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &8965968834670266039
SphereCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8965968834670266037}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &8965968834670266034
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8965968834670266037}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 569ca68f350b4a14f8619ace3abb92bc, type: 3}
m_Name:
m_EditorClassIdentifier:
direction: {x: 0, y: 0, z: 0}
speed: 0
fileFormatVersion: 2
guid: ecfb92997fb6674468149566eb767e2c
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Environnement : MonoBehaviour
{
public int minX;
public int minY;
public int minZ;
public int maxX;
public int maxY;
public int maxZ;
public bool _3D;
public bool globalSpeed;
public float speed;
public bool RaynoldEscape;
public int RaynoldEscapeTresh;
public bool RaynoldTogether;
public int RaynoldTogetherTresh;
public bool RaynoldFollow;
public int RaynoldFollowTresh;
// Start is called before the first frame update
void Start()
{
_3D = true;
globalSpeed = true;
speed = 1.2f;
minX = -30;
minY = 0;
minZ = -15;
maxX = 30;
maxY = 50;
maxZ = 15;
RaynoldEscape = false ;
RaynoldEscapeTresh = 1;
RaynoldTogether = false ;
RaynoldTogetherTresh = 3;
RaynoldFollow = false ;
RaynoldFollowTresh = 5;
}
// Update is called once per frame
void Update()
{
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: e6b1cf67504415c4686b3faeea17770e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class Flocking : MonoBehaviour
{
private Environnement env;
public Vector3 direction;
public float speed;
private bool _3D;
public Component[] birds;
private List<Vector3> nextDirections = new List<Vector3>();
// Start is called before the first frame update
void Start()
{
env = GameObject.Find("SMA").GetComponent<Environnement>();
direction = randomDirection();
speed = 1.2f;
_3D = env._3D;
birds = env.GetComponentsInChildren<Flocking>();
}
// Update is called once per frame
void Update()
{
if(env._3D != _3D) {
_3D = env._3D;
direction = randomDirection();
}
setDirection();
move();
}
Vector3 randomDirection() {
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
int r;
if(env._3D) {
for(int i = 0; i<10; i++) {
r = UnityEngine.Random.Range(0,3);
if (r == 0) x += 1.0f;
else if (r == 1) y += 1.0f;
else z += 1.0f;
}
}
else {
for(int i = 0; i<10; i++) {
r = UnityEngine.Random.Range(0,2);
if (r == 0) x += 1.0f;
else y += 1.0f;
}
}
if(UnityEngine.Random.Range(1,3) > 1) x = -x;
if(UnityEngine.Random.Range(1,3) > 1) y = -y;
if(UnityEngine.Random.Range(1,3) > 1) z = -z;
return normalizedVector(x,y,z);
}
Vector3 normalizedVector(float x, float y, float z) {
return (new Vector3(x,y,z)).normalized;
}
Vector3 meanVector(List<Vector3> vectors) {
Vector3 res = Vector3.zero;
for(int i = 0; i<vectors.Count; i++) {
res += vectors[i];
}
res = res/vectors.Count;
return res.normalized;
}
void setDirection() {
nextDirections.Clear();
environnement();
List<Component> neighbours = neighbourhood();
if(env.RaynoldEscape) raynoldEscape(neighbours);
if(env.RaynoldFollow) raynoldFollow(neighbours);
if(env.RaynoldTogether) raynoldTogether(neighbours);
direction = meanVector(nextDirections);
}
List<Component> neighbourhood() {
List<Component> neighbours = new List<Component>();
float dist;
Vector3 link;
Flocking bird;
for(int i=0; i<birds.Length; i++) {
bird = (Flocking) birds[i];
link = bird.transform.position - transform.position;
dist = (float) Math.Sqrt(Math.Pow(link.x,2) + Math.Pow(link.y,2) + Math.Pow(link.z,2));
if(bird != this && dist < env.RaynoldFollowTresh) neighbours.Add(birds[i]);
}
return neighbours;
}
void raynoldEscape(List<Component> neighbours) {
Vector3 res = Vector3.zero;
float dist;
Vector3 link;
Flocking bird;
for(int i=0; i<neighbours.Count; i++) {
bird = (Flocking) neighbours[i];
link = bird.transform.position - transform.position;
dist = (float) Math.Sqrt(Math.Pow(link.x,2) + Math.Pow(link.y,2) + Math.Pow(link.z,2));
if(bird != this && dist < env.RaynoldEscapeTresh) res -= link;
}
nextDirections.Add(normalizedVector(res.x,res.y,res.z));
}
void raynoldFollow(List<Component> neighbours) {
Vector3 res = Vector3.zero;
float dist;
Vector3 link;
Flocking bird;
for(int i=0; i<neighbours.Count; i++) {
bird = (Flocking) neighbours[i];
link = bird.transform.position - transform.position;
dist = (float) Math.Sqrt(Math.Pow(link.x,2) + Math.Pow(link.y,2) + Math.Pow(link.z,2));
if(bird != this && dist < env.RaynoldFollowTresh && dist >= env.RaynoldTogetherTresh) res += link;
}
nextDirections.Add(normalizedVector(res.x,res.y,res.z));
}
void raynoldTogether(List<Component> neighbours) {
Vector3 res = Vector3.zero;
float dist;
Vector3 link;
Flocking bird;
for(int i=0; i<neighbours.Count; i++) {
bird = (Flocking) neighbours[i];
link = bird.transform.position - transform.position;
dist = (float) Math.Sqrt(Math.Pow(link.x,2) + Math.Pow(link.y,2) + Math.Pow(link.z,2));
if(bird != this && dist < env.RaynoldTogetherTresh && dist >= env.RaynoldEscapeTresh) res += bird.direction;
}
nextDirections.Add(normalizedVector(res.x,res.y,res.z));
}
void environnement() {
Vector3 res = Vector3.zero;
res += direction;
if(transform.position.x < env.minX || transform.position.x > env.maxX) res.x = -direction.x;
if(transform.position.y < env.minY || transform.position.y > env.maxY) res.y = -direction.y;
if(transform.position.z < env.minZ || transform.position.z > env.maxZ) res.z = -direction.z;
nextDirections.Add(res);
}
void move() {
float s;
if(env.globalSpeed) s = env.speed; else s = speed;
transform.position += s*direction;
transform.LookAt(transform.position + s*direction);
}
}
fileFormatVersion: 2
guid: 569ca68f350b4a14f8619ace3abb92bc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: fb44d5370e6065d42932be2ab49c851d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 9fc0d4010bbf28b4594072e72b8655ab
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment