public HandOverlay(Hand p_hand) { m_renderTexture = new SFML.Graphics.RenderTexture(512, 512); m_backgroundSprite = new SFML.Graphics.Sprite(ms_resources["background"]); m_backgroundSprite.Color = ms_backgroundColor; m_thumbstickShape = new SFML.Graphics.Sprite(ms_resources["circle"]); m_thumbstickShape.Color = ms_inactiveColor; m_thumbstickShape.Position = new SFML.System.Vector2f(40f, 40f); m_touchpadShape = new SFML.Graphics.Sprite(ms_resources["circle"]); m_touchpadShape.Color = ms_inactiveColor; m_touchpadShape.Position = new SFML.System.Vector2f(40f, 270f); m_buttonB = new SFML.Graphics.Sprite(ms_resources["buttonB"]); m_buttonB.Color = ms_inactiveColor; m_buttonB.Position = new SFML.System.Vector2f(310f, 95f); m_buttonA = new SFML.Graphics.Sprite(ms_resources["buttonA"]); m_buttonA.Color = ms_inactiveColor; m_buttonA.Position = new SFML.System.Vector2f(310f, 210f); m_buttonSystem = new SFML.Graphics.Sprite(ms_resources["buttonS"]); m_buttonSystem.Color = ms_inactiveColor; m_buttonSystem.Position = new SFML.System.Vector2f(310f, 325f); m_cursorShape = new SFML.Graphics.CircleShape(5f); m_cursorShape.FillColor = ms_activeColor; m_thumbstickAxisShape = new SFML.Graphics.CircleShape(7.5f); m_thumbstickAxisShape.FillColor = ms_axisColorTouch; m_touchpadAxisShape = new SFML.Graphics.CircleShape(7.5f); m_touchpadAxisShape.FillColor = ms_axisColorTouch; m_presureRectangle = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(10f, 320f)); m_presureRectangle.Position = new SFML.System.Vector2f(480f, 100f); m_presureRectangle.FillColor = ms_inactiveColor; m_presureFillRectangle = new SFML.Graphics.RectangleShape(new SFML.System.Vector2f(10f, -320f)); m_presureFillRectangle.Position = new SFML.System.Vector2f(480f, 420f); m_presureFillRectangle.FillColor = ms_inactiveColor; // Create overlay Valve.VR.OpenVR.Overlay.CreateOverlay(ms_overlayNames[(int)p_hand], "Ultraleap hand overlay", ref m_overlay); Valve.VR.OpenVR.Overlay.SetOverlayWidthInMeters(m_overlay, ms_overlayWidth); Valve.VR.OpenVR.Overlay.ShowOverlay(m_overlay); m_overlayTexture.eColorSpace = Valve.VR.EColorSpace.Gamma; m_overlayTexture.eType = Valve.VR.ETextureType.OpenGL; m_overlayTexture.handle = (IntPtr)m_renderTexture.Texture.NativeHandle; // Controls m_controlButtons = new List <ControlButton>(); m_controlButtons.Add(new ControlButton(ControlButton.ButtonType.Button, "a")); m_controlButtons.Add(new ControlButton(ControlButton.ButtonType.Button, "b")); m_controlButtons.Add(new ControlButton(ControlButton.ButtonType.Button, "system")); m_controlButtons.Add(new ControlButton(ControlButton.ButtonType.Axis, "thumbstick")); m_controlButtons.Add(new ControlButton(ControlButton.ButtonType.Axis, "touchpad")); }
public static Size GetActualSize(this SFML.Graphics.Sprite sprite) { uint width = (uint)(sprite.Texture.Size.X * sprite.Scale.X); uint height = (uint)(sprite.Texture.Size.Y * sprite.Scale.Y); return(new Size(width, height)); }
/// <summary> /// Calculates and sets the scaling value that will cause the the Sprite to be rendered at the size given by <paramref name="targetResolution"/> /// </summary> /// <param name="sprite"></param> /// <param name="targetResolution"></param> public static void SetResolution(this SFML.Graphics.Sprite sprite, Size targetResolution) { double scalingValueX = (float)targetResolution.Width / (float)sprite.Texture.Size.X; double scalingValueY = (float)targetResolution.Height / (float)sprite.Texture.Size.Y; sprite.Scale = new Vec2 <double>(scalingValueX, scalingValueY); }
public void BoundingBoxTest() { System.Console.Out.WriteLine("Running bounding box Test"); SFML.Graphics.RenderTexture MyTexture = new SFML.Graphics.RenderTexture(100, 100); MyTexture.Clear(SFML.Graphics.Color.White); SFML.Graphics.Sprite TestSprite1 = new SFML.Graphics.Sprite(); TestSprite1.Texture = MyTexture.Texture; TestSprite1.Position = new SFML.Window.Vector2f(0, 0); SFML.Graphics.Sprite TestSprite2 = new SFML.Graphics.Sprite(); TestSprite2.Texture = MyTexture.Texture; TestSprite2.Position = new SFML.Window.Vector2f(10, 10); Assert.IsTrue(Collision.BoundingBoxTest(TestSprite1, TestSprite2)); TestSprite2.Position = new SFML.Window.Vector2f(0, 200); Assert.IsFalse(Collision.BoundingBoxTest(TestSprite1, TestSprite2)); TestSprite2.Position = new SFML.Window.Vector2f(0, 100); Assert.IsTrue(Collision.BoundingBoxTest(TestSprite1, TestSprite2)); TestSprite2.Position = new SFML.Window.Vector2f(-50, -50); Assert.IsTrue(Collision.BoundingBoxTest(TestSprite1, TestSprite2)); }
public void updateScreen() { SFML.Graphics.Texture texture = new SFML.Graphics.Texture(Core.beakWindow.screen); SFML.Graphics.Sprite sprite = new SFML.Graphics.Sprite(texture); sprite.Scale = new SFML.System.Vector2f(2, 2); drawCanvas.drawFrame(sprite); }
public static bool BoundingBoxTest(SFML.Graphics.Sprite Object1, SFML.Graphics.Shape Object2) { OrientedBoundingBox OBB1 = new OrientedBoundingBox(Object1); OrientedBoundingBox OBB2 = new OrientedBoundingBox(Object2); return(BoundingBoxTest(OBB1, OBB2)); }
public static bool BoundingBoxTest(SFML.Graphics.Sprite Object1, SFML.Graphics.Sprite Object2) { OrientedBoundingBox OBB1 = new OrientedBoundingBox(Object1); OrientedBoundingBox OBB2 = new OrientedBoundingBox(Object2); // Create the four distinct axes that are perpendicular to the edges of the two rectangles SFML.Window.Vector2f[] Axes = new SFML.Window.Vector2f[4] { new SFML.Window.Vector2f(OBB1.Points[1].X - OBB1.Points[0].X, OBB1.Points[1].Y - OBB1.Points[0].Y), new SFML.Window.Vector2f(OBB1.Points[1].X - OBB1.Points[2].X, OBB1.Points[1].Y - OBB1.Points[2].Y), new SFML.Window.Vector2f(OBB2.Points[0].X - OBB2.Points[3].X, OBB2.Points[0].Y - OBB2.Points[3].Y), new SFML.Window.Vector2f(OBB2.Points[0].X - OBB2.Points[1].X, OBB2.Points[0].Y - OBB2.Points[1].Y) }; for (int i = 0; i < 4; i++) // For each axis... { float MinOBB1 = 0.0f, MaxOBB1 = 0.0f, MinOBB2 = 0.0f, MaxOBB2 = 0.0f; // ... project the points of both OBBs onto the axis ... OBB1.ProjectOntoAxis(Axes[i], ref MinOBB1, ref MaxOBB1); OBB2.ProjectOntoAxis(Axes[i], ref MinOBB2, ref MaxOBB2); // ... and check whether the outermost projected points of both OBBs overlap. // If this is not the case, the Seperating Axis Theorem states that there can be no collision between the rectangles if (!((MinOBB2 <= MaxOBB1) && (MaxOBB2 >= MinOBB1))) { return(false); } } return(true); }
public UserShipDrawable(UserShip data) { _sprite = new SFML.Graphics.Sprite(); _userShipData = data; _life = data._life; _sprite.Texture = new SFML.Graphics.Texture(data._shipSprite, new SFML.Graphics.IntRect(10, 10, 32, 32)); _sprite.Position = new SFML.Window.Vector2f(50, 50); }
public GeneralTexture(string texture, Vector2D position) { this.position = position; this.texture = GeneralTextureManager.GetTexture(texture); this.sprite = new SFML.Graphics.Sprite(this.texture); this.sprite.Position = this.position.InternalVector; }
public EnemyShipSprite(EnemyShip data) { _sprite = new SFML.Graphics.Sprite(); _enemyShipData = data; _sprite.Texture = new SFML.Graphics.Texture(data._shipSprite, new SFML.Graphics.IntRect(10, 10, 32, 32)); _sprite.Position = new SFML.Window.Vector2f(100, 0); }
public Apple() : base() { texture = new SFML.Graphics.Texture("Resources\\apple.png"); sprite = new SFML.Graphics.Sprite(texture, new SFML.Graphics.IntRect(0, 0, 30, 30)); Points = 1; //Console.WriteLine((random.Next() % 30) * 29); Position = new Vector2f(((random.Next() % 28) + 1) * 30, ((random.Next() % 18) + 1) * 30); }
public static bool CircleTest(SFML.Graphics.Sprite Object1, SFML.Graphics.Shape Object2) { SFML.Window.Vector2f Obj1Size = GetSpriteSize(Object1); SFML.Window.Vector2f Obj2Size = GetSpriteSize(Object2); float Radius1 = (Obj1Size.X + Obj1Size.Y) / 4.0f; float Radius2 = (Obj2Size.X + Obj2Size.Y) / 4.0f; SFML.Window.Vector2f Distance = GetSpriteCenter(Object1) - GetSpriteCenter(Object2); return(Distance.X * Distance.X + Distance.Y * Distance.Y <= (Radius1 + Radius2) * (Radius1 + Radius2)); }
public OrientedBoundingBox(SFML.Graphics.Sprite Object) // Calculate the four points of the OBB from a transformed (scaled, rotated...) sprite { Points = new SFML.Window.Vector2f[4]; SFML.Graphics.Transform trans = Object.Transform; SFML.Graphics.IntRect local = Object.TextureRect; Points[0] = trans.TransformPoint(0.0f, 0.0f); Points[1] = trans.TransformPoint(local.Width, 0.0f); Points[2] = trans.TransformPoint(local.Width, local.Height); Points[3] = trans.TransformPoint(0.0f, local.Height); }
public void drawSelecRect(SFML.Graphics.RenderWindow window, Vec2f topLeft, Vec2f bottomRight) { float Xstart = Math.Min(topLeft.X, bottomRight.X); float Xend = Math.Max(topLeft.X, bottomRight.X); float Ystart = Math.Min(topLeft.Y, bottomRight.Y); float Yend = Math.Max(topLeft.Y, bottomRight.Y); m_sprite = new SFML.Graphics.Sprite(Helper.t_DebugWhite, new SFML.Graphics.IntRect(0, 0, (int)(Xstart - Xend), (int)(Ystart - Yend))); m_sprite.Position = new Vec2f(Xstart, Ystart); m_sprite.Color = new SFML.Graphics.Color(0, 128, 0, 128); window.Draw(m_sprite); }
public horse(string Color) { if (Color == "White") { im = new SFML.Graphics.Image(WhiteImagePath); } else { im = new SFML.Graphics.Image(BlackImagePath); } text = new SFML.Graphics.Texture(im); sp = new SFML.Graphics.Sprite(text); }
public Button(string textToShow, SFML.Graphics.Font font, SFML.System.Vector2f position, SFML.Graphics.Texture normal, SFML.Graphics.Texture highlighted, SFML.Graphics.Texture pressed) { text = textToShow; sfmlText = new SFML.Graphics.Text(text, font); sfmlText.OutlineThickness = 1; sfmlText.OutlineColor = SFML.Graphics.Color.Black; normalTXT = normal; highlightedTXT = highlighted; pressedTXT = pressed; sprite = new SFML.Graphics.Sprite(normalTXT); sprite.Position = position; }
public void drawFrame(SFML.Graphics.Sprite newFrame) { if (InvokeRequired) { drawFrameDelegate del = new drawFrameDelegate(drawFrame); Invoke(del, new object[] { newFrame }); } else { renderwindow.Draw(newFrame); renderwindow.Display(); } }
public Sprite([NotNull] string image, [NotNull] int depth) { this.image = image; this.depth = depth; if (!image.Equals(string.Empty)) { pathImage = AssetManager.Load(image); sprite = new SFML.Graphics.Sprite(new SFML.Graphics.Texture(pathImage)); } OnDraw += Sprite_OnDraw; }
public Hero(Vec2f position, Map map) { m_texture = Helper.Hero; m_map = map; m_sprite = new SFML.Graphics.Sprite(m_texture, new SFML.Graphics.IntRect(0, 0, 80, 80)); // wie genau funzt das mit dem weiterschieben ? m_position = position; m_health = 200; m_enemy = false; m_active = true; m_speed = 5; lifecounter = 0; setBox(); }
public Ally(Vec2f position, Map map) { m_texture = Helper.Ally; m_map = map; m_sprite = new SFML.Graphics.Sprite(m_texture, new SFML.Graphics.IntRect(0, 0, 80, 80)); m_position = position; m_health = 110; m_enemy = false; m_active = false; m_controlable = false; m_speed = 3; lifecounter = 0; setBox(); }
public Enemy(int typ, Vec2f position, Map map) { m_texture = Helper.Enemy; if (typ == 1) { m_texture = Helper.Enemy2; } m_map = map; m_sprite = new SFML.Graphics.Sprite(m_texture, new SFML.Graphics.IntRect(0, 0, 80, 80)); m_position = position; m_health = 100; m_enemy = true; m_active = false; m_controlable = false; m_speed = 3; lifecounter = 0; setBox(); }
public void InitializeFields(Camera cam) { m_minimapSprite = new SFML.Graphics.Sprite(Helper.t_DebugWhite, new SFML.Graphics.IntRect(0, 0, (int)cam.m_minimapSize.X, (int)cam.m_minimapSize.X)); for (uint i = 0; i < m_fields.X; i += 2) { for (uint j = 0; j < m_fields.Y; j += 2) { m_map[i, j] = new Field((FieldType)(((i * i + j * 5) / 13) % 2), this.m_map, new Vec2f(i, j)); m_map[i + 1, j] = new Field((FieldType)(((i * i + j * 5) / 13) % 2), this.m_map, new Vec2f(i + 1, j)); m_map[i, j + 1] = new Field((FieldType)(((i * i + j * 5) / 13) % 2), this.m_map, new Vec2f(i, j + 1)); m_map[i + 1, j + 1] = new Field((FieldType)(((i * i + j * 5) / 13) % 2), this.m_map, new Vec2f(i + 1, j + 1)); } } for (uint i = 0; i < m_fields.X; i++) { for (uint j = 0; j < m_fields.Y; j++) { m_map[i, j].initialize(); } } }
public override void OnDraw(object window) { if (!DrawEnabled) { return; } Vector3 T; Quaternion R; Vector3 S; Node.GlobalTransform.Decompress (out T, out R, out S); // クォータニオンは指定したのと等価な軸が反対で回転角度[0,180]の回転で返ってくる事がある // ここで回転軸(0,0,-1)のものを(0,0,1)に変換する必要がある var angle = R.Angle; var axis = R.Axis; var dot = Vector3.Dot (axis, new Vector3 (0, 0, 1)); if (dot < 0) { angle = 360 - angle; axis = -axis; } var opacity = Node.Upwards.Aggregate (1.0f, (x, node) => x * node.Opacity); var spr = new SFML.Graphics.Sprite (); spr.Texture = Resource.GetDefaultTexture ().Data; spr.TextureRect = new SFML.Graphics.IntRect (0, 0, (int)radius*2, (int)radius*2); spr.Position = new Vector2f (T.X, T.Y); spr.Scale = new Vector2f (S.X, S.Y); spr.Rotation = angle; spr.Origin = new Vector2f (radius, radius); spr.Color = new Color (255, 255, 255, (byte)(127 * opacity)).ToSFML (); var win = window as SFML.Graphics.RenderWindow; win.Draw (spr); }
private static SFML.Window.Vector2f GetSpriteSize(SFML.Graphics.Sprite Object) { SFML.Graphics.IntRect OriginalSize = Object.TextureRect; SFML.Window.Vector2f Scale = Object.Scale; return(new SFML.Window.Vector2f(OriginalSize.Width * Scale.X, OriginalSize.Height * Scale.Y)); }
private static SFML.Window.Vector2f GetSpriteCenter(SFML.Graphics.Sprite Object) { SFML.Graphics.FloatRect AABB = Object.GetGlobalBounds(); return(new SFML.Window.Vector2f(AABB.Left + AABB.Width / 2.0f, AABB.Top + AABB.Height / 2.0f)); }
public SfmlSprite() { sprite = new SFML.Graphics.Sprite(); }
public SFMLSprite2DComp() : base() { SFMLShape = new SFML.Graphics.Sprite(); texture = new Texture(); }
public static bool PixelPerfectTest(SFML.Graphics.Sprite Object1, SFML.Graphics.Sprite Object2, byte AlphaLimit) { throw new System.NotImplementedException("missing bitmaskmanager"); }
public SfmlSprite(Texture texture) { sprite = new SFML.Graphics.Sprite(texture.GetTextureImplementation().GetInternal()); }
public void setGroundSprite(SFML.Graphics.Sprite sprite) { m_sprite_ground = sprite; }
public void initialize() { m_sprite_ground = Helper.Ground; m_sprite_minimap = new SFML.Graphics.Sprite(Helper.t_DebugWhite, new SFML.Graphics.IntRect(0, 0, 2, 2)); initializeStatics(); if (m_index.X - 1 >= 0) { m_4neighbors[0] = m_map[(int)m_index.X - 1, (int)m_index.Y].m_type; // left } else { m_4neighbors[0] = FieldType.Dirt; } if (m_index.X - 1 >= 0 && m_index.Y - 1 >= 0) { m_8neighbors[0] = m_map[(int)m_index.X - 1, (int)m_index.Y - 1].m_type; // upper left } else { m_8neighbors[0] = FieldType.Dirt; } if (m_index.Y - 1 >= 0) { m_4neighbors[1] = m_map[(int)m_index.X, (int)m_index.Y - 1].m_type; // upper } else { m_4neighbors[1] = FieldType.Dirt; } if (m_index.X + 1 <= m_map.GetLength(0) - 1 && m_index.Y - 1 >= 0) { m_8neighbors[1] = m_map[(int)m_index.X + 1, (int)m_index.Y - 1].m_type; // upper right } else { m_8neighbors[1] = FieldType.Dirt; } if (m_index.X + 1 <= m_map.GetLength(0) - 1) { m_4neighbors[2] = m_map[(int)m_index.X + 1, (int)m_index.Y].m_type; // Right } else { m_4neighbors[2] = FieldType.Dirt; } if (m_index.X + 1 <= m_map.GetLength(0) - 1 && m_index.Y + 1 <= m_map.GetLength(1) - 1) { m_8neighbors[2] = m_map[(int)m_index.X + 1, (int)m_index.Y + 1].m_type; // Lower Right } else { m_8neighbors[2] = FieldType.Dirt; } if (m_index.Y + 1 <= m_map.GetLength(1) - 1) { m_4neighbors[3] = m_map[(int)m_index.X, (int)m_index.Y + 1].m_type; // Lower } else { m_4neighbors[3] = FieldType.Dirt; } if (m_index.X - 1 >= 0 && m_index.Y + 1 <= m_map.GetLength(1) - 1) { m_8neighbors[3] = m_map[(int)m_index.X - 1, (int)m_index.Y + 1].m_type; // Lower Left } else { m_8neighbors[3] = FieldType.Dirt; } m_4neighborSum = (int)m_4neighbors[0] + (int)m_4neighbors[1] + (int)m_4neighbors[2] + (int)m_4neighbors[3]; updateSprites(); }
// Initialize stuff that can only be initialized when we have all the data from parsing items. public void Init() { this.texture = new SFML.Graphics.Sprite(new SFML.Graphics.Image(textureLocation)); this.topTexture = new SFML.Graphics.Sprite(new SFML.Graphics.Image(topTextureLocation)); this.texture.Width = 32; this.texture.Height = 32; this.texture.Image.Smooth = false; this.topTexture.Width = 32; this.topTexture.Height = 32; this.topTexture.Image.Smooth = false; }
private void LoadImageForShader_Click(object sender, RoutedEventArgs e) { Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.CheckFileExists = true; dlg.DefaultExt = ".png"; dlg.Filter = "Images (.png, .jpg, .gif)|*.png;*.jpg;*.gif"; bool? res = dlg.ShowDialog(); if (res == true) { BitmapImage shaderImage = new BitmapImage(); shaderImage.BeginInit(); shaderImage.UriSource = new Uri(dlg.FileName, UriKind.Absolute); shaderImage.EndInit(); PreShaderImage.Source = shaderImage; lock (ShaderControl.DrawLocked) { if (ShaderSprite != null) ShaderSprite.Dispose(); ShaderSprite = new SFML.Graphics.Sprite(new SFML.Graphics.Texture(dlg.FileName)); if (ShaderControl != null) { ShaderControl.DrawableSprites.Clear(); ShaderControl.DrawableSprites.Add(ShaderSprite); } } /* * BitmapImage AIcon = new BitmapImage(); AIcon.BeginInit(); AIcon.UriSource = new Uri(pathtest + "\\" + path, UriKind.Absolute); AIcon.EndInit(); ItemIcon.Source = AIcon; */ } }