Compare commits

..

No commits in common. "39ac88b60af32c3f9307ab0fc69599e2c4588bf8" and "7358bc0b2423f6c748c708ae6786ad1b78d4efea" have entirely different histories.

2 changed files with 13 additions and 27 deletions

View File

@ -64,11 +64,11 @@ namespace SemiColinGames {
private void LoadLevel() { private void LoadLevel() {
world?.Dispose(); world?.Dispose();
world = new SneakWorld(GraphicsDevice, Content.LoadString("levels/demo.json")); // world = new SneakWorld(GraphicsDevice, Content.LoadString("levels/demo.json"));
// world = new TreeWorld(); world = new TreeWorld();
scene?.Dispose(); scene?.Dispose();
scene = new SneakScene(GraphicsDevice, ((SneakWorld) world).Camera); // scene = new SneakScene(GraphicsDevice, ((SneakWorld) world).Camera);
// scene = new TreeScene(GraphicsDevice); scene = new TreeScene(GraphicsDevice);
GC.Collect(); GC.Collect();
GC.WaitForPendingFinalizers(); GC.WaitForPendingFinalizers();

View File

@ -59,17 +59,11 @@ namespace SemiColinGames {
} }
public class TreeNode { public class TreeNode {
// Ideal orientation, relative to its parent. public float Orientation; // relative to parent
public readonly float Orientation; public float Length;
// Orientation in world space. public float InWidth;
public float WorldOrientation; public float OutWidth;
public readonly float Length;
public readonly float InWidth;
public readonly float OutWidth;
public readonly List<TreeNode> Children; public readonly List<TreeNode> Children;
// Position of in-vertex in world space.
public Vector2 Position; public Vector2 Position;
public TreeNode(float orientation, float length, float inWidth, float outWidth) : public TreeNode(float orientation, float length, float inWidth, float outWidth) :
@ -90,7 +84,6 @@ namespace SemiColinGames {
public TreeNode(float orientation, float length, float inWidth, float outWidth, List<TreeNode> children) { public TreeNode(float orientation, float length, float inWidth, float outWidth, List<TreeNode> children) {
Orientation = orientation; Orientation = orientation;
WorldOrientation = orientation;
Length = length; Length = length;
InWidth = inWidth; InWidth = inWidth;
OutWidth = outWidth; OutWidth = outWidth;
@ -101,8 +94,8 @@ namespace SemiColinGames {
public void Draw(bool isRunningSlowly, IWorld iworld, bool paused) { public void Draw(bool isRunningSlowly, IWorld iworld, bool paused) {
var tree = var tree =
new TreeNode(0.0f, 100, 10, 6, new TreeNode(-0.2f, 100, 10, 6,
new TreeNode(0.0f, 100, 10, 6, new TreeNode(-0.2f, 100, 10, 6,
new TreeNode(-0.2f, 100, 10, 6, new TreeNode(-0.2f, 100, 10, 6,
new TreeNode(-0.3f, 100, 6, 4, new TreeNode(-0.3f, 100, 6, 4,
new TreeNode(-0.1f, 100, 6, 4, new TreeNode(-0.1f, 100, 6, 4,
@ -120,18 +113,12 @@ namespace SemiColinGames {
LinkedList<TreeNode> queue = new LinkedList<TreeNode>(); LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
queue.AddLast(tree); queue.AddLast(tree);
Debug.WriteLine("---------------------");
while (queue.Count > 0) { while (queue.Count > 0) {
TreeNode parent = queue.First.Value; TreeNode parent = queue.First.Value;
queue.RemoveFirst(); queue.RemoveFirst();
Vector2 outVector = new Vector2(0, parent.Length).Rotate(parent.WorldOrientation); Vector2 outVector = new Vector2(0, parent.Length).Rotate(parent.Orientation);
Vector2 outPosition = Vector2.Add(parent.Position, outVector); Vector2 outPosition = Vector2.Add(parent.Position, outVector);
outVector.Normalize();
Vector2 wind = new Vector2(1.0f, 0.0f);
float windAmount = Vector2.Dot(wind, outVector);
Debug.WriteLine("" + windAmount);
// We want a trapezoid with 4 points. A is the in position, B is the out position. // We want a trapezoid with 4 points. A is the in position, B is the out position.
// The TreeNode.Length is the distance from A to B. // The TreeNode.Length is the distance from A to B.
// //
@ -152,14 +139,13 @@ namespace SemiColinGames {
t.p2 = new Vector2(parent.InWidth, 0); t.p2 = new Vector2(parent.InWidth, 0);
t.p3 = new Vector2(-parent.OutWidth, parent.Length * sideLengthFudge); t.p3 = new Vector2(-parent.OutWidth, parent.Length * sideLengthFudge);
t.p4 = new Vector2(parent.OutWidth, parent.Length * sideLengthFudge); t.p4 = new Vector2(parent.OutWidth, parent.Length * sideLengthFudge);
t.Rotate(parent.WorldOrientation); t.Rotate(parent.Orientation);
t.Translate(parent.Position); t.Translate(parent.Position);
segments.Add(t); segments.Add(t);
foreach (TreeNode child in parent.Children) { foreach (TreeNode child in parent.Children) {
child.Position = outPosition; child.Position = outPosition;
float orientation = parent.WorldOrientation + child.Orientation; child.Orientation += parent.Orientation;
child.WorldOrientation = orientation;
queue.AddLast(child); queue.AddLast(child);
} }
} }