Animating textures

Thanks for the component script pointer, [b:8dc5c4es]Geo[/b:8dc5c4es]! andnbsp;I was thinking about that the other day (trying to get smooth, andquot;zoomingandquot; camera motions and not succeeding in moving things by hand). andnbsp;I hadn’t stumbled across the component scripting yet, so I didn’t know entering formulas for motion was possible. andnbsp;Thanks!!!!

It opens up a [i:8dc5c4es]whole lot[/i:8dc5c4es] of possibilites where just plugging in a formula would work instead of positioning key frames by hand. andnbsp;I got used to figuring formulas for animating by hand-coding POVRay animations, so I can see LOTS of uses for this. andnbsp;3DC just keeps getting better and better for me, and Richard doesn’t even have to do anything–there’s lots there that I haven’t discovered yet.

If you can’t tell, I’m a little excited about this. andnbsp;;D

Is it possible to make a texture change to another texture on a certain frame of animation? andnbsp;I have a water ripple texture that is animated in six frames, and I want to make my model, which is just a flattened cube, switch textures every frame, for six frames, to simulate a lake. andnbsp;Is something like that doable in 3DC?

PS: I use version 5.7a, if that helps any.

Could you add your texture to 6 cubes and swap tham around ?

being brief, because I don’t do animation, but isn’t this what the component scripting thingy is for? andnbsp;it’s easy to change a texture with a script, and you could even move it by setting uv coords and ripple the little things head off. andnbsp;I stop now cause I don’t know if I’m talking bad stuff
George

Alan: For now, I guess I’ll have to do that.

Geo_Jenner: Zzzzzzzoooooooooommmmmmmmm!!!!! andnbsp;That’s the sound of what you just said flying right over my head at Mach 3. andnbsp;I have no idea what the andquot;component scripting thingyandquot; is.

And where did you come up with the line, andquot;ripple the little things head offandquot; anyway?

Sorry, no it isn’t.

Richard

aw Calvin you’re stealing my funder <!– s:-) –><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":-)" title="Smile" /><!– s:-) –>

I did it another way. andnbsp;I take one texture and increment the U an V andnbsp;of the texture coordinates. andnbsp;Took me a little while cause I tried to make them between -1 and 1, but during debug I discovered I didn’t need to. andnbsp;How do you post code in that nice little box? andnbsp;I get all these wraparounds.

George

–start code—
Language = VBScript

Sub AnimateObject (Time, 3DCObject)
andnbsp; andnbsp;Dim PointCount
andnbsp; andnbsp;Dim PointIndex
andnbsp; andnbsp;Dim U
andnbsp; andnbsp;Dim V

andnbsp; andnbsp;’get the number of points in the object
andnbsp; andnbsp;PointCount = 3DCObject.GetPointCount

andnbsp; andnbsp;’set the amount to adjust U and V
andnbsp; andnbsp;DeltaU=0.05
andnbsp; andnbsp;DeltaV=0.1
andnbsp; andnbsp;’Run through the points adding to UV
andnbsp; andnbsp;For PointIndex = 0 to PointCount – 1

andnbsp; andnbsp; andnbsp; andnbsp;’get the point
andnbsp; andnbsp; andnbsp; andnbsp; 3DCObject.GetPointTextureCoordinate PointIndex, U, V
andnbsp; andnbsp; andnbsp; andnbsp; U=U+DeltaU *Time
andnbsp; andnbsp; andnbsp; andnbsp; V=U+DeltaV * Time

andnbsp; andnbsp; andnbsp; andnbsp;’set the coordinates
andnbsp; andnbsp; andnbsp; andnbsp;3DCObject.SetPointTextureCoordinate PointIndex, U, V
andnbsp; andnbsp;Next
End Sub

—end code—

this is my last post promise.

It doesn’t go up because there is a bug. andnbsp;Now it works

U=U+DeltaU *Time
V=U+DeltaV * Time


^

this line should obviously be V=V+DeltaV* Time

Sorry bout that

KB —

You’re right… you need to have the andquot;Language = VBScriptandquot; line at the top of your component script. I corrected my code above to include that.

Geo —

Sorry for stealing your thunder… andnbsp;Thought I’d save you the effort <!– s:) –><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!– s:) –> To insert code, you need to use [ code ] insert code here [ code ]. But remove the spaces first. Or you can click on the andquot;#andquot; icon in the andquot;Add YABBC tagsandquot; icon list above the message window.

Cal.

[BLOCKQUOTE class=’ip-ubbcode-quote’][font size=’-1′]quote:[/font][HR]Geo_Jenner: Zzzzzzzoooooooooommmmmmmmm!!!!! That’s the sound of what you just said flying right over my head at Mach 3. I have no idea what the andquot;component scripting thingyandquot; is.
[HR][/BLOCKQUOTE]

If you right-click an object in your scene, and select andquot;Open-]Component Scriptandquot;, you are able to write a script that is called every time a frame is generated in your animation. In a andquot;AnimateObjectandquot; subroutine, you can change it’s position, texture mapping and many other things. For example, I use the component scripts to put gravity and collision detection into my animations. You can also make texture changes inside the script

[pre class=’ip-ubbcode-code-pre’]
Language = VBScript

Sub AnimateObject (Time, 3DCObject)
set mat = 3DCObject.GetMaterial(0)
‘ calculate new material name here
‘ for now, hard code the string, but this
‘ can easily be rotated (eg. for water) by setting
‘ the texture name index to some function of andquot;Timeandquot; modulo 6
tname = andquot;water_03.jpgandquot;
mat.SetTextureFileName(tname)
3DCObject.SetObjectMaterial(mat)
End Sub
[/pre]

I tested this and made a working rippling texture.

Hope that helps,
Cal.

I suppose I should put some instructions with that script since I didn’t comment it much.

You apply any texture to any object. andnbsp;What the script will do is move the texure right and up by amounts you specify in the code. andnbsp;

You specify the amount of change by setting DeltaU and DeltaV in the component script.

It sort of seemed to ripple with a seamless treebark texure I used on a cube and a sphere. andnbsp;The sphere just seems to go around and around instead of up and down as well, so there may very well be something wrong with the script.

And it was sort of fun. andnbsp;Maybe I’ll get into animation.

George

Cal andamp; Geo-

Isn’t –start code—
Language = VBScript
the scripting language? Thought this would be fun to monkey around with, but get this error.
andnbsp;Maybe I should stay in NinjaApprentice’s Zoom club?

andnbsp; andnbsp;KB <!– s:( –><img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad" /><!– s:( –>

Sorry KB, posting code is fraught with danger. andnbsp;Let me know if you can’t run it and I’ll mail you a 3dc file that works.
George

Geo
Yes, please. A working thingy to study would be great. I’ve got it to accept the code but wasn’t quite sure what to do with it!
Danger is my middle name. <!– s:P –><img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz" /><!– s:P –>

KB andnbsp;[img]mailto:Twobears@joimail.com[/img]
<!– e –><a href="mailto:Twobears@joimail.com">Twobears@joimail.com</a><!– e –>

Thanks Geo !
KB

You must be logged in to reply in this thread.

16 posts