[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question: url change in ImageTexture node



I will take a stab at this, although my scripting abilities are admittedly
weak. Hopefully if I have made a mistake someone else can post to this list
what it is so Kevin and I can both learn.

Kevin,

You will need a script to do this. Both javascript and vrmlscript will work. 
Your script should increment a counter to keep track of the number clicks
on the TouchSensor, and a ten if statements for to change the url url using
the Browser.createVrmlFromString method.  
Without my testing it to see, it should run something like this:

DEF ChangeTexture Script {
	eventIn	SFBool ISACTIVE
	field 		SFFloat counter	0
	eventOut 	SFString newURL
	"vrmlscript: 
		function ISACTIVE (value) {
			counter += ;
			if (counter == 1)
				Browser.createVrmlFromString(texture1.gif);
				//assumes your textures are in the same dir
			if (counter == 2)
				Browser.createVrmlFromString(texture2.gif);
				//etc. for all the textures.
			if (counter == 10)
				counter = 0;
				//resets the counter to recycle the textures
		)
	"
}
ROUTE YourNamedTouchSensor.isActive TO ChangeTexture.ISACTIVE 
ROUTE ChangeTexture.newURL TO NameOfDEFinedImageTextureNode.set_url 

Make sure you DEFine the ImageTexture node. 
Hope this works for you.
				
Dennis McKenzie




At 08:53 PM 7/6/97 -0400, you wrote:
>Question: url change in ImageTexture node
>I am looking for some help. I am trying to accomplish this result.
>
>An example:
>There is a vrml V2.0 scene with a texture mapped object, a box.
>I want to be able to use a touch sensor on the box, when the box is
>clicked on I want the texture map to change. By repeatedly clicking on
>the box cycle through say 10 or so possible texture maps. With each
>click on the box replacing the current texture on it and rendering the
>next texture map in the list of 10. After reaching the end of the list
>it automatically repeats.
>
>Quote from the VRML 2.0 Source book (second edition)
>Page 308 second paragraph
>	"The URL list can be changed by sending a value to the implied set_url
>eventIn of the url exposed field. When a value is received by this
>input, the field value is changed, and the new value is output using the
>implied url_changed eventOut of the exposed field."
>
>But then there is no example. 
>
>I have been trying to figure out how to write a route from a touch
>sensor to
>the url field of an ImageTexture node. But I can't figure out how this
>works
>because of the different data types.
>I do not know java yet, Do I need a script?
>
>I have been working on this for more than two weeks. If someone would
>let me
>know how this works. It would be much appreciated.
>
>Kevin Knowles
>Please contact me at pyrate@gte.net
>-------------------------------------------------------------------
>*** Please send administrative requests to <majordomo@sdsc.edu> ***
>-------------------------------------------------------------------
>
>

-------------------------------------------------------------------
*** Please send administrative requests to <majordomo@sdsc.edu> ***
-------------------------------------------------------------------


References: