protected ScopeComponent AddComponent(string name, SimpleTransform transform, Func <Vector3, Vector3> axisMap) { var component = new ScopeComponent(name, transform, axisMap); this.Components.Add(component); return(component); }
public static SimpleTransform Inverse(SimpleTransform transform) { var invRot = Quaternion.Inverse(transform.rotation); return(new SimpleTransform { position = invRot * -transform.position, rotation = invRot }); }
private void Awake() { controllerBlock = this; awakeParent = transform.parent; awakeTransform = transform.GetSimpleTransform(TransformType.Local); Signals.Get(out restartLevelSignal); Signals.Get(out toMenuSignal); restartLevelSignal.AddListener(OnRestartLevel); toMenuSignal.AddListener(OnRestartLevel); }
private void build() { saveStack.Clear(); DrawingTransform = SimpleTransform.Identity; for (int i = 0; i < state.Count; i++) { GameObject go; switch (state[i].symbol) { case 'N': go = makeModule(leaf); DrawingTransform.AssignToGameObject(go); DrawingTransform.position = go.transform.position; break; case 'F': go = makeModule(branch); DrawingTransform.AssignToGameObject(go); DrawingTransform.position = go.transform.position + go.transform.up * 1; break; case '[': saveStack.Push(DrawingTransform); break; case ']': if (saveStack.Count > 0) { DrawingTransform = saveStack.Pop(); } break; case 'R': Vector3 localUp = DrawingTransform.rotation * Vector3.up; Vector3 localRight = DrawingTransform.rotation * Vector3.right; if (state[i].parameters.Length == 2) { DrawingTransform.rotation *= Quaternion.AngleAxis(state[i].parameters[0], localUp) * Quaternion.AngleAxis(state[i].parameters[1], localRight); } break; } } }
private void Awake() { instance = this; types = Resources.FindObjectsOfTypeAll <ProjectileType>(); typeCount = types.Length; projectiles = new SimpleTransform[typeCount][]; counts = new int[typeCount]; hitEffects = new ComponentPool <ParticleSystem> [typeCount]; fireEffects = new ComponentPool <ParticleSystem> [typeCount]; for (int i = 0; i < typeCount; i++) { projectiles[i] = new SimpleTransform[MAX_PROJECTILES_PER_TYPE]; counts[i] = 0; hitEffects[i] = new ComponentPool <ParticleSystem>(10, types[i].blastFx); fireEffects[i] = new ComponentPool <ParticleSystem>(10, types[i].fireFx); } }
private bool IsInForbiddenArea(SimpleTransform tran){ for (int i = 0; i < _objectTransforms.Count; i++) { if (Vector2.Distance (tran.Position, _objectTransforms[i].Position) < (tran.LocalScale.x / 2f + _objectTransforms[i].LocalScale.x / 2f)) { return true; } } return false; }
public void SplitComponent(string query, ShapeSymbol symbol) { this.log.Trace("COMP: {0}, {1}", query, this.CurrentScope.Transform); var currentVol = currentNode.Value.Volume; var components = currentVol.Query(query); foreach (var cmp in components) { // Get the correct position of the component based on the current scope and volume. var newPos = this.CurrentScope.Transform.Position + (this.CurrentScope.Transform.Rotation * Vector3.Scale(currentVol.Transform.Scale, cmp.Transform.Position)); // Get the correct rotation of the component based on the current scope. var newRot = this.CurrentScope.Transform.Rotation * cmp.Transform.Rotation; // Rotate the volume's scale by the rotation of the component so that we can apply the correct scale to the component. // Rotating a scale vector can result in negative values, so we need to make sure that they are all positive. // var s = currentVol.Transform.Scale; // s = cmp.Rotation * s; // s = new Vector3(Mathf.Abs(s.x), Mathf.Abs(s.y), Mathf.Abs(s.z)); // var newScale = s; // var newScale = cmp.AxisMap(currentVol.Transform.Scale); var newScale = cmp.AxisMap(this.CurrentScope.Transform.Scale); newScale = Vector3.Scale(newScale, cmp.Transform.Scale); var newTrans = new SimpleTransform(newPos, newRot, newScale); this.log.Trace("**** {0}", newTrans); var node = this.NewNode(this.currentNode); node.Value.Transform = newTrans; node.Value.Rule = this.rules [symbol.Name]; node.Value.Args = this.ResolveArgs(symbol.UnresolvedArgs).ToList(); //symbol.ResolvedArgs.ToList(); this.AddNode(node); } }
public TextBasedObject(XmlNode node) { this.mesh_name = Utility.FirstChildElement(Utility.FirstChildElement(node, SceneImporter.mesh_element_name), SceneImporter.element_label_name).InnerText; this.mesh_link = Utility.FirstChildElement(Utility.FirstChildElement(node, SceneImporter.mesh_element_name), SceneImporter.element_label_path).InnerText; this.texture_name = Utility.FirstChildElement(Utility.FirstChildElement(node, SceneImporter.texture_element_name), SceneImporter.element_label_name).InnerText; this.texture_link = Utility.FirstChildElement(Utility.FirstChildElement(node, SceneImporter.texture_element_name), SceneImporter.element_label_path).InnerText; this.node_name = Utility.FirstChildElement(node, SceneImporter.node_element_name).InnerText; this.transform = new SimpleTransform(Vector3.zero, Vector3.zero, Vector3.zero); XmlNode element = Utility.FirstChildElement(node, SceneImporter.position_element_name); transform.position.x = float.Parse(Utility.FirstChildElement(element, "x").InnerText); transform.position.y = float.Parse(Utility.FirstChildElement(element, "y").InnerText); transform.position.z = float.Parse(Utility.FirstChildElement(element, "z").InnerText); element = Utility.FirstChildElement(node, SceneImporter.rotation_element_name); transform.rotation.x = float.Parse(Utility.FirstChildElement(element, "x").InnerText); transform.rotation.y = float.Parse(Utility.FirstChildElement(element, "y").InnerText); transform.rotation.z = float.Parse(Utility.FirstChildElement(element, "z").InnerText); element = Utility.FirstChildElement(node, SceneImporter.scale_element_name); transform.scale.x = float.Parse(Utility.FirstChildElement(element, "x").InnerText); transform.scale.y = float.Parse(Utility.FirstChildElement(element, "y").InnerText); transform.scale.z = float.Parse(Utility.FirstChildElement(element, "z").InnerText); }
private SimpleTransform GetRandomTransform(){ SimpleTransform tran=new SimpleTransform(); //scale float size= Random.Range (SizeMin, SizeMax); Vector2 scale = new Vector2 (size, size); //rotation float zRotation=Random.Range(-180f,180f); Quaternion rotation = Quaternion.AngleAxis (zRotation, Vector3.back); //position float x=Random.Range(-MainCam.aspect*MainCam.orthographicSize+scale.x/2, MainCam.aspect*MainCam.orthographicSize-scale.x/2); float y=Random.Range(-MainCam.orthographicSize +scale.y/2, MainCam.orthographicSize -scale.y/2); Vector2 position = new Vector2 (x, y); tran.Position = position; tran.Rotation = rotation; tran.LocalScale = scale; return tran; }
public virtual void ApplyTransform(SimpleTransform transform) { this.Transform.Position = transform.Position; this.Transform.Rotation = transform.Rotation; this.Transform.Scale = transform.Scale; }
public static SimpleTransform Inverse(SimpleTransform transform) { var invRot = Quaternion.Inverse(transform.rotation); return new SimpleTransform { position = invRot * -transform.position, rotation = invRot }; }
public ScopeComponent(string name, SimpleTransform tx, Func <Vector3, Vector3> axisMap) { this.Name = name; this.Transform = tx; this.AxisMap = axisMap; }
public Scope(SimpleTransform transform) { this.Transform = new SimpleTransform(transform); }
public static void SaveCurrentMapData() { GameObject go = GameObject.Find("HexGrid"); if (go) { HexGrid hexGrid = go.GetComponent <HexGrid>(); MapData mapData = ScriptableObject.CreateInstance <MapData>(); mapData.width = hexGrid.width; mapData.height = hexGrid.height; //analysis cell data HexCell[] results = hexGrid.transform.GetComponentsInChildren <HexCell>(); if (results.Length > 0) { mapData.cellDatas = new List <CellData>(mapData.width * mapData.height); foreach (HexCell hexCell in results) { CellData cellData = new CellData(); cellData.x = hexCell.coordinates.X; cellData.y = hexCell.coordinates.Z; cellData.waterLevel = hexCell.WaterLevel; cellData.elevation = hexCell.Elevation; cellData.terrainType = hexCell.terrainType; mapData.cellDatas.Add(cellData); } } //analysis environment Transform env = go.transform.Find("Environment"); int count = env.childCount; if (count > 0) { mapData.mapObjs = new List <MapObj>(count); for (int i = 0; i < count; i++) { Transform child = env.GetChild(i); MapObj mapObj = new MapObj(); mapObj.prefabName = "Prefabs/Tree01"; SimpleTransform simpleTransform = new SimpleTransform(); simpleTransform.position = child.localPosition; simpleTransform.scale = child.localScale; simpleTransform.rotation = child.localRotation; mapObj.transform = simpleTransform; mapData.mapObjs.Add(mapObj); } } //save mapData #if UNITY_EDITOR string path = EditorUtility.SaveFilePanel("Save Map Data", Application.dataPath, "", "asset"); if (string.IsNullOrEmpty(path)) { return; } path = path.Replace(Application.dataPath, "Assets"); AssetDatabase.CreateAsset(mapData, path); #endif } }
public Scope(SimpleTransform tx) { this.Transform = tx; this.Components = new List <ScopeComponent>(); }
public void SetForbiddenArea(SimpleTransform tran){ _objectTransforms.Add (tran); }
public TextBasedObject(String mesh_name, String mesh_link, String texture_name, String texture_link, String node_name, SimpleTransform transform) { this.mesh_name = mesh_name; this.mesh_link = mesh_link; this.texture_name = texture_name; this.texture_link = texture_link; this.node_name = node_name; this.transform = transform; }