Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Hapax

Pages: 1 [2] 3 4 ... 224
16
General / Re: Can't change shape's attributes outside of int main()
« on: February 14, 2024, 08:35:02 pm »
I think I was slightly confused by your mention of it working only in main.

Could you provide a small example* code of what you mean?
*A complete and minimal example would be great if possible.

17
Graphics / Re: LineStrip VertexArray and ConvexShape problem
« on: February 14, 2024, 04:32:55 pm »
I'm glad you've at least tried Selba Ward; it is there for people to use!

I mentioned Spline only as a simple and easy way to draw a polygon's outline. Simply export Polygon's positions and set all Spline's positions from that export. Remember to close the Spline. You can also use a thickness for Spline so the outline is no longer infinitely thin (and drawn as a pixel thickness). You can also round the corners. Note that Spline creates the entire polyline as a single object and draws it with a single draw call whereas drawing multiple sf::RectangleShapes (one for each edge) is one draw per edge. FYI, Selba Ward's Line can also draw a simple line with or without thickness and also used to use sf::RectangleShape internally but was replaced by custom vertex array. Still, Spline's better ;)

Another thing to note is that if anything in Selba Ward isn't generic enough to be useful in multiple scenarios, I'd like to consider updates and improvements, and if anything is completely missing from Selba Ward, I consider adding it.
Selba Ward is still improving and Polygon is actually pretty new so somethings are yet to come.

My responses were to help with the creation of the object that you were having trouble with. Hope you at least got that shape made! Note that I didn't mention Selba Ward at first and tried to explain how to create the object yourself. :)

My point about any complex being able to be represented by triangles still stands. However, this is separate from being able to triangulate from a given set of points. Does the "butterfly shape" have holes? Polygon can handle holes but must be informed where they are; hole vertices must also be in opposite (clockwise) direction. In addition, the triangulation method must be set to "EarClip" rather than the more simple "BasicEarClip" to be able to handle the holes. Note that Polygon can only handle "simple polygons"; that is, a polygon that never crosses itself. Holes are technically not part of a "simple polygon" but Polygon converts it into a simple polygon first (as a bonus!).

If you could provide the vertices for the "butterfly shape" and an image of what it should look like, I'd like to do some tests.

It's worth noting that Polygon is designed to be a way to provide a filled polygonal area from a set of points representing its boundary. It's not, however, designed to have visual effects that manipulate those points (such as corner rounding). Those effects should be done separately and given to Polygon to create the shape. In fact, Spline can do this; it can handle Bezier curves and can export its interpolated position so a curved boundary could be created in Spline and then passed to Polygon to create the shape.
It was considered to have a base for both Spline and Polygon as they have similar concepts but decided against so that each Selba Ward drawable can be used independently.

Reading what you wrote about the "butterfly shape" again, I realise that you are creating a polygon where edges cross. This is not a simple polygon and cannot be handled automatically by Polygon. It breaks the rule that vertices must be passed in the same direction. The "butterfly" has vertices in both clockwise and anti-clockwise directions.
Probably better to not have allowed a polygon definition to do this than to try to fix it when the mistake is made.
This could be considered "ill-formed" as it has a "twisted" and not flat face. In fact, if that shape (like a bow-tie, I'm imagining) is required, it can be created; the point in the centre should be included since it exists. It would basically be 6 vertices (5 different ones) which would be the rectangle (in anti-clockwise direction) with the centre vertex between the two vertices of each opposing edge (either top and bottom or left and right).
It could be thought of this way: why is a shape with 2 triangles trying be defined without giving one of the points of each triangle?

Pre-processing can "fix" this. It can already be done before giving the points to Polygon (by specifying them correctly) but features that check and/or adjust for this could be included in Polygon at a later time.

As an aside, Polygon should, in the future, also be able to use monotone triangulation (uses scanline).

I hope I've addressed your questions and helped with your issues. If I missed anything, feel free to let me know.
Also, I'm open to ideas for Polygon and also, more generally, Selba Ward.


EDIT (2024/02/15):
Selba Ward's Polygon can now (as of v1.4), in fact, also work points that are in a clockwise order!
And more!
For more info, see this: https://github.com/Hapaxia/SelbaWard/pull/46

18
General / Re: Can't change shape's attributes outside of int main()
« on: February 14, 2024, 01:00:07 am »
Glad you got it to work!  :)

First thing to note is that SFML objects shouldn't be global. It's not clear whether you mean this or not.
e.g. this is BAD:
sf::RenderWindow window;
int main()
{
}
The objects should be created inside the main function:
int main()
{
    sf::RenderWindow window;
}
It's still okay to create an object elsewhere as long as it still called by main:
sf::RenderWindow* createRenderWindow()
{
    sf::RenderWindow* pWindow = new sf::RenderWindow;
    return pWindow;
}
int main()
{
    sf::RenderWindow* pWindow = createRenderWindow();
}
Note that a pointer was used here for simplicity but this is not the safest way to do it. Use a smart pointer if you do it this way.

It's usually better to create them and then pass them:
void createRenderWindow(sf::RenderWindow& window)
{
    window.create(sf::VideoMode(960u, 540u), "");
}
int main()
{
    sf::RenderWindow window;
    createRenderWindow(window);
}

You don't need to pass objects back if you're using them temporarily:
void loadAFontButThenThrowItAway()
{
    sf::Font font;
    font.loadFromFile("fonts/arial.ttf"); // I am not checking whether it loads or not for simplicity and since it does not really matter here but you should always do that!
}
int main()
{
    loadAFontButThenThrowItAway();
}


With all that said, another thing to consider is that SFML needs to be included before using an object so, if you're doing something in a separate file, you'll likely need to include SFML headers from that file too.

19
General / Re: Can't static link SFML
« on: February 13, 2024, 06:32:14 pm »
Hello
Hello! :)

linking the SFML library statically in Visual Studio 2022
I downloaded the WinLibs MSVCRT 13.1.0
The WinLibs are for the MinGW compiler. Since you're using the latest version of Visual Studio, those are not needed and the download 'does not need to match 100%'.
With the rest of the information of your configuration, can we presume that you downloaded this one: "Visual C++ 17 (2022) - 32-bit"?

In addition, don't forget to define the SFML_STATIC macro in Preprocessor Definitions (when building statically).

20
Graphics / Re: LineStrip VertexArray and ConvexShape problem
« on: February 13, 2024, 06:21:38 pm »
Polygon requires anti-clockwise due to the calculations testing angles based on inside/outside. It could be adjusted to work with clockwise by swapping angles and sides but the ability to do both is extra calculations for both ways. However, Polygon can reverse them for you so you can provide them as clockwise and reverse them.
Maybe a future update would have the ability to do both by traversing the points in both directions.
Polygon's next update will have colour and texture; that's already ready but I'm looking into other methods and mesh refinement as well as other improvements.
An outline was considered for polygon but since it exports its positions, this can be generated super-easy, especially with Spline (also Selba Ward), which takes those exported positions directly.

With your implementation, remember that resizing the window doesn't automatically resize the view. Maybe that is involved.
https://www.sfml-dev.org/tutorials/2.6/graphics-view.php#showing-more-when-the-window-is-resized

I can't really say why your tone is shifting. I wonder if it may be because it's on a different part of the display and the angle of viewing is different...

And yes, every complex shape can be represented by triangles.
If you have any vertex array shape (not the points or lines primitives) then you can easily extract its triangles:
https://github.com/SFML/SFML/wiki/Source%3A-Triangles-Extractor

21
Graphics / Re: LineStrip VertexArray and ConvexShape problem
« on: February 12, 2024, 09:04:50 pm »
It's important to realise that Selba Ward's Polygon can do this shape automatically, by the way (both triangulation methods work):

However, the order of vertices are VERY important. They absolutely must be in a consistent order around around the perimeter and in an anti-clockwise/counter-clockwise direction. It's best not to duplicate vertices too.
(if they are in the wrong order, you can tell Polygon to reverse their order: reverseVertices)
NOTE: I added the wireframe in the example to show how Polygon triangulated it but it's wasn't a part of the actual Polygon. However, a recent Polygon update allows these wireframes automatically.

22
General discussions / Re: iOS and ANdroid support?
« on: February 08, 2024, 03:35:58 pm »

23
General / Re: Can't get SFML on VS 2022
« on: February 08, 2024, 03:32:56 pm »
As a default, the compiled executables are in folder in the solution root (note: not the project; all projects compile to the same folders).
x86 (32-bit) compilations will be under the configuration-type folder (e.g. Debug, Release)
x64 (64-bit) compilations will be under the folder x64 and then under the configuration-type folder (so, x64/Debug, x64/Release).

This is the default so is a good place to look. You can, however, alter these per project or even per configuration but it's not often necessary to do so.

24
It's common to see operator < being used when sorting is involved as that's how most sorting decides on the order: "is it less than? yes, then it goes first."

You are using std::set and this stores things in order. Your set has sf::Colors. The question is: how do you sort colours? The set will be asking the same question: "is this colour less than that colour? if yes, it goes first". But wait! How can an sf::Color be "less" than another sf::Color?

You can still do it in a set but you will need extra work. For example, you could put each colour in a struct and define its < operator, then use that struct in the set. You could also add to the struct a value that would allow you to give values to each colour, allowing them to be in a specific order.

However, I think it's unlikely you actually want to order the colours so maybe the unordered version of the set is what you actually want:
https://en.cppreference.com/w/cpp/container/unordered_set

With that said, if you're just storing them, would just a standard vector not be sufficient?

25
DotNet / Re: Mouse Scroll Direction
« on: February 07, 2024, 10:39:12 pm »
Does this mean you have two wheels or maybe a multi-directional ball/wheel?

No, many mouses (that i know) support pressing your mouse wheel to the side to scroll sideways
1. I have only one mouse wheel, so I don't need to check which wheel is being scrolled (for now).
This is exactly what I meant by multi-directional wheel.
Up and down scrolling is a wheel scroll and left and right will likely be a separate wheel scroll. This would mean that it would be giving the information to the driver (and then to your OS and then to you via SFML) as two separate wheels.
This brings me to believe it would be a good idea to the check which wheel.

In addition, are you certain that the only time this function is called is when the event type is correct?
Assuming you mean Project.ZoomView(), yes that is only called from that event, since it is a binding for the EventHandler Class (Which contains the event handling functions).
No, actually. Project.ZoomView was not to what I was referring.
Rather, the code that called OnMouseScroll.
I'm guessing (because this is C#) that this is called by the action of a mouse scroll so it should be okay but I would wonder if other SFML event types are getting passed into OnMouseScroll as it doesn't actively check its type to make sure and using the event if it's the incorrect type can "give bad values" - to state it casually.

26
DotNet / Re: Mouse Scroll Direction
« on: February 07, 2024, 05:21:28 pm »
I have an issue with my mouse that sometimes scrolls in the wrong direction. This is just a bad mouse though; it's certainly not SFML. It's probably not this though.

You mentioned scrolling up, down, left and right.
Does this mean you have two wheels or maybe a multi-directional ball/wheel?
Note that, per wheel, it can only go in one direction: positive or negative.
It also doesn't look like you're checking which wheel is being scrolled.

In addition, are you certain that the only time this function is called is when the event type is correct?

27
General / Re: Can't get SFML on VS 2022
« on: February 07, 2024, 05:13:34 pm »
Remember that those properties are "per project" and have to set each time so if you've start a new project since setting the properties, you'll need to set them again.

For your issue, I'd be checking the headers/include directory to make sure they are where you told VS they are (in your project properties).

Note that you if you set these properties for one configuration (release, for example) then they won't be set for the other (debug, for example). You can set multiple configurations at once but remember that some properties need to be set differently for each configuration.

Are you using double-quotes or angle brackets for your inclusion?

28
This is pretty impressive. Nice work! :o

I see you're also encountering the age-old SFML issue of textured quads rotating in 3D space. ;D
Because they're treated as triangles and not as quads, the textures have no knowledge of the point from the other triangle so cannot interpolate as if perspective. You can see this (it's subtle) in your videos. I've managed to find a couple of solutions to this (subdivision or shader per quad) but I've not ventured into large-scale applications of this so I wish you luck with that! Obviously shader per quad could be excessive (one draw call per quad and can't easily be drawn behind everything else) and subdivision can stack the number of those triangles up very quickly!
My examples (as part of Selba Ward) of those two methods are here: Sprite 3D (subdivision) and Elastic Sprite (perspective shader) and you may find them useful while looking for your own solution
It genuinely might be better to get better looking coloured objects than using textured quads but it depends on your intent (or just your interest of looking for problems to solve!)

29
It's also worth noting that the Render Window is global. SFML resources should never* be global objects.

*However, pointers are okay as long as they're initialized as a null pointer. This is because you decide when to create the object meaning that they get called after main has started in a similar way to if it was created from inside main. (you can basically create it as the first line of main)

30
Graphics / Re: RectangleShape.getPosition always returns 0 for value
« on: February 07, 2024, 04:37:53 pm »
I'm not sure if there are extra settings for the window i have to set up if i'm on a Mac, but it seems odd to me that it reports the mouse position as (0, 2100) in the up left corner, which normally would be (0, 0)

How are you receiving these mouse co-ordinates? Events (check that you're using the right part of the union) or real-time values (remember to add the window as a parameter to make it local co-ordinates).

I mention the local co-ordinates even though I believe all Mac apps are technically full screen (I think... right?) because it might be affected by a multiple monitor set-up.

Pages: 1 [2] 3 4 ... 224
anything