public static BoxPrimitive RetextureTop(BoxPrimitive other, GraphicsDevice graphics, Point newTexture) { BoxPrimitive.BoxTextureCoords coords = new BoxPrimitive.BoxTextureCoords(other.UVs.m_texWidth, other.UVs.m_texHeight, other.UVs.m_cellWidth, other.UVs.m_cellHeight, other.UVs.m_front, other.UVs.m_back, newTexture, other.UVs.m_bottom, other.UVs.m_left, other.UVs.m_right); BoxPrimitive toReturn = new BoxPrimitive(graphics, other.Width, other.Height, other.Depth, coords); return toReturn; }
public void Initialize(GraphicsDevice graphics, ContentManager content) { if (!m_initialized) { Texture2D spriteSheet = content.Load<Texture2D>("tiles"); BoxPrimitive.BoxTextureCoords boxCoords = new BoxPrimitive.BoxTextureCoords(spriteSheet.Width, spriteSheet.Height, 32, 32, new Point(5, 9), new Point(8, 9), new Point(7, 8), new Point(9, 9), new Point(7, 9), new Point(6, 9)); BoxPrimitives["bed"] = new BoxPrimitive(graphics, 0.8f, 0.5f, 1.8f, boxCoords); m_initialized = false; } }
public static LocatableComponent GenerateBlankBox(BoundingBox box, ComponentManager componentManager, ContentManager content, GraphicsDevice graphics, string texture, Point topFrame, Point sideFrame, int frameWidth, int frameHeight) { Matrix transform = Matrix.CreateTranslation((box.Max - box.Min) * 0.5f + box.Min); Vector3 extents = box.Max - box.Min; LocatableComponent boxComponent = new LocatableComponent(componentManager, "box", componentManager.RootComponent, transform, extents, Vector3.Zero); Texture2D tex = content.Load<Texture2D>(texture); BoxPrimitive.BoxTextureCoords uvs = new BoxPrimitive.BoxTextureCoords(tex.Width, tex.Height,frameWidth, frameHeight, sideFrame, sideFrame, topFrame, topFrame, sideFrame, sideFrame); BoxPrimitive primitive = new BoxPrimitive(graphics, extents.X, extents.Y, extents.Z, uvs); TexturedBoxObject graphicalBox = new TexturedBoxObject(componentManager, "texturedbox", boxComponent, Matrix.CreateTranslation(-extents * 0.5f) , extents, Vector3.Zero, primitive, content.Load<Texture2D>(texture)); boxComponent.FrustrumCull = false; graphicalBox.FrustrumCull = false; return boxComponent; }
public TexturedBoxObject(ComponentManager manager, string name, GameComponent parent, Matrix localTransform, Vector3 boundingBoxExtents, Vector3 boundingBoxPos, BoxPrimitive primitive, Texture2D tex) : base(manager, name, parent, localTransform, boundingBoxExtents, boundingBoxPos, false) { Primitive = primitive; Texture = tex; }