Page 1 of 3

possibility to let materials spin

Posted: Mon Apr 06, 2015 2:36 pm
by THOM
I know you can move textures. In egsample the magma texture is slowly wandering by using

Code: Select all

self:setTexcoordScaleOffset(0.5, 1, time*0.05, 0)
Question: Can you also let a texture spin around it's middleaxis?
And if you can do this by using setTexcoordScaleOffset - which effect do the four argument-numbers cause?

Re: possibility to let materials spin

Posted: Mon Apr 06, 2015 7:31 pm
by minmay
First and second arguments are the X and Y scale for the texture. Third and fourth arguments are the X and Y offset for the texture. So you can't rotate it; use the "crystal" shader for that.

Re: possibility to let materials spin

Posted: Mon Apr 06, 2015 8:39 pm
by THOM
ah - thanks, minmay

but how to use the "crystal" shader? If I just put the commands in my material definition the result is weird. Even after altering. And I can't find any description for that :?: :?:

What I use is

Code: Select all

	shader = "crystal",
	shadeTex = "mod_assets/textures/cauldron_soup.tga",
	shadeTexAngle = 0,
	crystalIntensity = 1,
	onUpdate = function(self, time)
		self:setParam("shadeTexAngle", time*0.01)
	end,

Re: possibility to let materials spin

Posted: Mon Apr 06, 2015 9:56 pm
by minmay
It's the shader used for healing crystals among other things, look at the healing_crystal material. I don't think you can use it to just rotate a plain texture even if you're okay with losing lighting.

From the name of the material it sounds like you want to make the texture swirl around the center of a circle or similar shape. Why don't you just rotate the circle itself?

Re: possibility to let materials spin

Posted: Tue Apr 07, 2015 5:36 am
by Isaac
minmay wrote:Why don't you just rotate the circle itself?
That's what I had to do for the magic circle [portal] in my ORRR2 room. But now it's easier. The tools exist, one can animate it in Blender more effectively.

Re: possibility to let materials spin

Posted: Tue Apr 07, 2015 10:12 am
by THOM
aha....

Again it seems, some day I have to have a look at Blender...

Re: possibility to let materials spin

Posted: Tue Apr 07, 2015 4:46 pm
by Isaac
THOM wrote:aha....

Again it seems, some day I have to have a look at Blender...
Blender would be best IMO, but it is certainly possible to script a repeated rotation using the built in transformation functions.
SpoilerShow
Image

**Just an example.

Code: Select all

-- Animation script, called by a timer to update position.

x = 0
y = 0


function ersatzAnimator()

	 x=x+0.02%4
	 y=y+0.25%.1

	spinner:setPosition(anim_1.x,anim_1.y,x,(math.sin(y)*0.02+0.1),anim_1.level)

end
All you would really need is to adjust the object's facing as a decimal.

Re: possibility to let materials spin

Posted: Tue Apr 07, 2015 5:55 pm
by THOM
Hey Isaac - that looks interesting.

But I don't understand, how to use this script. Do I have to copy it into the material-definition? Do I have to replace "anim_1" with something?? I can't see something refering to a texture.dss or a model.

And must it not be named "local x = 0 local y = 0" ??

You see: I'm confuded... :?

Re: possibility to let materials spin

Posted: Tue Apr 07, 2015 6:15 pm
by Isaac
THOM wrote:Hey Isaac - that looks interesting.

But I don't understand, how to use this script. Do I have to copy it into the material-definition? Do I have to replace "anim_1" with something?? I can't see something refering to a texture.dss or a model.

And must it not be named "local x = 0 local y = 0" ??

You see: I'm confuded... :?
I consider myself a novice at scripting. I started Lua when I started Grimock, so I only have a couple years at it ~part time, as a hobby.

My understanding of [currently] is that defining it local would create a temporary copy of the already defined x & y. The point of defining them outside of [and further up from] the function, is to keep them after the function exits. This way, the next time the function runs, the values for x & y are initially what they were when the function last exit. This incrementally rotates one step from its previous position.

If you are trying to rotate a texture on a [square?] tile, using this concept instead of Blender, you might try using an official floor tile, scaled up in GMT, with your texture applied, and transform it with a similar script that only updates the object's facing with setPosition().

Re: possibility to let materials spin

Posted: Tue Apr 07, 2015 6:37 pm
by minmay
You should use world rotation (setWorldRotationAngles) instead of facing.