How to make a scrolling texture for conveyor belt

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

How to make a scrolling texture for conveyor belt

Post by pfo »

I've got a problem that's got me stumped: if I made a conveyor belt, how could I get the texture to scroll? I tried going through the vertices each frame and adjusting the UV coords, but getVertices() doesn't get the render buffer vertices. I suppose I could modify the engine to expose the render buffer vertices, but I'd rather not do that.

Another approach I thought of is using shaders, but I don't think it's possible for a shader to know what direction each conveyor is going in and how fast, unless I made conveyor belts move in only 1 direction at only 1 speed (boring....)

Anyone else got any ideas?
Aquarius

Post by Aquarius »

I had the same problem when i was trying to improve the water-node. Its absolutely annoying that i did not find a way to adjust uvs. An animated texture or shaders are simply not the same.
Maybe some good soul who knows how has merci....












So you think you can tell, heaven from hell....
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Use Emil Halim's Magic 2D library, its really awesome.

A bit hard to understand when you dont know whats in the library, but Emil is very nice and he will help ya out.
Guest

Post by Guest »

Ya saying his 2d library has code to scroll textures in 3d on meshes?
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

His library allows you to make scrolling textures and save them so that you can apply them to 3D meshes...yes :)
Guest

Post by Guest »

Assuming that a) Irrlicht lets you specify tiled textures and b) lets you modify the texture matrix the easiest way short of a vertex shader would be to apply a translation to the texture matrix (but reset it every once in a while before the values become too ridiculous).
peterparker
Posts: 11
Joined: Mon Nov 28, 2005 5:00 am
Location: N.Y.

texture matrix support would be very nice

Post by peterparker »

I have to agree to Guests statement:
an Interface to the texture matrix would be very nice. Also some Quake3 shader can be supported more easy and a lot of vitality would be added to models and scenes if it were possible.

Peter
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Try out the Magic library before you bust out your shaders. I think it may solve your problems and give you some more speed.
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

Krama: I took a look at the Magic 2D library, and it's not clear to me what I could use in it to scroll a texture. Besides that, it works mostly with OpenGL, and what would I do for DirectX then?

Guest: (a) is correct, (b) I have no idea how to get that matrix, if I could find it somewhere and expose it that would save the day for me.

It's sad because I got the physics of the conveyor belt working, you'd think the scrolling texture would be easier.

Edit: more problems, this particular mesh buffer is contained in an IOCTTreeSceneNode, when that node gets created it creates additional mesh buffers from the mesh, making it impossible to differentiate which particular mesh buffer contains my conveyor texture (?!?). This would also explain why storing a pointer to the mesh buffer at creation and modifying it every frame doesn't work (that mesh buffer is not being rendered). I'm going to have to re-think this strategy, maybe make a special node for this purpose.
Last edited by pfo on Thu Dec 22, 2005 1:31 am, edited 1 time in total.
michael520
Posts: 230
Joined: Mon Oct 10, 2005 2:24 am

Post by michael520 »

Ah, I encounter the same problem with texture-animation for a conveyor belt !
I am new on this, I think we should change the uv of vertexes in every frame so that the texture on the mesh would look animating... right?
Guest

Post by Guest »

pfo wrote:Guest: (a) is correct, (b) I have no idea how to get that matrix, if I could find it somewhere and expose it that would save the day for me.
That's a bit tricky then. You could probably just bypass the engine and do d3d or ogl calls yourself in some way, but that might introduce more trouble than it's worth, plus would break support for more than one api. The other option would include recompiling the engine after adding a few functions to get the texture matrix (or least set it). The last option would be resorting to shaders.

ATI advices to not change the texture matrix unless you really have to. I don't know how much impact it would have, but seeing their general "gently caress flexibility if it buys us 2fps more in benchmarks vs. nVidia"-approach and how using non-4byte-aligned vertex data turns 1200fps into 0.0001fps.. who knows.
For a shader you would simply specify an offset as shader constant and add a line to add that to the uv coords.

Though none of that solves the problem if you can't be sure which part to render with the shader/changed matrix. How complex is that belt? Without dropping the octtree I could only suggest making the actual belt using the texture its own mesh. As it technically uses a different material it should be anyway (and will surely end up as a seperate submesh one way or another).

Maybe the engine could be extended to support simple texture "animation" as a material property, specifying some kind of "transformation per second" or at least video like "frames". But these days I would still say "why add that kind of specialized functionality when there are shaders".
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Well Magic also has a Direct X library that you can work with. If you want confirmation that a conveyer belt could be implemented with an animated texture just pm Emil Halim, he is very kind and will most definately answer.
Guest

Post by Guest »

krama757 wrote:Well Magic also has a Direct X library that you can work with. If you want confirmation that a conveyer belt could be implemented with an animated texture just pm Emil Halim, he is very kind and will most definately answer.
What exactly is your definition of an "animated texture" anyway? An animated gif? A video file? And what good would that be, when Irrlicht surely doesn't support either to be loaded as texture?
krama757
Posts: 451
Joined: Sun Nov 06, 2005 12:07 am

Post by krama757 »

Emils library allows you to do what irrlicht doesnt. If you see some of his examples he combines 2D and 3D....I believe you can load an animated gif or even an avi file as a skin for a mesh.

But I am a complete newbie to his library, please pm him.
pfo
Posts: 370
Joined: Mon Aug 29, 2005 10:54 pm
Location: http://web.utk.edu/~pfox1

Post by pfo »

I'm not really interested in a solution that uses an animated gif or movie to simulate the texture moving because I am using a physics engine and I want it to look realistic. Using an animated GIF or movie, and trying to calibrate it to work with any given conveyor belt at any given angle and have it correlate to the speed that the texture moves and the force the conveyor exerts sounds like a nightmare that would yield passable results at best. It seems the easiest way would be to calculate distances in 3d along the conveyor direction and use that to shift UV coordinates, probably via a custom scene node. I'm making my levels in DeleD, I wrote a custom loader so I could use the UserTag info in polygons as MetaData for my game. This way you could easily build levels in DeleD and import them into Irrlicht with lots of parameters setup automatically. I'm trying to make the MetaData as lite as possible, with an animated texture I'd have to reference each image's path each time I wanted to make one of these...
when Irrlicht surely doesn't support either to be loaded as texture?
Actually, Irrlicht does support sequences of textures for a material buffer with the texture animator. You could use it to load each frame of a GIF and control its animation speed. It also supports playing AVIs in texture, I think its in one of the examples, or someone on the forum did it.
Post Reply