public Leaf(Branch Parent, float Pitch, float Yaw, float Roll) { this.Parent = Parent; this.Pitch = Pitch; this.Yaw = Yaw; this.Roll = Roll; Tree = Parent.Tree; Base = Parent.Tip; RotMatrix = new Matrix3(Parent.RotMatrix); //RotMatrix = RotMatrix.RotZ(Yaw).RotX(Pitch).RotZ(Roll); RotMatrix = RotMatrix.RotZ(Yaw).RotY(Pitch).RotZ(Roll); Tip1 = RotMatrix * new Vector3(0, 1, 2); Tip2 = RotMatrix * new Vector3(0, -1, 2); Norm = Vector3.Cross(Tip1, Tip2); Norm.Norm(); Tip1 += Base; Tip2 += Base; Center = (Base + Tip1 + Tip2) / 3; if (Center.Z > Tree.TotalHeight) { Tree.TotalHeight = (float)Center.Z; } Vector Pos = new Vector((float)(Center.X) * SizeScale2d, (float)Center.Y * SizeScale2d) + Tree.Pos; VectorI ChunkPos = Tree.ChunkPos; UpdateWorld.ConstrainVectorInChunk(ref Pos, ref ChunkPos); this.Pos = Pos; this.ChunkPos = ChunkPos; Col = Tree.LeafColor; Vertecies = new Vector3[] { Base, Tip1, Tip2 }; }
public void MouseDrag(float Dx, float Dy) { if (Selected is Tree) { float mult = 0.3F; Draw3D.angle.Z -= Dx * mult; Draw3D.angle.X += Dy * mult; Draw3D.angle.X = Math.Max(Math.Min(Draw3D.angle.X, 0), -90); } else { //CameraPosition.X -= Dx / Zoom; //CameraPosition.Y -= Dy / Zoom; CameraPos2 -= new Vector(Dx, Dy) / Zoom; UpdateWorld.ConstrainVectorInChunk(ref CameraPos2, ref CameraChunk); } }
public void ScreenToWorld(float x, float y, out Vector V, out VectorI C) { V = new Vector((x - Form1.PB.Width / 2) / Zoom + CameraPos2.X, (y - Form1.PB.Height / 2) / Zoom + CameraPos2.Y); C = CameraChunk; UpdateWorld.ConstrainVectorInChunk(ref V, ref C); }