/// <summary> /// Actualiza el BoundingBox de la caja. /// No contempla rotacion /// </summary> private void updateBoundingBox() { Vector3 midSize = Vector3.Scale(size, 0.5f); boundingBox.setExtremes(Vector3.Subtract(translation, midSize), Vector3.Add(translation, midSize)); }
/// <summary> /// Actualizar parámetros de la pared en base a los valores configurados /// </summary> public void updateValues() { float autoWidth; float autoHeight; //Calcular los 4 corners de la pared, segun el tipo de orientacion Vector3 bLeft, tLeft, bRight, tRight; if (orientation == Orientations.XYplane) { bLeft = origin; tLeft = new Vector3(origin.X + size.X, origin.Y, origin.Z); bRight = new Vector3(origin.X, origin.Y + size.Y, origin.Z); tRight = new Vector3(origin.X + size.X, origin.Y + size.Y, origin.Z); autoWidth = (size.X / texture.Width); autoHeight = (size.Y / texture.Height); } else if (orientation == Orientations.YZplane) { bLeft = origin; tLeft = new Vector3(origin.X, origin.Y, origin.Z + size.Z); bRight = new Vector3(origin.X, origin.Y + size.Y, origin.Z); tRight = new Vector3(origin.X, origin.Y + size.Y, origin.Z + size.Z); autoWidth = (size.Y / texture.Width); autoHeight = (size.Z / texture.Height); } else { bLeft = origin; tLeft = new Vector3(origin.X + size.X, origin.Y, origin.Z); bRight = new Vector3(origin.X, origin.Y, origin.Z + size.Z); tRight = new Vector3(origin.X + size.X, origin.Y, origin.Z + size.Z); autoWidth = (size.X / texture.Width); autoHeight = (size.Z / texture.Height); } //Auto ajustar UV if (autoAdjustUv) { this.uTile = autoHeight; this.vTile = autoWidth; } float offsetU = this.uvOffset.X; float offsetV = this.uvOffset.Y; //Primer triangulo vertices[0] = new CustomVertex.PositionTextured(bLeft, offsetU + uTile, offsetV + vTile); vertices[1] = new CustomVertex.PositionTextured(tLeft, offsetU, offsetV + vTile); vertices[2] = new CustomVertex.PositionTextured(tRight, offsetU, offsetV); //Segundo triangulo vertices[3] = new CustomVertex.PositionTextured(bLeft, offsetU + uTile, offsetV + vTile); vertices[4] = new CustomVertex.PositionTextured(tRight, offsetU, offsetV); vertices[5] = new CustomVertex.PositionTextured(bRight, offsetU + uTile, offsetV); /*Versión con triángulos para el otro sentido * //Primer triangulo * vertices[0] = new CustomVertex.PositionTextured(tLeft, 0 * this.uTile, 1 * this.vTile); * vertices[1] = new CustomVertex.PositionTextured(bLeft, 1 * this.uTile, 1 * this.vTile); * vertices[2] = new CustomVertex.PositionTextured(bRight, 1 * this.uTile, 0 * this.vTile); * * //Segundo triangulo * vertices[3] = new CustomVertex.PositionTextured(bRight, 1 * this.uTile, 0 * this.vTile); * vertices[4] = new CustomVertex.PositionTextured(tRight, 0 * this.uTile, 0 * this.vTile); * vertices[5] = new CustomVertex.PositionTextured(tLeft, 0 * this.uTile, 1 * this.vTile); */ //BoundingBox boundingBox.setExtremes(bLeft, tRight); }