Saturday, 17 September 2011

Updates

Have not been writing here in a long time. Will try to do a more regular update from now on.

Yay! Have been accepted to do a DSO-URECA project on video compression. Hope I'll learn new stuff. Wanted to do one that was basically data mining but the Prof. had too many students.. Popular guy. Must be the Korean craze thing. But this seems fun too and I'll be working on an embedded system.

Have not been touching much on my other labs work and just got to touching CSC204 lab. I managed to get the door open and close toggle thing working now! Had a door that basically opens and when clicked on again opens again.. from open position. But finally got it working right today!

How I did it:

I created 2 timeSensor nodes in 3D studio max. 1 to handle the open and the other to handle the close portion of the object. Next, using the autokey, I made the opening and closing animations. Frame 0 to frame 49 is my opening animation and frame 50 to 100 is my closing animation. I next created a touchSensor node. I pointed the touchSensor to the opening and closing timeSensors. I then export to a VRML file.

Next, in Notepad++, I opened the VRML file and added a script which I got off an internet source. I then reroute the nodes - i.e. touchSensor routed to the script and the script routed to the timeSensors open and close. Basically, I'm intercepting the call from touchSensor to the timeSensors.

Here's my code for the 2 doors and 2 windows:

#Script for bifold door
DEF ToggleBiFoldDoor Script {
  field  SFBool  state FALSE
  eventIn  SFTime toggle
  eventOut SFTime startClose
  eventOut SFTime startOpen
  url "vrmlscript:
 function toggle(curtime) {
  state = !state;
  if (state) {
    startOpen = curtime;
    startClose = -1;
  }
  else
  {
    startOpen = -1;
    startClose = curtime;
  }
 }
 "
}
#Script for casement window
DEF ToggleCasWin Script {
  field  SFBool  state FALSE
  eventIn  SFTime toggle
  eventOut SFTime startClose
  eventOut SFTime startOpen
  url "vrmlscript:
 function toggle(curtime) {
  state = !state;
  if (state) {
    startOpen = curtime;
    startClose = -1;
  }
  else
  {
    startOpen = -1;
    startClose = curtime;
  }
 }
 "
}
#Script for pivot door
DEF TogglePivotDoor Script {
  field  SFBool  state FALSE
  eventIn  SFTime toggle
  eventOut SFTime startClose
  eventOut SFTime startOpen
  url "vrmlscript:
 function toggle(curtime) {
  state = !state;
  if (state) {
    startOpen = curtime;
    startClose = -1;
  }
  else
  {
    startOpen = -1;
    startClose = curtime;
  }
 }
 "
}
#Script for awn window
DEF ToggleAwnWin Script {
  field  SFBool  state FALSE
  eventIn  SFTime toggle
  eventOut SFTime startClose
  eventOut SFTime startOpen
  url "vrmlscript:
 function toggle(curtime) {
  state = !state;
  if (state) {
    startOpen = curtime;
    startClose = -1;
  }
  else
  {
    startOpen = -1;
    startClose = curtime;
  }
 }
 "
}
#Bifold Door open and close
ROUTE BiFold_Door_touch-SENSOR.touchTime TO ToggleBiFoldDoor.toggle
ROUTE ToggleBiFoldDoor.startClose TO Bifold_DoorTime_Close-TIMER.startTime
ROUTE ToggleBiFoldDoor.startOpen  TO Bifold_DoorTime_Open-TIMER.startTime
#Cas window open and close
ROUTE Cas_win_touch-SENSOR.touchTime TO ToggleCasWin.toggle
ROUTE ToggleCasWin.startClose TO Casc_Win_Time_Close-TIMER.startTime
ROUTE ToggleCasWin.startOpen  TO Cas_Win_Time_Open-TIMER.startTime
#pivot Door open and close
ROUTE Pivot_Door_Touch-SENSOR.touchTime TO TogglePivotDoor.toggle
ROUTE TogglePivotDoor.startClose TO Pivot_Door_Time_Close-TIMER.startTime
ROUTE TogglePivotDoor.startOpen  TO Pivot_Door_Time_Open-TIMER.startTime
#Awn window open and close
ROUTE Awn_Win_Touch-SENSOR.touchTime TO ToggleAwnWin.toggle
ROUTE ToggleAwnWin.startClose TO Awn_Win_Time_Close-TIMER.startTime
ROUTE ToggleAwnWin.startOpen  TO Awn_Win_Time_Open-TIMER.startTime

Credits to: Open & Close - Reversing animations and davidjsushil.com

Have to go and touch on CSC301 assignment too. My team mates have a heavy load and I'm trying to keep this additional workload as light as possible for them. I had CSC207 last semester and boy is it tiring.

The new blogger editor seems really sleek and cool. Hope to be using it more often. If it seems like this post is incoherent, that's because I'm typing whatever that's in my mind without any editing and I can't be bothered haha.

No comments:

Post a Comment