2D images with rotation

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.

Re: 2D images with rotation

Postby swesoulc » Mon May 28, 2012 8:04 pm

Your test contains just the .exe, but for anyone to debug this we would need code to reproduce it (and with code I mean certainly an example that is already reduced to just the problem, not some large project with all the code).

yes, my purpose with the exe, as i stated , Was to Just Display the result.
I've uploaded a small exe to demonstrate my problem.

i never even opted for anyone to bug search my code. Since the only thing i did was change my previous draw function to this one, and i have had no problem with the rest of the code for well about 2 years, my thoughts go to that the problem is somewhere within the newly added code. And since my project spans way, Way more then one file... To share the code would be quite tideus. Code that i myself have a hard time putting my head around at times. I would actually never request that of this community ( i have Some pride atleast )

I have mearly been asking if this issue have been know by the original coder.
If anyone hase had this problem before and found a work-around.
if anyone would like to declare me stupid and say that it is obviously the rect i toss to the function that is broken. ( i can go through those for a seventh time, if it would make anyone feel better )
If it is the recalculating of coordinates that gets screwed up because i havn't set a camera.
Basicly anything.

thank you though CuteAlien for your reply, however degrading it now was.
swesoulc
 
Posts: 17
Joined: Tue Apr 03, 2007 10:05 am

Re: 2D images with rotation

Postby CuteAlien » Mon May 28, 2012 10:17 pm

Uhm, sorry, this wasn't meant to be degrading. I just wanted to tell you the fastest way to get better help, don't take this personal. This is pretty much the standard info we give out, the fact that it didn't tell me anything was more or less implicit already when I asked for sources. When you have the feeling that I'm describing it too detailed (the stuff about reducing it first) just put it to the fact that in a forum with many beginners 9 out of 10 just don't know this stuff (and the 10th is pissed of because he thinks we make fun of him telling him obvious stuff... that's life).

So, can't help - haven't seen a bug exactly like this with draw2DImage, but well - maybe someone else thinks this looks familiar from screenshots. But maybe post a little of your code around the trouble function in case it's something obvious which you just don't see because you stared at it too long already :-)
IRC: #irrlicht on irc.freenode.net
My patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Games with Irrlicht: http://www.irrgheist.com/
News: http://www.reddit.com/r/irrlicht/
User avatar
CuteAlien
Admin
 
Posts: 5364
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: 2D images with rotation

Postby swesoulc » Tue May 29, 2012 7:31 am

Well thank you again cutealien

EDIT (entire post deleted )

Thanks for putting up with me. Problem solved. I have declared myself an idiot. draw2dimage works fine. The problem was that i had been staring at the code for too long, and forgot to look at the texture. Would you belive that a image not in 100x100 don't look too good when you try and put it out as such.

will be going back to my former post to remove images and links.
swesoulc
 
Posts: 17
Joined: Tue Apr 03, 2007 10:05 am

Re: 2D images with rotation

Postby zhengxianfu » Sun Jun 03, 2012 3:08 pm

Lonesome Ducky wrote:I have written the completed version of this snippet. I have incorporated all fixes mentioned, and optimized it from 8 sin/cos calls to 2, so it is less computationally intensive. The code is also cleaned up a bit and should be easier to understand. Here you go! :D



Thanks very much.I use it into my project .Great Job!
zhengxianfu
 
Posts: 16
Joined: Thu Apr 05, 2012 9:33 am

Re: 2D images with rotation

Postby Catprog » Sat Jul 14, 2012 6:14 am

I am getting a bit of jitter as well. BackOfMap,FrontMap are the two textures. left,right,top,bottom are where it is being drawn. frame is what step it is on.

cpp Code: Select all
    void draw(irr::scene::ISceneManager* smgr )
    {
 
        core::dimension2d<u32> texSize = BackOfMap->getSize();
 
        cImage* mapFront;
 
 
        cImage* mapBack;
 
 
        bool needCleanup=false;
        if(Frame<=.99)
        {
 
 
            u32 diffrence = (right-left)*(Frame);
            u32 RightText = texSize.Width*(Frame);
            u32 revRightText = texSize.Width*(1-Frame);
 
            f32 halfOfRolling =texSize.Width*.1f/2;
 
            u32 WidthOfScreenScroll = (right-left)*.1f;
 
 
 
            mapFront=new cImage(FrontMap,
                                core::rect<s32>(left,top,left+diffrence,bottom),
                                core::rect<s32>(0,0,RightText ,texSize.Height));
 
 
            u32 rightOfMap = (right-left)*(.2+Frame);
            if(rightOfMap>=right) rightOfMap=right;
            s32 leftOfMap = rightOfMap-(right-left-diffrence);
            if(leftOfMap<left) leftOfMap=left;
 
            f32 SizeOfShownMap=(rightOfMap-leftOfMap);
 
            u32 RightTex  = ((SizeOfShownMap/(right-left)))*texSize.Width;
 
 
 
            mapBack=new cImage(BackOfMap,
                               core::rect<s32>(leftOfMap,top,rightOfMap,bottom),
                               core::rect<s32>(0,0, RightTex,texSize.Height));
 
 
            needCleanup=true;
        }
        else
        {
 
            mapFront=new cImage(FrontMap,
                                core::rect<s32>(left,top,right,bottom),
                                core::rect<s32>(0,0,texSize.Width,texSize.Height));
 
            needCleanup=false;
 
 
        }
 
        mapFront->Draw(smgr);
 
        if(Frame<=.99)       mapBack->Draw(smgr);
 
 
        if(needCleanup)        delete mapBack;
 
        delete mapFront;
    }
Catprog
 
Posts: 162
Joined: Wed Jan 31, 2007 9:07 am

Re: 2D images with rotation

Postby Lonesome Ducky » Sun Jul 15, 2012 7:09 pm

Please make sure to use the code in the very first post in this thread. The code you're using is my first revision and is, quite frankly, terrible :lol:
User avatar
Lonesome Ducky
Competition winner
 
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Re: 2D images with rotation

Postby arnir » Wed Sep 05, 2012 12:09 pm

genial! really thanks!
programmer is bad designer
designer is bad programmer
arnir
Competition winner
 
Posts: 134
Joined: Sat Jan 20, 2007 4:36 pm
Location: Czech Republic

Previous

Return to Code Snippets

Who is online

Users browsing this forum: No registered users and 0 guests