robotArm
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UVC.Data.Core;
|
||||
|
||||
@@ -6,6 +7,7 @@ namespace Simulator.Data {
|
||||
public class RackComponent : ComponentBase
|
||||
{
|
||||
public GameObject cellPrefab;
|
||||
public GameObject emptyPrefab;
|
||||
public RackDataClass rackData;
|
||||
|
||||
public Dictionary<(int x,int y, int z),CellComponent> cellComponents=new Dictionary<(int x, int y, int z), CellComponent>();
|
||||
@@ -28,9 +30,7 @@ namespace Simulator.Data {
|
||||
var y = (int)coordinates.GetInt("y");
|
||||
var z = (int)coordinates.GetInt("z");
|
||||
var entity=EntityManager.Instance.GetEntities(entityids,this);
|
||||
entity[0].transform.SetParent(cellComponents[(x, y, z)].Socket.transform);
|
||||
entity[0].transform.localPosition = new Vector3(0, -0.25f, -0.25f);
|
||||
entitys.Add(entity[0].gameObject);
|
||||
SetEntityToCell(entity[0], (x, y, z));
|
||||
}
|
||||
|
||||
public void SetASRSQueue(DataObject modelData)
|
||||
@@ -43,6 +43,41 @@ namespace Simulator.Data {
|
||||
entitys.Add(entity.gameObject);
|
||||
}
|
||||
|
||||
public void InitializeQueue(DataObject modelData)
|
||||
{
|
||||
var datas = modelData.GetDataObject("data");
|
||||
var from_position = datas.GetDataObject("from_position");
|
||||
var fx = from_position.GetInt("x").Value;
|
||||
var fy = from_position.GetInt("y").Value;
|
||||
var fz = from_position.GetInt("z").Value;
|
||||
Vector3 fromVector3 = new Vector3(fx, fy, fz);
|
||||
var to_position = datas.GetDataObject("to_position");
|
||||
var tx = to_position.GetInt("x").Value;
|
||||
var ty = to_position.GetInt("y").Value;
|
||||
var tz = to_position.GetInt("z").Value;
|
||||
Vector3 toVector3 = new Vector3(tx, ty, tz);
|
||||
var entityIds = datas["entities"].ConvertTo<List<string>>();
|
||||
var entities=EntityManager.Instance.SpawnEntites(entityIds, this);
|
||||
int index = 0;
|
||||
for (int x = fx; x < tx; x++)
|
||||
{
|
||||
for(int y = fy; y < fy; y++)
|
||||
{
|
||||
for(int z = fz; z < fz; z++)
|
||||
{
|
||||
SetEntityToCell(entities[index++], (x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetEntityToCell(Entity entity,(int x,int y,int z) coord)
|
||||
{
|
||||
entity.transform.SetParent(cellComponents[(coord.x,coord.y,coord.z)].Socket.transform);
|
||||
entity.transform.localPosition = new Vector3(0, -0.25f, -0.25f);
|
||||
entitys.Add(entity.gameObject);
|
||||
}
|
||||
|
||||
public void SpawnCell(rack_layout layout,bool asrs)
|
||||
{
|
||||
//Vector3 center = new Vector3(layout.x * layout.x_length / 2f, 0f, layout.z * layout.z_length / 2f);
|
||||
@@ -55,10 +90,7 @@ namespace Simulator.Data {
|
||||
for(int x=0;x<layout.x; x++)
|
||||
{
|
||||
var cell = Instantiate(cellPrefab);
|
||||
//cell.transform.localScale=new Vector3(layout.x_length, layout.y_length, layout.z_length);
|
||||
cell.transform.localScale=new Vector3(layout.x_length/0.63f, layout.y_length / 0.63f, layout.z_length / 0.59f);
|
||||
//cell.transform.position = new Vector3(layout.x_length * x*0.55f, layout.y_length * y * 0.59f, layout.z_length * z * 0.75f);
|
||||
//cell.transform.position = new Vector3(layout.x_length * x, layout.y_length * y*0.55f/0.59f, layout.z_length*z* 0.55f / 0.75f);
|
||||
cell.transform.position = new Vector3(layout.x_length * x, layout.y_length * y+0.8f, layout.z_length*z);
|
||||
cell.transform.parent = this.transform;
|
||||
cellComponents.Add((x, y, z), cell.GetComponent<CellComponent>());
|
||||
@@ -70,17 +102,14 @@ namespace Simulator.Data {
|
||||
}
|
||||
if (asrs)
|
||||
{
|
||||
var pickcell = Instantiate(cellPrefab);
|
||||
//pickcell.transform.localScale = new Vector3(layout.x_length, layout.y_length, layout.z_length);
|
||||
var pickcell = Instantiate(emptyPrefab);
|
||||
pickcell.transform.localScale = new Vector3(layout.x_length / 0.63f, layout.y_length / 0.63f, layout.z_length / 0.59f);
|
||||
//pickcell.transform.position = new Vector3(layout.x_length * -0.55f, layout.y_length * 0, layout.z_length * 0);
|
||||
pickcell.transform.position = new Vector3(layout.x_length*-1f, layout.y_length * 0 + 0.8f, layout.z_length * 0);
|
||||
pickcell.transform.position = new Vector3(layout.x_length*0f, layout.y_length * 0 + 0.8f, layout.z_length * -4f);
|
||||
pickcell.transform.parent = this.transform;
|
||||
cellComponents.Add((-1, 0, 0), pickcell.GetComponent<CellComponent>());
|
||||
var dropcell = Instantiate(cellPrefab);
|
||||
//dropcell.transform.localScale = new Vector3(layout.x_length, layout.y_length, layout.z_length);
|
||||
var dropcell = Instantiate(emptyPrefab);
|
||||
dropcell.transform.localScale = new Vector3(layout.x_length / 0.63f, layout.y_length / 0.63f, layout.z_length / 0.59f);
|
||||
dropcell.transform.position = new Vector3(layout.x_length * (layout.x), layout.y_length * 0+0.8f, layout.z_length * 0);
|
||||
dropcell.transform.position = new Vector3(layout.x_length * (layout.x-1f), layout.y_length * 0+0.8f, layout.z_length * -4f);
|
||||
dropcell.transform.parent = this.transform;
|
||||
cellComponents.Add(((int)(layout.x), 0, 0), dropcell.GetComponent<CellComponent>());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user