public ObjectMetadata(SimpleSimObj simObj) { GameObject o = simObj.gameObject; this.name = o.name; this.position = o.transform.position; this.rotation = o.transform.eulerAngles; this.objectType = Enum.GetName(typeof(SimObjType), simObj.ObjType); this.receptacle = simObj.IsReceptacle; this.openable = simObj.IsOpenable; if (this.openable) { this.isopen = simObj.IsOpen; } this.pickupable = simObj.IsPickupable; this.objectId = simObj.UniqueID; this.visible = simObj.IsVisible; Bounds bounds = simObj.Bounds; this.bounds3D = new [] { bounds.min.x, bounds.min.y, bounds.min.z, bounds.max.x, bounds.max.y, bounds.max.z, }; }
public virtual ObjectMetadata[] generateObjectMetadata() { // Encode these in a json string and send it to the server SimpleSimObj[] simObjects = this.allSceneObjects(); int numObj = simObjects.Length; List <ObjectMetadata> metadata = new List <ObjectMetadata>(); Dictionary <string, List <string> > parentReceptacles = new Dictionary <string, List <string> > (); HashSet <string> visibleObjectIds = new HashSet <string>(); foreach (SimpleSimObj so in VisibleSimObjs() as SimpleSimObj[]) { visibleObjectIds.Add(so.UniqueID); } for (int k = 0; k < numObj; k++) { SimpleSimObj simObj = simObjects[k]; if (this.excludeObject(simObj.UniqueID)) { continue; } ObjectMetadata meta = new ObjectMetadata(simObj); if (meta.receptacle) { List <string> receptacleObjectIds = simObj.ReceptacleObjectIds; foreach (string oid in receptacleObjectIds) { if (!parentReceptacles.ContainsKey(oid)) { parentReceptacles[oid] = new List <string>(); } parentReceptacles[oid].Add(simObj.UniqueID); } meta.receptacleObjectIds = receptacleObjectIds.ToArray(); meta.receptacleCount = simObj.ReceptacleCount; // may want to change this to the number of objects for physics? } meta.distance = Vector3.Distance(transform.position, simObj.gameObject.transform.position); meta.visible = visibleObjectIds.Contains(simObj.UniqueID); metadata.Add(meta); } foreach (ObjectMetadata meta in metadata) { if (parentReceptacles.ContainsKey(meta.objectId)) { meta.parentReceptacles = parentReceptacles[meta.objectId].ToArray(); } } return(metadata.ToArray()); }
private ObjectMetadata[] generateObjectMetadataForTag(string tag, bool isAnimated) { // Encode these in a json string and send it to the server SimpleSimObj[] simObjects = GameObject.FindObjectsOfType(typeof(SimObj)) as SimpleSimObj[]; HashSet <SimpleSimObj> visibleObjectIds = new HashSet <SimpleSimObj>(); foreach (SimpleSimObj so in VisibleSimObjs() as SimpleSimObj[]) { visibleObjectIds.Add(so); } int numObj = simObjects.Length; List <ObjectMetadata> metadata = new List <ObjectMetadata>(); Dictionary <string, string> parentReceptacles = new Dictionary <string, string> (); for (int k = 0; k < numObj; k++) { SimpleSimObj simObj = simObjects[k]; if (this.excludeObject(simObj)) { continue; } ObjectMetadata meta = new ObjectMetadata(simObj); if (meta.receptacle) { List <string> receptacleObjectIds = simObj.ReceptacleObjectIds; foreach (string oid in receptacleObjectIds) { parentReceptacles.Add(oid, simObj.UniqueID); } meta.pivotSimObjs = simObj.PivotSimObjs.ToArray(); meta.receptacleObjectIds = receptacleObjectIds.ToArray(); meta.receptacleCount = simObj.ReceptacleCount; } meta.visible = (visibleObjectIds.Contains(simObj)); meta.distance = Vector3.Distance(transform.position, simObj.gameObject.transform.position); metadata.Add(meta); } foreach (ObjectMetadata meta in metadata) { if (parentReceptacles.ContainsKey(meta.objectId)) { meta.parentReceptacle = parentReceptacles [meta.objectId]; } } return(metadata.ToArray()); }
protected bool openSimObj(SimpleSimObj so) { return(so.Open()); }
protected bool closeSimObj(SimpleSimObj so) { return(so.Close()); }
public bool excludeObject(SimpleSimObj so) { return(excludeObject(so.UniqueID)); }