How to make a scrolling texture for conveyor belt
-
- 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
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?
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?
-
- Posts: 11
- Joined: Mon Nov 28, 2005 5:00 am
- Location: N.Y.
texture matrix support would be very nice
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
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
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
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.
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.
-
- Posts: 230
- Joined: Mon Oct 10, 2005 2:24 am
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.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.
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".
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 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.
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
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...
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.when Irrlicht surely doesn't support either to be loaded as texture?