public virtual void Create(Gem.PropertyBag Properties) { RenderMesh = Properties.GetPropertyAs<Gem.Geo.Mesh>("render-mesh"); NavigationMesh = Properties.GetPropertyAs<Gem.Geo.Mesh>("nav-mesh", () => null); Texture = Properties.GetPropertyAs<Texture2D>("texture"); NormalMap = Properties.GetPropertyAs<Texture2D>("normal-map", () => null); }
public void DirtyTree() { cachedMesh = null; cachedRenderMesh = null; if (Left != null) Left.DirtyTree(); if (Right != null) Right.DirtyTree(); }
public EditorGrid(GraphicsDevice Device, int DivisionsX, int DivisionsY, Euler Euler = null) { this.Orientation = Euler; if (this.Orientation == null) this.Orientation = new Euler(); this.DivisionsX = DivisionsX; this.DivisionsY = DivisionsY; cellWidth = 1.0f / DivisionsX; cellHeight = 1.0f / DivisionsY; QuadMesh = Gem.Geo.Gen.FacetCopy(Gem.Geo.Gen.CreateQuad()); Gem.Geo.Gen.Transform(QuadMesh, Matrix.CreateTranslation(0.5f, 0.5f, 0.0f)); GridMesh = Gem.Geo.WireframeMesh.GenerateGrid(1.0f, 1.0f, DivisionsX, DivisionsY); }
public override void CalculateLocalMouse(Microsoft.Xna.Framework.Ray MouseRay, Action<Gem.Render.SceneNode, float> HoverCallback) { MouseHover = false; var localMouse = GetLocalMouseRay(MouseRay); GridTraversal.Raycast(localMouse.Position, localMouse.Direction, PickRadius, (x, y, z, normal) => { if (!World.check(x, y, z)) return false; if (World.CellAt(x, y, z).Block == null) return false; if (World.CellAt(x, y, z).Block.Solid == false) return false; HiliteQuad = Gem.Geo.Gen.CreateQuad(); // Align quad with correct face. if (normal.Z < 0) // normal points down. Gem.Geo.Gen.Transform(HiliteQuad, Matrix.CreateFromAxisAngle(Vector3.UnitX, Gem.Math.Angle.PI)); else if (normal.Z == 0) Gem.Geo.Gen.Transform(HiliteQuad, Matrix.CreateFromAxisAngle( Vector3.Cross(-Vector3.UnitZ, normal), -Gem.Math.Angle.PI / 2)); // Move quad to center of block. Gem.Geo.Gen.Transform(HiliteQuad, Matrix.CreateTranslation(x + 0.5f, y + 0.5f, z + 0.5f)); // Move quad out to correct surface. Gem.Geo.Gen.Transform(HiliteQuad, Matrix.CreateTranslation(normal * 0.52f)); var faceIntersection = HiliteQuad.RayIntersection(localMouse); //if (faceIntersection.Intersects == false) throw new InvalidProgramException(); HoverCallback(this, faceIntersection.Distance); HoverBlock = new Coordinate(x, y, z); AdjacentHoverBlock = new Coordinate((int)(x + normal.X), (int)(y + normal.Y), (int)(z + normal.Z)); HoverNormal = normal; return true; }); }
public void DirtyUp() { cachedMesh = null; cachedRenderMesh = null; if (Parent != null) Parent.DirtyUp(); }
public void UpdateGeometry() { ChunkMesh = Generate.ChunkGeometry(World, Blocks); }