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() {
world?.Dispose();
world = new SneakWorld(GraphicsDevice, Content.LoadString("levels/demo.json"));
// world = new TreeWorld();
// world = new SneakWorld(GraphicsDevice, Content.LoadString("levels/demo.json"));
world = new TreeWorld();
scene?.Dispose();
scene = new SneakScene(GraphicsDevice, ((SneakWorld) world).Camera);
// scene = new TreeScene(GraphicsDevice);
// scene = new SneakScene(GraphicsDevice, ((SneakWorld) world).Camera);
scene = new TreeScene(GraphicsDevice);
GC.Collect();
GC.WaitForPendingFinalizers();

View File

@ -59,17 +59,11 @@ namespace SemiColinGames {
}
public class TreeNode {
// Ideal orientation, relative to its parent.
public readonly float Orientation;
// Orientation in world space.
public float WorldOrientation;
public readonly float Length;
public readonly float InWidth;
public readonly float OutWidth;
public float Orientation; // relative to parent
public float Length;
public float InWidth;
public float OutWidth;
public readonly List<TreeNode> Children;
// Position of in-vertex in world space.
public Vector2 Position;
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) {
Orientation = orientation;
WorldOrientation = orientation;
Length = length;
InWidth = inWidth;
OutWidth = outWidth;
@ -101,8 +94,8 @@ namespace SemiColinGames {
public void Draw(bool isRunningSlowly, IWorld iworld, bool paused) {
var tree =
new TreeNode(0.0f, 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.1f, 100, 6, 4,
@ -120,18 +113,12 @@ namespace SemiColinGames {
LinkedList<TreeNode> queue = new LinkedList<TreeNode>();
queue.AddLast(tree);
Debug.WriteLine("---------------------");
while (queue.Count > 0) {
TreeNode parent = queue.First.Value;
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);
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.
// The TreeNode.Length is the distance from A to B.
//
@ -152,14 +139,13 @@ namespace SemiColinGames {
t.p2 = new Vector2(parent.InWidth, 0);
t.p3 = 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);
segments.Add(t);
foreach (TreeNode child in parent.Children) {
child.Position = outPosition;
float orientation = parent.WorldOrientation + child.Orientation;
child.WorldOrientation = orientation;
child.Orientation += parent.Orientation;
queue.AddLast(child);
}
}