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

Re: Question: url change in ImageTexture node




Hi Kevin,
  Yes..you'll need a Script node to accomplish this. (There is a
  tedious path without using Script, where box with different textures
  mapped are put under a switch node and its whichChoice is changed
  using a ScalarInterpolator which varies from 0 to 9....No..it's too
  tedious a task)

  Script makes life  simpler as follows:
_________________________________________________________________________

  #VRML V2.0 utf8

  Group {
   children [
    Shape { appearance Appearance {
     texture DEF imgTex ImageTexture {
      url "img0.jpg" #first image to be displayed 
      }
     }
     geometry Box { size 1 1 1 }
    },
    DEF clicker TouchSensor{}
   ]
  }
  
  DEF urlScript Script {
   eventIn SFBool clicked
   eventOut MFString newUrl
   field MFString urlArray null
   field SFInt32 index 0
   url "vrmlscript:
    function initialize() {
     //load the array with images to be displayed
     urlArray = new MFString('img0.jpg', 'img1.jpg', ..., 'img9.jpg');
    }
    function clicked(value) {
     if (value) {
      //only when isActive is true
      newUrl = new MFString(urlArray[index++%10]);//circulate thro' imgs
     }
    }"
   }
   ROUTE clicker.isActive TO urlSCript.clicked
   ROUTE urlScript.newUrl TO imgTex.set_url
__________________________________________________________________________  

regards,
s.r.i.k.u
^v^v^v^v^v^v^v^v^v^
        Mb.sRiKuMaR
Tata Elxsi (I) Ltd.
  Bangalore, India.
 091.080.8452016/17
sriku@teil.soft.net
v^v^v^v^v^v^v^v^v^v

--------------------------------------------
On Sun, 6 Jul 1997, Kevin Todd Knowles 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> ***
-------------------------------------------------------------------


Follow-Ups: References: