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

Author Topic: relative transforms don't work  (Read 3857 times)

0 Members and 1 Guest are viewing this topic.

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
relative transforms don't work
« on: June 28, 2017, 07:41:34 pm »
hello every one
I want to create class cannon which is a class to simulate a real cannon
the cannon is represented by a rectangle shape
I want this rectangle to always work in relative transforms
the owner of the cannon must pass it's sf::transformable part of it in the constructor
and in the class i keep a reference to this sf::transformable
i think this should work but it is not
here a small program that do this ((not the real one the real one is a failure )) and it's  not working as expected
void main(){
        sf::RenderWindow window (sf::VideoMode(400,400),"cannon test 1");

        sf::RectangleShape ret(sf::Vector2f(30,30));
        ret.setPosition(200,200);
        sf::CircleShape circle(30);
        circle.setOrigin(30,30);
        circle.setPosition(0,0);
        sf::Transformable &ref = ret;
        while(true)
        {
                sf::Event event;
                while(window.pollEvent(event)){}
                sf::Transform tra =sf::Transform::Identity ;
                tra.combine(ref.getTransform());
                tra.combine(circle.getTransform());
                window.clear();
                window.draw(ret);
                window.draw(circle,tra);
                window.display();
        }
}
 
here the result
« Last Edit: June 30, 2017, 12:06:06 am by EGYPTIAN CODER »

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: relative transforms don't work
« Reply #1 on: June 30, 2017, 12:48:51 am »
why no one answer the question is simple

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: relative transforms don't work
« Reply #2 on: June 30, 2017, 07:34:42 am »
Please describe "not working as expected". What's the result, and what do you expect it to be?
Laurent Gomila - SFML developer

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: relative transforms don't work
« Reply #3 on: June 30, 2017, 08:54:39 am »
with the code above I expect
this

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: relative transforms don't work
« Reply #4 on: June 30, 2017, 09:00:14 am »
It seems like you apply the circle's transform twice (one is implicit when you draw it). Try this:

window.draw(circle, ref.getTransform());
Laurent Gomila - SFML developer

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: relative transforms don't work
« Reply #5 on: June 30, 2017, 10:01:29 am »
the  problem is solved
in online chat I tried to solve it twice and some of them just say we are sleeping
those people should be fired

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: relative transforms don't work
« Reply #6 on: June 30, 2017, 10:42:27 am »
Perhaps you should be "fired" for being very impolite and demanding?

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: relative transforms don't work
« Reply #7 on: June 30, 2017, 11:04:06 am »
I am just joking
they indeed help me alot

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: relative transforms don't work
« Reply #8 on: June 30, 2017, 11:16:20 am »
Fired from what?
You are aware that everyone is helping on out of their own feee will and their own free time?! Nobody is employed and you certainly have no right to feel entitled in receiving the help right the second you ask a question.
Most people who are active in the IRC channel are from west Europe so if you ask a question in the middle of the night, chances are that most are currently sleeping.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

EGYPTIAN CODER

  • Newbie
  • *
  • Posts: 32
    • View Profile
    • Email
Re: relative transforms don't work
« Reply #9 on: June 30, 2017, 11:25:39 am »
Fired from what?
You are aware that everyone is helping on out of their own feee will and their own free time?! Nobody is employed and you certainly have no right to feel entitled in receiving the help right the second you ask a question.
Most people who are active in the IRC channel are from west Europe so if you ask a question in the middle of the night, chances are that most are currently sleeping.
I totally agree I know that very well
I just wanted  to say a joke and I  really sorry, I didn't  mean to harm anyone in this forum
again  :-[

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: relative transforms don't work
« Reply #10 on: June 30, 2017, 11:37:54 am »
It's fine then. For jokes online, I highly recommend using some emoticon (e.g. ;) [emoji14] ) to indicate that it's not a serious statement or adding some "hehe"/"haha", to show that it's supposed to be a joke.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/