Inserting a jpg image and rotating it?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Inserting a jpg image and rotating it?

Post by Ravi08 »

I was wondering if it is possiable to insert a jpg image and then rotate it.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

what do you mean by insert a jpg?

you want to draw a jpg onscreen and rotate it?

you can't get this functionality with draw2Dimage so i think you'll have to create a quad and apply the texture to it and then rotate that.

you can create a quad by creating a very simple hillplane node (check the smgr API) and then setting the texture and rotating the node.
Image Image Image
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Post by Ravi08 »

ok thanks for the help. Soz about the u beibng confused. Ill explain, u know last week i asked how i can animate a car and u said rotating the wheels. Well one of my models uses texturing i think its called UV texture or something so this means that my model doesnt hav a seperate wheel model instead the wheels are a jpg image of a wheel that when u look at the model it looks like they are 3d.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

well you'll have a very hard time rotating that i should think... although you could just get the wheel texture and overlay it, so draw that quad i mentioned above just in front of the wheel part of the model.
Image Image Image
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Post by Ravi08 »

ok thanks. Just one more thing, which is i hav another model but this time i hav saved the wheels as a mesh so i can load them separately and was wonderin how to animate em cause last time u gave me code to just rotate, is there a way where they keep rotating so it looks like the wheels are rollin.

THANKS
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

As i said before, you just rotate them a little bit more each frame. The extra amount that you rotate them each frame depends on how fast you want them to appear to move.

So
frame 1: rotate them 1 degree maybe
frame 2: rotate them 2 degrees maybe

so something like this:

Code: Select all

void rotateWheel() {
  static float rotation = 0;
  wheelNode->setRotation(vector3df(rotation,0,0)); // or on the z axis if necessary
  rotation++;
}
Image Image Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

In case the wheels are using a separate material you can also use the texture matrix to rotate the texture around the mesh. You'll have to check whether the effect is really intended, but it might work.
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Post by Ravi08 »

ok thanks both of u for helpin
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Post by Ravi08 »

sorry for keep askin but i hav added that code and got 2 errors.

this is wat i hav:

Code: Select all

    {
    void rotateWheel()
      static float rotation = 0;
      node3->setRotation(vector3df(rotation,0,0)); // or on the z axis if necessary
      rotation++;
    }
the first error is on the static line it says expected initalizer before "static"
the second error is on the line below and it says 'Rotation' was not declared in this scope.

the first error i dont really understand but i can remember me gettin a few of them wen i was doin a java project. the second error just confuses me cause i hav declared rotation in the static line.

i added the code in the main class so int main below where i add my nodes, thats where i got my 2 errors. Then i copyed the same code and added it before the int main and worked but there was no rotation and yes i changed all the numbers.

I dont mind which one u help with just plz help.
djzmo
Posts: 24
Joined: Sun Jul 20, 2008 3:20 pm
Location: Mercury

Post by djzmo »

it must be

Code: Select all

    void rotateWheel()
    {
      static float rotation = 0;
      node3->setRotation(vector3df(rotation,0,0)); // or on the z axis if necessary
      rotation++;
    }
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Post by Ravi08 »

ok thanks.

I tried that at the top and it accepted it but no rotation and wen i tried it in the int main, it reject it.
djzmo
Posts: 24
Joined: Sun Jul 20, 2008 3:20 pm
Location: Mercury

Post by djzmo »

Ravi08 wrote:ok thanks.

I tried that at the top and it accepted it but no rotation and wen i tried it in the int main, it reject it.
what? inside the int main?
I think it's better for you to learn the basics of C++ before start using Irrlicht.
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Post by Ravi08 »

well int main is the main method but u can also add classes before it and that code i hav tried in the int main method and before this method. One of em comes up with an error and the other doesnt do anything
Ravi08
Posts: 249
Joined: Thu Jul 17, 2008 12:25 pm

Post by Ravi08 »

do u think im missin a namespace or something?
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

Ravi08 wrote:do u think im missin a namespace or something?
I think you're missing the very basics of C/C++ !!! :roll:
you should realy learn this first of all !!!

http://www.cplusplus.com/doc/tutorial/
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Post Reply