private bool skyToGroundAlgorithm(ITerrain terrain, out Vector3 position) { Vector3 aPoint; Vector3 terrainPoint; float t = 0; while (true) { aPoint = this.Ray.Origin + t * this.Ray.Direction; if (terrain.getPosition(aPoint.X, aPoint.Z, out terrainPoint)) { if (GeneralMethods.isCloseTo(aPoint.Y, terrainPoint.Y, 1)) { //encontramos el punto de interseccion position = aPoint; return true; } } else if (aPoint.Y >= terrain.maxY || aPoint.Y < terrain.minY) { //ya nos fuimos o muy arriba o muy abajo position = Vector3.Empty; return false; } t++; } }
private static ILevelObject getWall(XmlNode levelObjectNode, ITerrain terrain) { float[] pos = TgcParserUtils.parseFloat2Array(levelObjectNode.InnerText); Vector3 size = TgcParserUtils.float3ArrayToVector3(TgcParserUtils.parseFloat3Array(levelObjectNode.Attributes.GetNamedItem("size").InnerText)); return new Wall(terrain.getPosition(pos[0], pos[1]), size); }
private static Commando getDefault(XmlNode commandoNode, ITerrain terrain) { float[] pos = TgcViewer.Utils.TgcSceneLoader.TgcParserUtils.parseFloat2Array(commandoNode.InnerText); Commando commando = new Commando(terrain.getPosition(pos[0], pos[1])); XmlNode pic = commandoNode.Attributes.GetNamedItem("picture"); if (pic != null) { commando.Picture = new CharacterPicture(CommandosUI.Instance.MediaDir + pic.InnerText); } return commando; }
private static Enemy getSoldier(XmlNode enemyNode, ITerrain terrain) { List<Vector3> waitpoints = new List<Vector3>(); foreach (XmlNode wn in enemyNode.ChildNodes) { if (wn.NodeType == XmlNodeType.Element) { float[] pos = TgcParserUtils.parseFloat2Array(wn.InnerText); waitpoints.Add(terrain.getPosition(pos[0], pos[1])); } } return new Soldier(waitpoints.ToArray<Vector3>()); }
public FreeCamera(ITerrain terrain, bool enabled) : this() { this.CameraCenter = terrain.getPosition(0, 150); this.Terrain = terrain; this.Enable = enabled; }
/// <summary> /// Se fija si el terreno tapa la vista a un punto. /// </summary> /// <param name="terrain"></param> /// <param name="targetPoint"></param> /// <returns></returns> private bool canSeeInTerrain(ITerrain terrain, Vector3 targetPoint) { Vector3 origin = this.Position; Vector3 direction = targetPoint - this.Position; float t; for (t = 0; t < 1; t += 0.05f) { Vector3 aPoint = origin + t * direction; Vector3 terrainPoint = terrain.getPosition(aPoint.X, aPoint.Z); if (aPoint.Y < terrainPoint.Y) return false; } return true; }
private static ILevelObject getMeshObject(XmlNode levelObjectNode, ITerrain terrain, string mediaDir, Vector3 scale, Vector3 rotation) { float[] pos = TgcParserUtils.parseFloat2Array(levelObjectNode.InnerText); string path = mediaDir + levelObjectNode.Attributes.GetNamedItem("mesh").InnerText; return new MeshObject(path, terrain.getPosition(pos[0], pos[1]), scale, rotation); }
private static ILevelObject getTree(XmlNode levelObjectNode, ITerrain terrain, Vector3 scale, Vector3 rotation) { float[] pos = TgcParserUtils.parseFloat2Array(levelObjectNode.InnerText); return new Tree(terrain.getPosition(pos[0], pos[1]), scale, rotation); }