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 - boniomri

Pages: [1]
1
General / Re: Importing shaders from shaderstoy
« on: January 08, 2016, 06:29:13 pm »
Thank you both so much!

Just to make sure I understand what you mean Ztormi, what I have to do is basically copy the code into a "something.fragment" file, then pass parameters that I see being used in the code?
In this example would I be sending a sf::Vector3f to iResolution?
Since I only see iResolution being used in the code out of that list.

As for your GLSL is pretty easy comment, looking at the code it does look abit intimidating, but I don't have enough time to learn it until I hand in the project.
Essentially I don't need shaders, I just thought it would be a cool extra to have and also because I have never had the chance to mess around with shaders, so I jumped on the "lets try it 2 weeks before I hand the project" train.
Thanks again though.

2
General / Importing shaders from shaderstoy
« on: January 08, 2016, 12:19:41 pm »
I have been trying to mess with shaders on my project recently and I encountered  afew problems.
Firstly I am a total noobie with shaders and sfml so excuse me if I state things that are wrong, I probably understood info I read incorrectly.

I saw there is a site called shaderstoy and I tried to figure out how to implement shaders from the site into my project. I read the sfml wiki about shaders, I got the SFML code part, although I'm not sure what to do on the shaders side.
What file to create with the code from the site, what parameters to pass etc.
For example this shader:
https://www.shadertoy.com/view/MsjXzh

How would one implement it and know what parameters to pass to it?

Again, sorry if I said stuff that made you cringe from my lack of knowledge in this department.
I just couldnt find lots of info regarding my question, I hope I was clear.

3
General / Re: Point values of the edges of a sprite
« on: December 13, 2015, 03:39:14 pm »
Quote
And for you question, "What dosent work?", well, everything ::)
Solving a problem involves trying to understand exactly what's going on, not just rolling eyes on the forum :P

Since you have the debug shape displayed, it should be easy to see how it is wrong: is the shape scaled? offseted? rotated? I can't believe it's totally random compared to what it's supposed to be.
I didn't understand what was going wrong, that's why I'm here asking this question  :-\
As for the debug shape, it dosent even show, so thats why I said it's something with the math probably.

I know nothing about tmx, anyway the problem might be in your collision checking itself. If I get you right you try to check collision of rotated rectangles the same way you do for unrotated ones. Can you show your method?
The method is fine, I have tested it lots of different times.
I only have to find a way to find the points. Thank you though :).

4
General / Re: Point values of the edges of a sprite
« on: December 13, 2015, 02:00:30 pm »
Your problem was already clear enough. If what was suggested doesn't work, then tell us what's wrong exactly and show your code, instead of re-explaining your initial problem ;)

This is the function I implemented using the technic you gave me:
tmx::MapObject Player::GetFutureRect()
{
        sf::FloatRect rect = this->getLocalBounds();

        sf::Vector2f topLeft(rect.left, rect.top);
        sf::Vector2f transformedTopLeft = this->getTransform() * topLeft;
        sf::Vector2f topRight(rect.left+32, rect.top);
        sf::Vector2f transformedTopRight = this->getTransform() * topRight;
        sf::Vector2f bottomLeft(rect.left, rect.top+32);
        sf::Vector2f transformedBottomLeft = this->getTransform() * bottomLeft;
        sf::Vector2f bottomRight(rect.left+32, rect.top+32);
        sf::Vector2f transformedBottomRight = this->getTransform() * bottomRight;


        tmx::MapObject mo;
        mo.SetPosition(transformedTopLeft);
        mo.AddPoint(transformedTopLeft);
        mo.AddPoint(transformedTopRight);
        mo.AddPoint(transformedBottomRight);
        mo.AddPoint(transformedBottomLeft);
        mo.CreateDebugShape(sf::Color::Magenta);

        return mo;
}

And for you question, "What dosent work?", well, everything  ::)
They just not collide for some reaso (probably something with my math).

5
General / Re: Point values of the edges of a sprite
« on: December 13, 2015, 09:40:36 am »
I think I need to re-explain my problem.
I am using the tmxloader to create MapObject to be able to check collisions around my map.

This is an illustration of a map and a player inside it:
http://i.imgur.com/cDzCcsJ.png

My current collision checking is based on my globalBounds, meaning, it will generate a sf::FloatRect with the global bounds of my sprite and it will pass the tmx::MapObject 4 points based on the float rect.
So I end up with something like this (red=collision rect, blue=actual player and purple is a object to check if they are colliding):
http://i.imgur.com/i6f0ZH4.png

Basically what happens there is that the red rectangle identifies a collison when in reality they didnt collide yet.
The solution for this problem is of course to put the points exactly on the edges of the rectangle.
Afaik, there is no option to rotate a tmx::MapObject.

I'd appreciate any help, I have tried what you guys suggested but it dosent seem to work properly (maybe I implemented wrong).

This is my original function:
tmx::MapObject Player::GetRect()
{
        sf::FloatRect fr = this->getGlobalBounds();
        sf::RectangleShape rs;
        rs.setPosition(this->getPosition());
        rs.setSize(sf::Vector2f(32,32));
        rs.setOrigin(16, 16);
        rs.setRotation(this->getRotation());

        tmx::MapObject mo;
        mo.SetPosition(sf::Vector2f(fr.left, fr.top));
        mo.AddPoint(rs.getPoint(1));
        mo.AddPoint(rs.getPoint(2));
        mo.AddPoint(rs.getPoint(3));
        mo.AddPoint(rs.getPoint(4));
        mo.CreateDebugShape(sf::Color::Magenta);

        return mo;
}
 

I hope I was clear enough now.

6
General / Point values of the edges of a sprite
« on: December 12, 2015, 02:23:12 pm »
I have a square shaped sprite that is sometimes rotated.
I want to get the x,y cords of all the edges of that certain sprite even when its rotated.
What is the best way to do so?

Illustration to show what I mean (32x32 square):
http://i.imgur.com/YweUiAT.png

7
I step-by-stepped the program, the if statement does return true. I will check your solution as soon as I get home and report back. Thank you for the detailed answer!

Edit: Fixed by making the spawn points using the polygon tool instead of just the rect tool.
Shitty workaround, but thats the only way it seems to work.

8
I made an Object Layer in tiled with afew spawn points.
I have been trying to use this code to iterate through the spawn points but it dosent seem to work.

if (type.find("enemy") != std::string::npos)
        {
                for (auto layer = ml->GetLayers().begin(); layer != ml->GetLayers().end(); ++layer)
                {
                        if (layer->name == "spawns")
                        {
                                for (auto object = layer->objects.begin(); object != layer->objects.end(); ++object)
                                {
                                        std::unordered_map<std::string, Entity*>::const_iterator it = this->map.find(type);
                                        while (it != this->map.end())
                                        {
                                                if (it->second->getPosition() != object->GetPosition())
                                                {
                                                        e->setPosition(object->GetPosition());
                                                        return 1;
                                                }
                                        }
                                        return 0;
                                }
                                break;
                        }
                }
        }
It wont go inside the second for-loop for some reason.
This is the object group located in the tmx file:
 <objectgroup name="spawns">
  <object id="18" name="spawn" x="390" y="225"/>
  <object id="20" name="spawn" x="642" y="225"/>
  <object id="21" name="spawn" x="390" y="515"/>
  <object id="22" name="spawn" x="642" y="515"/>
 </objectgroup>
 

I thought since the collision code that he showed in his Github wiki page was pretty similliar with what I was trying to do, I'd use it for getting the spawn locations aswell.

Link to the git : https://github.com/fallahn/sfml-tmxloader

9
General / Help with Fallahn's tmx loader
« on: November 10, 2015, 02:27:31 pm »
Hey,
I have been experiencing problem when trying to use the tmx loader in my project.
If anyone could explain what I have to include/link to my project and what am I supposed to do with zlib, it'd be amazing!

That's the github link:
https://github.com/fallahn/sfml-tmxloader

Pages: [1]
anything