media @ VU
[] readme course preface I 1 2 II 3 4 III 5 6 7 IV 8 9 10 V 11 12 afterthoughts appendix references examples resources _

talk show tell print

music-dossier-PresentationButtons.vr

music-dossier-PresentationButtons.vr (wrl ) [ flux / bitmanagement / cortona / octaga ]


  
  EXTERNPROTO ScrollPane [
          eventIn        SFString loadURL
          eventIn        SFString setText
          eventIn SFInt32 scrollText
          eventOut SFString linkClicked
          eventOut SFString activeLink
          field SFInt32 maxCharsOnALine
          field SFString linkFont
          field SFFloat charAspect
  ]
  "music-dossier-text.wrl#ScrollPane"
  
  EXTERNPROTO        pointer[
          eventIn        SFBool selected
  ]
  "models\buttonBar\back\back_forward_button.wrl#ModelBackForwardNode"
  
  EXTERNPROTO        exit[]
  "models\exit.wrl#exitButton"
  
  PROTO Content[
           eventIn SFNode infoObject
           eventIn SFInt32 pos
           eventOut SFNode clicked
          eventOut MFNode shape 
  ]
  {
                  DEF  trans Transform {
                          scale 2 2 2
                          translation        -10 8 0
                          children [
                                  Shape {
                                          geometry Box {
                                                  size 3 2 1
                                          }
                                          appearance Appearance {
                                                  material Material {
                                                          transparency 1
                                                  }
                                          }
                                  }
                                  Shape {
                                          geometry DEF textField Text        {
                                                  fontStyle FontStyle        {
                                                          justify        "MIDDLE"
                                                  }
                                          }
                                          appearance Appearance {
                                                  material Material {
                                                          diffuseColor 1 1 1
                                                          specularColor .92 .43 .01
                                                          ambientIntensity .117
                                                          shininess .4
                                                  }
                                          }
                                  }
                                  DEF touch TouchSensor{}
                          ]
                  }
  
  DEF        Clicked Script {
          directOutput TRUE
          eventIn        SFInt32        pos IS pos
          eventOut SFVec3f position
          eventIn        SFBool click 
          eventOut SFNode        clicked IS clicked
          eventOut MFNode shape IS shape
          eventIn SFNode infoObject IS infoObject
          eventOut MFString text
          field MFNode trans USE trans
          
          url        "javascript:
  
          function infoObject(value) {
                  text = new MFString(value.shortName);
          }
  
          function pos(value)
          {
                  //print(value);
                  position = new SFVec3f(-20 + value*10,0,0);
                  shape = trans;
                  //print(position);
          }
  
          function click()
          {
                  clicked = infoObject;        
          }
  
   "
  }                
          ROUTE Clicked.text TO textField.string
          ROUTE Clicked.position TO trans.translation
          ROUTE touch.isActive TO        Clicked.click
  
  }
  
  PROTO PresentationButtons [        
          eventIn        MFNode setNodes
          eventIn SFString show
          eventIn        SFBool closeButtons
          eventIn SFString activeLink
          eventIn SFInt32 placeActive
          eventOut MFNode indexNodesOut
          eventOut SFString clickedOnNode
          eventOut SFBool        ready
          eventOut SFNode        contentLeft
          eventOut SFNode        contentMiddle
          eventOut SFNode        contentRight
          eventOut SFNode        onlyContent
          eventOut SFString close
          eventOut SFBool noContent
          eventIn SFBool touchExit 
          eventIn SFBool touchMiddle
          eventIn SFString clickedText
  ]
  {
  
                  Transform {
                          scale 2 2 2
                          translation        -10 8 0
                          rotation 0 0 1 3.14
                          children [
                                  DEF pointerLeft pointer{}
                                  DEF touchLeft TouchSensor{}
                          ]
                  }
                  Transform {
                          scale 2 2 2
                          translation        0 8 0
                          rotation 0 0 1 1.57
                          children [
                                  DEF pointerMiddle pointer{}
                                  DEF touchMiddle TouchSensor{}
                          ]
                  }
                  Transform {
                          scale 2 2 2
                          translation        10 8 0
                          children [
                                  DEF pointerRight pointer{}
                                  DEF touchRight TouchSensor{}
                          ]
                  }
  
                  Transform {
                          scale 10 10 1
                          translation        70 -5 0
                          children [
                                  exit{}
                                  DEF touchExit TouchSensor{}
                          ]
                  }
  
                  Transform {
                          scale 30 15 1
                          translation        -57.5 -5 0
                          children [
                                  DEF scrollPicture ScrollPane {maxCharsOnALine 30 linkFont "fonts/aerial_link_black.bmp" charAspect 0.25 }
                          ]
                  }
  
                  Transform {
                          scale 30 15 1
                          translation        -22.5 -5 0
                          children [
                                  DEF scrollVideo ScrollPane {maxCharsOnALine 30 linkFont "fonts/aerial_link_black.bmp" charAspect 0.25}
                          ]
                  }
  
                  Transform {
                          scale 30 15 1
                          translation        12.5 -5 0
                          children [
                                  DEF scrollAudio ScrollPane {maxCharsOnALine 30 linkFont "fonts/aerial_link_black.bmp" charAspect 0.25}
                          ]
                  }
  
                  Transform {
                          scale 30 15 1
                          translation        47.5 -5 0
                          children [
                                  DEF scrollText ScrollPane {maxCharsOnALine 30 linkFont "fonts/aerial_link_black.bmp" charAspect 0.25}
                          ]
                  }
  
  DEF titlesCategories Transform {         # titles categories
                          children [
  DEF titleCategoriesVideo Transform { 
                                          scale 2 2 2
                                          translation        -24 3.5 0
                                          children [
                          Shape {
                                  geometry DEF VideoTitle Text { # video list title
                                          string "Video Clips"
                                          fontStyle FontStyle {
                                            justify "MIDDLE"
                                            family "arial"
                                            size 1.5
                                          }
                                  }
                                  appearance Appearance {
                                          material Material {
                                                  diffuseColor 1 1 1
                                                  
                                          }
                                  }
                          }
  
                          
                  
                  ]
          }
  
    DEF titleCategoriesPicture Transform { 
                                          scale 2 2 2
                                          translation        -59 3.5 0
                                          children [
                          Shape {
                                  geometry DEF PictureTitle Text { # video list title
                                          string "Pictures"
                                          fontStyle FontStyle {
                                            justify "MIDDLE"
                                            family "arial"
                                            size 1.5
                                          }
                                  }
                                  appearance Appearance {
                                          material Material {
                                                  diffuseColor 1 1 1
                                                  
                                          }
                                  }
                          }
  
                          
                  
                  ]
          }
  
    DEF titleCategoriesText Transform { 
                                          scale 2 2 2
                                          translation        46 3.5 0
                                          children [
                          Shape {
                                  geometry DEF TextTitle Text { # video list title
                                          string "Texts"
                                          fontStyle FontStyle {
                                            justify "MIDDLE"
                                            family "arial"
                                            size 1.5
                                          }
                                  }
                                  appearance Appearance {
                                          material Material {
                                                  diffuseColor 1 1 1
                                                  
                                          }
                                  }
                          }
  
                          
                  
                  ]
          }
  
    DEF titleCategoriesAudio Transform { 
                                          scale 2 2 2
                                          translation        11 3.5 0
                                          children [
                          Shape {
                                  geometry DEF TextAudio Text { # audio list title
                                          string "Audio files"
                                          fontStyle FontStyle {
                                            justify "MIDDLE"
                                            family "arial"
                                            size 1.5
                                          }
                                  }
                                  appearance Appearance {
                                          material Material {
                                                  diffuseColor 1 1 1
                                                  
                                          }
                                  }
                          }
  
                          
                  
                  ]
          }
  ]
  }
  
  DEF        Clicked Script {
          directOutput TRUE
          eventIn        SFBool touchRight
          eventIn        SFBool touchLeft
          eventIn        SFBool touchMiddle IS touchMiddle # 
          eventIn        SFBool touchExit IS        touchExit # 
          eventIn        SFBool closedByPresEnv IS        closeButtons
          eventIn        SFString clickedVideo
          eventIn        SFString clickedAudio
          eventIn        SFString clickedPicture
          eventIn        SFString clickedText IS        clickedText        #
          eventIn        SFString activeLink IS activeLink
          eventIn        SFInt32        placeActive IS placeActive
  
          eventOut SFNode        contentLeft IS contentLeft
          eventOut SFNode        contentMiddle IS contentMiddle
          eventOut SFNode        contentRight IS contentRight
          eventOut SFNode        onlyContent IS onlyContent
          eventOut SFString clickedOnNode IS clickedOnNode
          eventOut SFBool        rightPointerSelected
          eventOut SFBool        leftPointerSelected
          eventOut SFBool        middlePointerSelected
          eventOut SFString close IS close
          eventOut SFBool noContent IS noContent
          eventIn        SFNode clicked
          eventIn        MFNode allNodes IS setNodes
      eventIn SFString show IS show
          eventOut SFBool        ready IS ready
          eventOut SFString videoText
          eventOut SFString audioText
          eventOut SFString textText
          eventOut SFString pictureText
          field SFInt32 current -1
          field MFNode infoObjects  []
          field SFNode materials NULL
          
          
          url        "javascript:
  
          function initialize()
          {
                  ready = true;
                  text ='dit is tekst'; 
          }
  
          function touchLeft()
          {
                  current =0;
                  leftPointerSelected =true;
                  middlePointerSelected =false;
                  rightPointerSelected =false;
          }
  
          function touchMiddle()
          {
                  current =1;
                  leftPointerSelected =false;
                  middlePointerSelected =true;
                  rightPointerSelected =false;
          }
  
          function touchRight()
          {
                  current =2;
                  leftPointerSelected =false;
                  middlePointerSelected =false;
                  rightPointerSelected =true;
          }
  
          function touchExit(value)
          {
                  if(value)
                  {
                          close = show;
                          unselect();
                  }
          }
  
          function closedByPresEnv(value) {
                  if (value) unselect();
          }
  
          function unselect()
          {
                  leftPointerSelected =false;
                  middlePointerSelected =false;
                  rightPointerSelected =false;
                  current=-1;
          }
     
  
          function searchNode(value)
          {
                  for(j=0;j<infoObjects.length;j++)
  		{ 
  			if(infoObjects[j].ID==value) return infoObjects[j];
  		}
  	 } 
  
  
  	function clickedPicture(value)
  	{
  		if(value)
  		{
  		//	print ('clicked' + value + current);
  			var node = searchNode(value);																				
  			if(current==-1) contentLeft = node;
  			if(current==0) contentLeft = node;
  			else if(current==1) contentMiddle = node;
  			else if(current==2) contentRight = node;
  			unselect();
  		}
  	} 
  
  
  	function clickedVideo(value)
  	{
  		if(value)
  		{
  			//print ('clicked' + value + current);
  			var node = searchNode(value);																				
  			if(current==-1) contentMiddle = node;
  			if(current==0) contentLeft = node;
  			else if(current==1) contentMiddle = node;
  			else if(current==2) contentRight = node;
  			unselect();
  		}
  	}
  
  	function clickedAudio(value)
  	{
  		if(value)
  		{
  			//print ('clicked' + value + current);
  			var node = searchNode(value);																				
  			if(current==-1) contentMiddle = node;
  			if(current==0) contentLeft = node;
  			else if(current==1) contentMiddle = node;
  			else if(current==2) contentRight = node;
  			unselect();
  		}
  	}
  
  
  	function clickedText(value)
  	{
  		if(value)
  		{
  		//	print ('clicked' + value + current);
  			var node = null;
  			if(value=='Materials') node = materials;
  			else  node = searchNode(value);																				
  			if(current==-1) contentRight = node;
  			if(current==0) contentLeft = node;
  			else if(current==1) contentMiddle = node;
  			else if(current==2) contentRight = node;
  			unselect();
  		}
  	}
  
  	function placeActive(pane) 
  	{ // Put activeLink on pane
  		if(activeLink!='')
  		{
  			current=pane;
  			clickedText(activeLink);
  			Browser.getScript().activeLink='';
  		}
  	}		
  
  	 // Uh.........
  	function show(value)
  	{
  		if (value != null) 
  		{
  			//print('button content'+ value);
  
  			for (i = 0; i < allNodes.length; i++) {
  				if (allNodes[i].ID == value) {
  					currentNode = allNodes[i];
  					break;
  				}
  			}
  
  			var infoObject =currentNode.infoObject;
  			if(infoObject.getType() == 'Picture' || infoObject.getType() == 'Video' || infoObject.getType() == 'TextItem' || infoObject.getType() == 'Audio' )
  			{
  				infoObjects.add(infoObject);
  				//clickedOnNode = value;
  				onlyContent =  infoObject;
  				noContent = false;
  		
  				return;
  			}
  			else
  			{
  				//print('Huidige node : '+  currentNode + ' en mijn lengte is : ' + currentNode.connectedNodesOut[0]);
  				//var nodes=0;
  				var texttext ='';
  				var textvideo ='';
  				var textaudio ='';
  				var textpicture	='';
  				var textmaterials	='';
  				var video = 'null'; //can't test var for null
  				var text = 'null';
  				var audio = 'null';
  				var picture = 'null';
  				for(j=0;j//print('hier' + currentNode.connectedNodesOut[j].infoObjects[0].ID);
  					var x = currentNode.connectedNodesOut[j].infoObjects;
  					for(k=0;k//print('test' + x[k].getType());
  						if(x[k].getType() == 'Picture' || x[k].getType() == 'Video' || x[k].getType() == 'TextItem' || x[k].getType() == 'Audio')
  						{
  							infoObjects.add(x[k]);
  							if(x[k].getType() == 'Picture')
  							{
  								textpicture += '[[' + x[k].ID + ' -' + x[k].shortName + ']]\n';
  								picture = x[k];
  							}
  							else if(x[k].getType() == 'Video')
  							{
  								textvideo += '[[' + x[k].ID + ' -' + x[k].shortName + ']]\n';
  								video = x[k];
  							}
  
  							else if(x[k].getType() == 'Audio')
  							{
  								textaudio += '[[' + x[k].ID + ' -' + x[k].shortName + ']]\n';
  								audio = x[k];
  							}
  
  							else if(x[k].getType() == 'TextItem')
  							{
  								texttext += '[[' + x[k].ID + ' -' + x[k].shortName + ']]\n';
  								text = x[k];
  							}
  						}
  						if(x[k].getType() == 'MaterialItem')
  						{
  							 textmaterials += '[[' + x[k].ID + ' -' + x[k].longName + ']]\n';
  						}
  					}
  				}
  				if(textmaterials != '') 
  				{
  					materials =Browser.createVrmlFromString('PROTO Text[field SFString text \"\" field SFString ID \"MaterialList_' + infoObject.ID + ' \"]{} Text{}')[0];
  					//print(materials.ID);
  					materials.text = textmaterials;
  					infoObjects.add(materials);
  					texttext += '[[Materials -Used Materials]]\n';
  				}
  				if(infoObjects.length==0) 
  				{
  					noContent = true;
  					onlyContent = null;
  					return;
  				}
  				noContent = false;
  
  				if(infoObjects.length==1)
  				{
  					onlyContent = infoObjects[0];
  					return;
  				}
  				if (infoObjects.length > 1) onlyContent = null;
                                  if(infoObjects.length<=3)
                                  {
                                          if(infoObjects.length>0) contentMiddle = infoObjects[0];
                                          if(infoObjects.length >1) contentLeft = infoObjects[1];
                                          if(infoObjects.length >2) contentRight = infoObjects[2];
                                  }
                                  else
                                  {
                                          if(picture!='null') contentLeft = picture;
                                          else contentLeft = infoObjects[0];
                                          if(video!='null') contentMiddle = video;
                                          else contentMiddle = infoObjects[1];
                                          if(text!='null') contentRight = text;
                                          else contentRight = infoObjects[2];
                                  }
                                  videoText =textvideo;
                                  textText = texttext;
                                  pictureText =textpicture;
                                  audioText =  textaudio;
                          //        clickedOnNode = value;
                          }
                  }
                  else
                  {
                          contentLeft=null;
                          contentMiddle=null;
                          contentRight=null;
                          videoText ='';
                          textText = '';
                          pictureText ='';
                          audioText ='';
  
                          infoObjects = new MFNode();
                  }
  
          }
  
          
          function allNodes(value) { 
                  //print('crenode');
  //                var x = 0;
  //                for (i = 0; i < value.length; i ++) {
  //                         x++;  //indexobjects
  //                        for(j=0;j<value.infoObjects.length;j++)
  //                        { 
  //                                print(infoObjects[j]);
  //                                content = Browser.createVrmlFromString('Content{}')[0];
  //                                content.infoObject = infoObjects[j];
  //                                content.pos = x;
  //                                buttons.addChildren(content);
  //                        }
                  }
                          
  //        }
            "
  
  }
  
  ROUTE Clicked.pictureText TO scrollPicture.setText
  ROUTE Clicked.videoText TO scrollVideo.setText
  ROUTE Clicked.audioText TO scrollAudio.setText
  ROUTE Clicked.textText TO scrollText.setText
  ROUTE scrollPicture.linkClicked        TO Clicked.clickedPicture
  ROUTE scrollText.linkClicked TO        Clicked.clickedText
  ROUTE scrollVideo.linkClicked TO Clicked.clickedVideo
  ROUTE scrollAudio.linkClicked TO Clicked.clickedAudio
  
  ROUTE scrollPicture.activeLink TO Clicked.activeLink
  ROUTE scrollText.activeLink TO        Clicked.activeLink
  ROUTE scrollVideo.activeLink TO Clicked.activeLink
  ROUTE scrollAudio.activeLink TO Clicked.activeLink
  
  ROUTE touchLeft.isActive TO        Clicked.touchLeft
  ROUTE touchMiddle.isActive TO Clicked.touchMiddle
  ROUTE touchRight.isActive TO Clicked.touchRight
  ROUTE touchExit.isActive TO        Clicked.touchExit
  
  ROUTE Clicked.leftPointerSelected TO pointerLeft.selected
  ROUTE Clicked.middlePointerSelected TO pointerMiddle.selected
  ROUTE Clicked.rightPointerSelected TO pointerRight.selected
  
  }
  
  


(C) A. Eliëns 21/5/2007

You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.