behavior api (TCL version)Ver 0.2
Sony Corporation.
History
- Jan 19 1996: Add "vsGetEventObj".
- Dec 21 1995: Add "vsWarning", "vsError" and "vsMessage" are renamed to "vsMessageDlg".
- Dec 21 1995: Add "vsGet3DMovieInfo","vsSet3DMovieFrame".
- Dec 21 1995: Add "vsSet3DMoviePrevFrame".
- Dec 21 1995: "vsPlay3DVideo" had been renamed to "vsSet3DMovieNextFrame".
- Dec 18 1995: Add "vstkInit".
- Dec 15 1995: Add "vsPlay3DMovie", "vsPause3DMovie" and "vsSet3DMovieSpeed".
- Dec 15 1995: "vsSwitchObj" had been renamed to "vsSetSwitchObjByNo".
- Dec 15 1995: Add "vsGetSwitchObjByNo" and "vsGetSwitchObjInfo".
- Dec 15 1995: Add "vs{Get/Set}{Camera/Light}Attribute.
- Dec 14 1995: Add "vsGetEvent{2DPoint/Time}.
- Dec 1 1995: "vsGetTopObjByName" -> "vsGetObjByName".
- Nov 30 1995: Add "vs{Get/Set}ObjAttribute.
- Nov 30 1995: Add "vs{Bew/Del}Variable.
- Nov 30 1995: Del "vs{Obj,Part,ObjAll}{Ambient,Diffuse....}".
- Nov 29 1995: Add "vsKinGetFrame".
- Nov 27 1995: Add "vsSwitchObj".
- Nov 27 1995: Add "vsValue" had been renamed to "vsGetVariable" and "vsSetVariable".
- Nov 25 1995: Add "vsRand", "vsGetLocalTime" and "vsGetCtime".
- Nov 13 1995: Add "vs3DPosTo2DPos" and some command had been renamed.
- vs*Parts* -> vs*Part*.
- vsWwwOpenVRML -> vsWwwOpenFile.
Nov 2 1995: The Draft version for alpha release.
The following describes the API accessible to scripts to access,
define and manipulate VS Objects present in a VS 3D world and defined in Sony's
extension of the VRML laungage E-VRML. These commands can be called from scripts
running in the browser and in application objects.
Index
.
- Object Access Functions
- Material Control Functions
- Translation and Rotation Control Functions
- Kinemation Functions
- Structure Access Functions
- Camera Access Functions
- Light Access Functions
- Task Control Functions
- Video Control Functions
- Sound Control Functions
- WWW Browser Control Functions
- Browser Control Functions
- Misc Functions
vsGetObjByName
vsAddObjFromFile
vsAddObjFromStr
vsNewVariable
vsDelVariable
VsGetVariable
VsSetVariable
VsGetObjAttribute
VsSetObjAttribute
vsSetSwitchObjByNo
vsGetSwitchObjInfo
vsGetSwitchObjByNo
*Index.
Material Control Functions
vsGetObjPart
vsSetPartMaterial
vsSetObjMaterial
vsSetObjAllMaterial
vsGetPartMaterial
vsGetObjMaterial
vsGetObjAllMaterial
*Index.
Translation and Rotation Control Functions
vsRotate
vsRotateAngle
vsTranslate
vsRotateTranslate
vsRotateTranslateAngle
vsGetObjWRT
vsGetObjLRT
*Index.
Kinemation Functions
vsKinNew
vsKinDelete
vsKinSetFrame
vsKinNextPosture
vsKinPrevPosture
vsKinGetFrame
*Index.
Structure Access Functions
vsGetEventType
vsGetEventModifier
vsGetEventKey
vsGetEventPart
vsGetEventObj
vsGetEventPoint
vsGetEvent2DPoint
vsGetEventTime
*Index.
Camera Access Functions
vsGetActiveCamera
vsSetCameraAttribute
vsGetCameraAttribute
*Index.
Light Access Functions
vsSetLightAttribute
vsGetLightAttribute
*Index.
Task Control Functions
vsAddEventHandler
vsRemoveEventHandler
vsAddTimeOutHandler
vsRemoveTimeOutHandler
*Index.
Video Control Functions
vsPlay3DMovie
vsPause3DMovie
vsGet3DMovieSpeed
vsSet3DMovieSpeed
vsGet3DMovieInfo
vsSet3DMovieFrame
vsSet3DMovieNextFrame
vsSet3DMoviePrevFrame
vsPlay2DVideo
*Index.
Sound Control Functions
vsPlayAmbientSoundByName
vsPlayAmbientSound
vsStopSoundByName
vsStopSound
vsPlaySpotSoundByName
vsPlaySpotSound
vsSetSoundVolumeByName
vsSetSoundVolume
vsSuspendSuspendByName
vsSuspendSound
vsSuspendAllSound
vsResumeSoundByName
vsResumeSound
vsResumeAllSound
*Index.
WWW Browser Control Functions
vsWwwOpenUrl
vsWwwGetFile
vsWwwOpenFile
*Index.
Browser Control Functions
vsBackwardPage
vsForwardPage
vsMenuExec
*Index.
Misc Functions
vsMessage
vsWarning
vsError
vs2DPosTo3DPos
vsRand
vsGetLocalTime
vsGetCTime
vstkInit
*Index.
Object Access Functions
- Function:
- Searchs an object named by [name] from the specified [obj] to its descendant.
- If [obj] is not specified, searchs an object from the topobjlist of the current world.
-
- Name:
- vsGetObjByName name
- vsGetObjByName obj name
- Args:
-
- obj:(in)
- Object.
-
- name:(in)
- Object name.
Return:
No such object : 0
Otherwise : Object
- Example:
[wrl]
DEF robot Separator { # robot
DEF hand Separator { # hand
Cone {}
DEF finger Separator { # finger
Cube {}
}
}
}
DEF robot Separator { # dog
DEF robot Separator { # robot
DEF hand Separator { # hand
Cone {}
DEF finger Separator { # finger
Cube {}
}
}
}
}
[Object tree]
----------+-------------+--------- topobj
| |
robot dog <- [dog]
| |
hand robot
| |
[robot_finger]->finger hand
|
finger <- [dog_robot_finger]
[tcl]
set dog [vsGetObjByName "dog"] ;
if {$dog != 0} {
set dog_robot_finger [vsGetObjByName dog "robot.hand.finger"]
}
set robot_finger [vsGetObjByName "robot.hand.finger"]
if {$robot_finger} {
global vsAmbient
vsSetObjAllMaterial $robot_finger $vsAmbient 1.0 0.0 0.0
}
Back to Index.
- Function:
- Create new object from E-VRML file.
- Name:
- vsAddObjFromFile obj E-VRMLfilename
- Args:
-
- obj:(in)
- 0 if new object is a top object.
- Otherwise, new object's parent Separator object.
- E-VRMLfilename:(in)
- E-VRML file name. This file must be a local file.
- Return:
- Failure : 0
- Success : Object .
- Example:
[tcl]
global $vsSuccess
if {0 == vsAddObjFromFile $obj vsWwwGetFile["models/bird.wrl"]} {
vsWarning "vsAddObjFromFile failed."
}
Back to Index.
- Function:
- Create new object from E-VRML string.
- Name:
- vsAddObjFromStr obj E-VRMLstring
Args:
-
- obj:(in)
- 0 if new object is a top object.
- Otherwise, new object's parent Separator object.
- E-VRMLstring:(in)
- E-VRML string.
- Return:
- Failure : 0
- Success : Object.
Example:
-
[tcl]
if {0 == [vsAddObjFromStr $obj " \
#VRLM V1.0 ascii\n\
Cone \{ \n\
parts ALL\n\
bottomRadius 2\n\
height 7\n\
\}"] } {
vsWarning "vsAddObjFromStr failed."
}
Back to Index.
- Function:
- Manipulate object variable.
- Name:
- vsNewVariable obj valuename value [ro]
- vsDelVariable obj valuename
- Args:
-
- obj:(in)
- Object.
- valuename:(in)
- Name of object variable.
- value:(in)
- If specified, the object variable is set to "value".
- ro:(in)
- If specified, the object variable is set to read only.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Note:
- Example:
-
see vsSetVariable.
Back to Index.
- Function:
- Manipulate object variable.
- Name:
- vsGetVariable obj valuename
- vsSetVariable obj valuename value
- Args:
-
- obj:(in)
- Object.
- valuename:(in)
- Name of object variable.
- value:(in)
- If specified, the object variable is set to "value".
- Return:
- New or current value of object variable.
- Note:
If valuemane dose exist get, novalue initialises the valuename to the
empty string and returns it.
vsSetVariable :
If valuename is read only, warning message dialog has appeared on the screen.
- Example:
-
[tcl]
vsNewVariable $obj count 100 ; # set [count] to 100.
vsSetVariable $obj count 200 ; # set [count] to 100.
vsNewVariable $obj rocount 100 ro ; # set [count] to 100, ro.
vsSetVariable $obj rocount 200 ; # display the warning dialog in this line.
set localcount [vsGetVariable $obj count] ; # get value of [count].
incr localcount
vsSetVariable $obj count $localcount ; # set [count] to $localcount.
Back to Index.
- Function:
- Get/Set Object's attribute.
- Name:
- vsGetObjAttribute obj attrbute value
- vsSetObjAttribute obj attrbute value
- Args:
-
- obj:(in)
- Object.
- attribute:(in)one of:
- vsObjAttrNode
- vsObjAttrName
- vsObjAttrComment
- vsObjAttrVisible
- vsObjAttrGrasp
- vsObjAttrSolid
- vsObjAttrCollision
- value:(in for set, out for get):
+----------------------------------------------+
| attribute | value type | access |
+---------------------+---------------+--------+
|vsObjAttrNode |string | RO |
|vsObjAttrName |string | RW |
|vsObjAttrComment |string | RW |
|vsObjAttrVisible |vsTrue/vsFalse | RW |
|vsObjAttrGrasp |vsTrue/vsFalse | RO |
|vsObjAttrSolid |vsTrue/vsFalse | RO |
|vsObjAttrCollision |vsTrue/vsFalse | RO |
+---------------------+---------------+--------+
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsObjAttrNode vsObjAttrVisible vsTrue
set ret [ vsGetObjAttribute $coneobj $vsObjAttrNode node]
if {$ret == $vsSuccess} {
vsWarning "$node" ; # <- "Cone"
}
set ret [vsGetObjAttribute $coneobj $vsObjAttrVisible $vsTrue]
if {$ret != $vsSuccess} {
vsWarning "vsGetObjAttribute failed."
}
Back to Index.
- Function:
- Traverses one,none, or all of Switch Node object's children.
- Name:
- vsSetSwitchObjByNo obj whichchild
- Args:
-
- obj:(in)
- Switch node object.
- whichchild:(in)
- object No(0-max). (-1 means do not traverse any children. -3 traverses
all children)
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[wrl]
#VRML V1.0 ascii
DEF Root Separator {
DirectionalLight {
intensity 1
color 0.8 0.2 0.9
direction -1 0 1
}
Separator {
PeriodicTask {
filename "switch.tcl"
millisecond 300
userData "data"
function "switchFunc"
scriptType TCL
}
Switch {
whichChild 0
Cone {
parts ALL
bottomRadius 2
height 7
}
Transform { translation 0 1 0 }
Cone {
parts ALL
bottomRadius 2
height 9
}
Transform { translation 0 3 0 }
Cone {
parts ALL
bottomRadius 2
height 15
}
}
}
}
[tcl]
set objNo 0
proc switchFunc {obj eve userdata} {
global objNo vsContinue
if {$switch == 0} {
vsSetSwitchObjByNo $obj 0 ;
set objNo 1
} elseif {$switch == 1} {
vsSetSwitchObjByNo $obj 1 ;
set objNo 2
} elseif {$switch == 2} {
vsSetSwitchObjByNo $obj 2 ;
set objNo 0
}
return $vsContinue
}
Back to Index.
- Function:
- Get switch node object's information.
- Name:
- vsGetSwitchObjInfo obj current
- vsGetSwitchObjInfo obj current max
- vsGetSwitchObjByNo obj whichchild
- Args:
-
- obj:(in)
- Switch node object.
- current:(out)
- Current object No(0-max). (-1 means do not traverse any children. -3 traverses
all children)
- max:(out)
- number of switch object's children.
- whichchild:(in)
- Object No(0-max).
- Return:
- vsGetSwitchObjInfo : Nothing.
- vsGetSwitchObjByNo :
- Success: object.
- Failure: 0
- Example:
-
[tcl]
global vsCSLocal vsRelative
vsGetSwitchObjInfo $swobj current max
incr current
if {$current >= $max} {
set current 0
}
vsSetSwitchObjByNo $swobj $current
set obj [vsGetSwitchObjByNo $swobj $current]
if {0 == $obj} {
vsWarning "vsGetSwitchObjByNo"
} else {
vsTranslate $obj 1.0 0.0 0.0 $vsCSLocal $vsRelative
}
Back to Index.
Material Control Functions
- Function:
- Get part from specified object.Part is [parts] field in VRML, or a face of Indexfaceset.
- Name:
- vsGetObjPart obj VsLeafType
- vsGetObjPart faceobj faceNo
- Args:
-
- obj:(in)
- Cylinder or Cone object or parent of Cylinder or Cone object.
- VsLeafType:(in)
- $vsConeSide
- $vsConeBottom
- $vsCylinderSide
- $vsCylinderBottom
- $vsCylinderTop
- faceobj:(in)
- Object, except Cone or Cylinder object.
- faceNo:(in)
- Numerical value.
- Return:
- No such part : 0
- Otherwise : Part of object.
- Example:
-
[tcl]
global vsConeBottom
set bottom [vsGetObjPart $coneobj $vsConeBottom]
if {$bottom == 0} {
vsWarning "vsGetObjPart failed"
}
and see also vsSetObjMaterial
Back to Index.
- Function:
- Get/Set any Material of object or an object's part.
- Name:
- vsSetPartMaterial part attribute value
- vsSetObjMaterial obj attribute value
- vsSetObjAllMaterial obj attribute value1 ... valueN
- vsGetPartMaterial part attribute value
- vsGetObjMaterial obj attribute value
- vsGetObjAllMaterial obj attribute value1 ... valueN
- Args:
-
- obj:(in)
- Object.
- part:(in)
- Part. this must be return value of
vsGetObjPart or
vsGetEventPart.
- attribute:(in)
- $vsAmbient
- $vsDiffuse
- $vsSpecular
- $vsEmissive
- $vsShininess
- $vsTransparency
-
- value:(in for Set, out for Get)
- r g b (0.0-1.0)
- If attributes is following:
- $vsAmbient
- $vsDiffuse
- $vsSpecular
- $vsEmissive
- f (0.0 - 1.0)
- If attributes is following:
- $vsShininess
- $vsTransparency
-
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsAmbient vsShininess
global vsConeBottom
set f 0.0
set r 0.0
set g 0.0
set b 0.0
vsGetObjMaterial $obj $vsAmbient r g b
vsGetObjMaterial $obj $vsShininess $f
vsSetObjMaterial $obj $vsAmbient [expr $r/2] $g $b
vsSetObjMaterial $obj $vsShininess [expr $f/2]
vsSetPartMaterial [vsGetObjPart $coneobj $vsConeBottom] \
$vsAmbient 1.0 0.0 1.0
vsGetPartMaterial [vsGetObjPart $cubeobj 1] $vsAmbient $r $g $b
Back to Index.
Translation Control Functions
- Function:
- Set rotation coordinates of an object.
- Name:
- vsRotate obj rx1 ry1 rz1 rx2 ry2 rz2 rx3 ry3 rz3
VsCoordSystem VsTransferMode
- vsRotateAngle obj xangle yangle zangle
VsCoordSystem VsTransferMode
- Args:
-
- obj:(in)
- Object.
- rx1 ry1 rz1 rx2 ry2 rz2 rx3 ry3 rz3:(in)
- Rotation matrix. See VRML documents.
- xangle yangle zangle :(in)
- Rotation angle in degrees.
- VsCoordSystem:(in)
- $vsCSLocal
- $vsCSWorld
- $vsCSParent
- $vsCSRelative
- VsTransferMode:(in)
- $vsAbsolute
- $vsRelative
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsCSLocal vsRelative vsSuccess
set ret [vsRotateAngle $obj 10.0 0.0 0.0 $vsCSLocal $vsRelative]
if {$ret != $vsSuccess} {
vsWarning "vsRotateAngle failed"
}
Back to Index.
- Function:
- Set position coordinates of an object.
- Name:
- vsTranslate obj tx ty tz VsCoordSystem VsTransferMode
- Args:
-
- obj:(in)
- Object.
- tx ty tz:(in)
- Translation value. See VRML documents for unit.
- VsCoordSystem,VsTransferMode:(in)
- see vsRotate
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsCSLocal vsRelative vsSuccess
set ret [vsTranslate $obj 10.0 0.0 0.0 $vsCSLocal $vsRelative]
if {$ret != $vsSuccess} {
vsWarning "vsTranslate failed"
}
Back to Index.
- Function:
- Set rotation and position coordinates of an object.
- Name:
vsRotateTranslate obj
rx1 ry1 rz1 rx2 ry2 rz2 rx3 ry3 rz3 tx ty tz
VsCoordSystem VsTransferMode
-
vsRotateAngleTranslate obj xangle yangle zangle
tx ty tz VsCoordSystem VsTransferMode
- Args:
- See vsRotate and vsTranslate.
- Return:
- Success : $vsSuccess
- Failure : unspecified
- Example:
-
[tcl]
global vsCSLocal vsRelative vsSuccess
set ret [vsRotateAngleTranslate $obj 10.0 0.0 0.0 \
20.0 10.0 10.0 $vsCSLocal $vsRelative]
if {$ret != $vsSuccess} {
vsWarning "vsRotateAngleTranslate failed"
}
Back to Index.
Query Object's Translation and Rotation.
- Function:
- Get object's position and rotation in world coordinates.
- Name:
- vsGetObjWRT obj x y z
- vsGetObjWRT obj x y z rx1 ry1 rz1 rx2 ry2 rz2 rx3 ry3 rz3
- Args:
-
- obj:(in)
- Object.
- rx1 ry1 rz1 rx2 ry2 rz2 rx3 ry3 rz3 :(out)
- Rotation coordinates of an objects.
- tx ty tz:(out)
- Translation coordinates of object.
- Return :
- Nothing.
- Example:
-
[tcl]
global vsCSWorld vsAbsolute
set x 0
set y 0
set z 0
vsGetObjWRT $obj x y z
vsTranslate $obj [expr $x+10.0] \
$y $z $vsCSWorld $vsAbsolute
Back to Index.
- Function:
- Get object's position and rotation in local coordinates.
- Name:
- vsGetObjLRT obj x y z
- vsGetObjLRT obj x y z rx1 ry1 rz1 rx2 ry2 rz2 rx3 ry3 rz3
- Args:
- same as vsGetObjWRT.
- Return :
- Nothing.
- Example:
-
[tcl]
global vsCSLocal vsAbsolute
set x 0
set y 0
set z 0
vsGetObjLRT $obj x y z
vsTranslate $obj [expr $x+10.0] \
$y $z $vsCSWorld $vsAbsolute
Back to Index.
Kinemation Functions
- Function:
- Create Kinemation Object.
- Name:
- vsKinNew skinUrl obj_return
- Args:
-
- skinUrl(in):
- Kinemation skin Url string.
- obj_return(out):
- Created kinemation object.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsSuccess
set kinobj 0
set ret [vsKinNew "../kinema/boy.wrl" kinobj]
if {$ret != $vsSuccess} {
vsWarning "vsKinNew failed"
}
Back to Index.
- Function:
- Delete kinemation object.
- Name:
- vsKinDelete obj
- Args:
-
- obj:(in)
- Kinemation object, must be created with vsKinNew.
- Return:
- Nothing.
- Example:
-
[tcl]
vsKinDelete $obj
Back to Index.
-
Function:
- Animate Kinemation object. See document on kinemation data to create the frame.
- Name:
- vsKinSetFrame obj frameNo
- vsKinNextPosture obj
- vsKinPrevPosture obj
- Args:
-
- obj:(in)
- Created with vsKinNew.
- frameNo:(in)
- Kinemation frame number.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[wrl]
SporadicTask {
fields [ SFLong millisecond, SFString userData, SFString function, SFString filename, SFEnum scriptType ]
millisecond 50
userData "data"
function "KinGirlInit"
filename "../scripts/kinema.tcl"
scriptType TCL
}
any object definition.
[tcl]
set kinGirlCounter 0
###############################################################
# animate kinemation object.
###############################################################
proc KinGirlMove { obj ev userdata } {
global kinGirlCounter
global vsCSWorld vsAbsolute vsRelative
set x 0.0
set y 0.0
set z 0.0
if { $kinGirlCounter < 400 } {
incr kinGirlCounter
vsKinNextPosture $obj
} else {
set kinGirlCounter 0
vsGetObjWRT $obj x y z
vsTranslate $obj 0.0 0.0 0.0 $vsCSWorld $vsAbsolute
vsRotateAngle $obj 0.0 180.0 0.0 $vsCSWorld $vsRelative
vsTranslate $obj $x $y $z $vsCSWorld $vsAbsolute
}
}
###############################################################
# create kinemation object, and set KinGirlMove as periodictask.
###############################################################
proc KinGirlInit { obj ev userdata } {
global vsTclScript vsPeriodicTask vsCSWorld vsRelative
set girl 0
vsKinNew ../models/girl.wrl girl
vsTranslate $girl -21.0 0.0 -35.5 $vsCSWorld $vsRelative
vsAddTimeOutHandler $girl 300 $vsTclScript "" KinGirlMove 0 $vsPeriodicTask
}
Back to Index.
-
Function:
- Get current kinemation frame number and maximum kinemation frame number.
See document on kinemation data to create the frame.
- Name:
- vsKinGetFrame obj frameNo
- vsKinGetFrame obj frameNo maxframeNo
- Args:
-
- obj:(in)
- Created with vsKinNew.
- frameNo:(out)
- Current kinemation frame number.
- maxframeNo:(out)
- Maximum kinemation frame number.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsSuccess
if{$vsSuccess != [vsKinGetFrame $kinobj cur max]} {
vsWarning "vsKinGetFrane Failure."
} else {
if {$cur > [expr $max/2]} {
vsKinSetFrame $kinobj 0
} else {
vsKinNextPosture $kinobj
}
}
Back to Index.
Structure Access Functions
event
- Function:
- Return the event type of an event structure.
- Name:
- vsGetEventType event
- Args:
-
- event:(in)
- Reference of event structure, See E-VRML document for
definition of event structure.
- Return:
A mask denoting any combination of:
+----------------------+------------------+
| eventType on wrl | on tcl |
+----------------------+------------------+
|WORLD_IN | $vsWorldIn |
|WORLD_OUT | $vsWorldOut |
|COLLISION | $vsCollision |
|CREATE_WORLD | $vsCreateWorld |
|DELETE_WORLD | $vsDeleteWorld |
|CREATE_NOTIFY | $vsCreateNotify |
|DELETE_NOTIFY | $vsDeleteNotify |
|TIME_OUT | $vsTimeOut |
|GRAB | $vsGrab |
|RELEASE | $vsRelease |
|DRAG | $vsDrag |
|PICK | $vsPick |
|FRAME | $vsFrame |
+----------------------+------------------+
- Example:
-
[tcl]
proc eventproc {obj event user_data} {
global vsPick
set type [vsGetEventType $event]
if {1 == [expr $type & $vsPick]} {
vsWarning "picked."
}
}
Back to Index.
- Function:
- Return the selected part of an event structure. For example, it return the part clicked on
by a vsPick event.
- Name:
- vsGetEventPart event
- Args:
-
- event:(in)
- Reference of event structure.
- Retrun:
- part.
- Example:
-
[tcl]
proc eventHandler {obj event user} {
global vsAmbient
set part [vsGetEventPart $event]
vsSetPartMaterial $part $vsAmbient 0.5 1.0 1.0
}
Back to Index.
- Function:
- Return the selected object of an event structure. For example, it return the object clicked on by a vsPick event.
- Name:
- vsGetEventObj event
- Args:
-
- event:(in)
- Reference of event structure.
- Retrun:
- Object.
- Example:
-
[wrl]
EventHandler {
eventType PICK
function "eventHandler"
filename "eventtest.tcl"
userData "notuse"
}
Separator {
DEF cube1 Cube{}
Transform {
translation 3 0 0
}
DEF cube2 Cube{}
}
[tcl]
proc eventHandler {obj event user} {
global vsAmbient
set object [vsGetEventObj $event]
# object is cube1 or cube2.
vsSetObjAllMaterial $object $vsAmbient 0.5 1.0 1.0
}
Back to Index.
- Function:
- Return the position in world coordinates of an event structure.
- Name:
- vsGetEventPoint event x y z
- Args:
-
- event:(in)
- Reference of event structure
- x y z:(out)
- coordinate of event position.
- Return:
- Nothing.
- Example:
- see vsGetTopObjByName
Back to Index.
- Function:
- Return the position in screen coordinates of an event structure.
- Name:
- vsGetEvent2DPoint event x y
- Args:
-
- event:(in)
- Reference of event structure
- x y:(out)
- coordinate of event position.
- Return:
- Nothing.
- Example:
-
[tcl]
proc eventHandler {obj event user} {
vsGetEvent2DPoint $event x y
}
Back to Index.
- Function:
- Return the time of an event structure.
- Name:
- vsGetEventTime event sec milli_sec
- Args:
-
- event:(in)
- Reference of event structure
- sec milli_sec:(out)
- Time of event occrred.
- Return:
- Nothing.
- Example:
-
[tcl]
proc eventHandler {obj event user} {
vsGetEventTime $event sec milli_sec
}
Back to Index.
Camera Access Functions
- Function:
- Get Active Camera.
- Name:
- vsGetActiveCamera
- Args:
-
- nothing.
- Return:
- Active camera object in current world.
- Example:
-
[tcl]
set orgcamera [vsGetActiveCamera]
Back to Index.
- Function:
- Get/Set Camera's attribute.
- See also vs{Get/Set}ObjAttribute.
- Name:
- vsSetCameraAttribute obj attribute value
- vsGetCameraAttribute obj attribute value
- Args:
- obj:(in)
- Camera Object.
- attribute:(in)one of:
- vsCameraAttrLookAt
- vsCameraAttrFocalDistance
- vsCameraAttrBackground
- vsCameraAttrHeight
- vsCameraAttrHeightAngle
- value:(in for set, out for get):
-
+--------------------------+----------------+---------------+
| attribute | value type | camera type |
+--------------------------+----------------+---------------+
| vsCameraAttrLookAt | x(float) | all |
| | y(float) | |
| | z(float) | |
+--------------------------+----------------+---------------+
| vsCameraAttrFocalDistance| dist(float) | all |
+--------------------------+----------------+---------------+
| vsCameraAttrBackground | r(0.0-1.0) | all |
| | g(0.0-1.0) | |
| | b(0.0-1.0) | |
+--------------------------+----------------+---------------+
| vsCameraAttrHeight | height(float) | orthographic |
+--------------------------+----------------+---------------+
| vsCameraAttrHeightAngle | angle(float) | perspective |
+--------------------------+----------------+---------------+
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsCameraAttrBackground vsSuccess
set camera [vsGetActiveCamera]
if {0 == $camera} {
vsWarning "vsGetActiveCamera failed"
}
set ret [vsSetCameraAttribute $camera \
$vsCameraAttrBackground 1.0 0.0 0.0]
if {$ret != $vsSuccess} {
vsWarning "vsSetCameraAttribute failed."
}
Back to Index.
Light Access Functions
- Function:
- Get/Set Light's attribute.
- See also vs{Get/Set}ObjAttribute.
- Name:
- vsSetLightAttribute obj attribute value
- vsGetLightAttribute obj attribute value
- Args:
- obj:(in)
- Camera Object.
- attribute:(in)one of:
- vsLightAttrOn
- vsLightAttrIntensity
- vsLightAttrColor
- vsLightAttrLocation
- vsLightAttrDirection
- vsLightAttrDropOffRate
- vsLightAttrCutOffAngle
- value:(in for set, out for get):
+--------------------------+----------------+---------------+
| attribute | value type | light type |
+--------------------------+----------------+---------------+
| vsLightAttrOn | vsTrue/vsFalse| all |
+--------------------------+----------------+---------------+
| vsLightAttrIntensity | val(float) | all |
+--------------------------+----------------+---------------+
| vsLightAttrColor | r(0.0-1.0) | all |
| | g(0.0-1.0) | |
| | b(0.0-1.0) | |
+--------------------------+----------------+---------------+
| vsLightAttrLocation | x(float) | spot & point |
| | y(float) | |
| | z(float) | |
+--------------------------+----------------+---------------+
| vsLightAttrDirection | x(float) | spot & |
| | y(float) | directional |
| | z(float) | |
+--------------------------+----------------+---------------+
| vsLightAttrDropOffRate | val(float) | spot |
+--------------------------+----------------+---------------+
| vsLightAttrCutOffAngle | val(float) | spot |
+--------------------------+----------------+---------------+
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsLightAttrOn vsTrue vsSuccess
set ret [vsSetLightAttribute $light \
$vsLightAttrOn $vsTrue]
if {$ret != $vsSuccess} {
vsWarning "vsSetLightAttribute failed."
}
Back to Index.
Task Control Functions
Event
- Function:
- Add event handler. Only Tcl scripts are currently supported.
- Name:
- vsAddEventHandler obj VsBitMask VsScriptType filenameUrl function user_data
- Args:
-
- obj:(in)
- Object.
- VsBitMask:(in)
- See vsGetEventType
- VsScriptType:(in)
- $vsPythonScript
- $vsTclScript
- $vsJavaScript
- $vsVBScript (Visual Vasic)
- $vsCBinary (C Binary)
- fielanmeUrl:(in)
- Script file name URL string.
- function:(in)
- Script function name.
- user_data:(in)
- User data string.
See
Sony's extensions to the VRML 1.0 standard.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsSuccess vsPick vsTclScript
set ret [vsAddEventHandler $obj $vsPick \
$vsTclScript "../script/task.tcl" "bdfunc" "data"]
if {$ret != $vsSuccess} {
vsWarning "vsAddEventHandler failed"
}
- see also vsGetEventType.
Back to Index.
- Function:
- Remove event handler.
- Name:
- vsRemoveEventHandler obj VsBitMask VsScriptType
filenameUrl function user_data
- Args:
- Same as vsAddEventHandler
- Return:
- Success : $vsSuccess
- Failure : Unspecified
Back to Index.
Timeout
- Function:
- Add timeout handler. Only Tcl scripts are currently supported.
- Name:
- vsAddTimeOutHandler obj time_value VsScriptType
filenameUrl function user_data VsTaskType
- Args:
-
- obj:(in)
- Object.
- time_value:(in)
- Timeout value in milliseconds.
- VsScriptType:(in)
- $vsPythonScript
- $vsTclScript
- $vsJavaScript
- $vsVBScript
- $vsCBinary
- filenameUrl:(in)
- Script file name URL string.
- function:(in)
- Script function name.
- user_data:(in)
- User data string.
See
Sony's extensions to the VRML 1.0 standard.
- VsTaskType:(in)
- $vsSporadicTask
- $vsPeriodicTask
- Return:
- Success : Timeouthandler id.
- Failure : 0
- Example:
- See vsRemoveTimeOutHandler.
Back to Index.
- Function:
- Remove timeout handler.
- Name:
- vsRemoveTimeOutHandler obj timeouthanlerId
- Args:
-
- obj:(in)
- Object.
- timeouthandlerId:(in)
- Return value from VsAddTimeOutHandler.
Return:
Nothing.
- Example:
-
[wrl]
EventHandler {
fields [ SFSBitMask eventType, SFString userData, SFString function, SFString filename, SFEnum scriptType ]
eventType PICK
userData "data"
function "vs_H_Event_RBProc"
filename "proc.tcl"
scriptType TCL
}
Cone {
parts ALL
bottomRadius 2
height 7
}
[tcl]
set red 0
proc coneTmFunc {obj event data} {
global red count vsContinue vsDiffuse
if {$red == 0} {
vsSetObjMaterial $obj $vsDiffuse 1.0 0.0 0.0
} else {
vsSetObjMaterial $obj $vsDiffuse 0.0 0.0 1.0
}
return $vsContinue
}
set TmId 0
proc RbProc {obj event userdata} {
global TmId vsPeriodicTask vsTclScript
if {$TmId == 0} { # timeouthandler is not living
set TmId [vsAddTimeOutHandler $obj 120 \
$vsTclScript "" coneTmFunc \
$userdata $vsPeriodicTask]
if {$TmId == 0} {
vsWarning "vsAddTimeOutHandler failed"
}
} else {
vsRemoveTimeOutHandler $obj $TmId
}
}
Back to Index.
Video Control Functions
- Function:
- Display the next frame of a video sequence of an object's surface.
- To play the video this must be called as part of a TimeoutHandler.
- Name:
- vsPlay3DVideo obj
- Args:
-
- obj:(in)
- Object must specify a movie file in E-VRML file, as a Texture field.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[wrl]
Separator {
Texture2 { # set movie file to object .
filename "../video/bballs/bballs.bmp"
}
Coordinate3 {
point [
-2 2 0, 0 2 0, 2 2 0, -2 0 0, 0 0 0, 2 0 0]
}
TextureCoordinate2 {
point [0 0, 0 1, 1 1, 1 0]
}
PeriodicTask {
fields [ SFLong millisecond, SFString userData, SFString function, SFString filename, SFEnum scriptType ]
millisecond 167
userData "data"
function "vs_H_Periodic3DPray"
filename "video.tcl"
scriptType TCL
}
IndexedFaceSet {
coordIndex [ 0, 3, 4, 1, -1]
textureCoordIndex [1, 0, 3, 2, -1]
}
}
[tcl]
proc Periodic3DPray {obj event user} {
vsPlay3DVideo $obj
}
Back to Index.
- Function:
- Play/Pause video on object's surface.
- Name:
- vsPlay3DMovie obj
- vsPause3DMovie obj
- Args:
-
- obj:(in)
- Object must specify a movie file in E-VRML file, as a Texture2 or Movie2 field.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[wrl]
Separator {
Movie2 { # set movie file to object .
filename "../video/bballs/bballs.bmp"
}
Coordinate3 {
point [
-2 2 0, 0 2 0, 2 2 0, -2 0 0, 0 0 0, 2 0 0]
}
TextureCoordinate2 {
point [0 0, 0 1, 1 1, 1 0]
}
EventHandler {
userData "data"
function "vs_H_Create3DPlay"
filename "video.tcl"
scriptType TCL
}
IndexedFaceSet {
coordIndex [ 0, 3, 4, 1, -1]
textureCoordIndex [1, 0, 3, 2, -1]
}
}
[tcl]
proc vs_H_Create3DPlay {obj event user} {
vsPlay3DVideo $obj
}
Back to Index.
- Function:
- Set video speed on object's surface.
- Name:
- vsSet3DMovieSpeed obj speed
- Args:
-
- obj:(in)
- Object must specify a movie file in E-VRML file, as a Texture2 or Movie2 field.
- speed:(in)
- minus value means revers play.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
vsSet3DMovieSpeed $movieobj 2.0 ;# double speed play.
vsSet3DMovieSpeed $movieobj -2.0 ;# double speed, revers play.
Back to Index.
- Function:
- Get video speed on object's surface.
- Name:
- vsGet3DMovieSpeed obj
- Args:
-
- obj:(in)
- Object must specify a movie file in E-VRML file, as a Texture2 or Movie2 field.
- Return:
- Current speed.
- Example:
-
[tcl]
set cur [vsGet3DMovieSpeed $movieobj]
vsSet3DMovieSpeed $movieobj [expr -1 * $cur]
Back to Index.
- Function:
- Get video objec't information.
- Name:
- vsGet3DMovieInfo obj cur
- vsGet3DMovieInfo obj cur max
- Args:
-
- obj:(in)
- Object must specify a movie file in E-VRML file, as a Texture2 or Movie2 field.
- cur:(out)
- Current frame no.
- max:(out)
- Number of frame.
- Return:
- Nothing.
- Example:
-
[tcl]
global vsTrue vsFalse
vsPause3DMovie $movieobj
vsSet3DMovieInfo $movieobj cur max
vsSet3DMovieFrame $movieobj [expr $cur/2]
vsPlay3DMovie $movieobj
See also vsSet3DMovieFrame.
Back to Index.
- Function:
- Set video object's frame.
- Name:
- vsSet3DMovieFrame obj frame
- vsSet3DMovieNextFrame obj (vsPlay3DVideo)
- vsSet3DMoviePrevFrame obj
- Args:
-
- obj:(in)
- Object must specify a movie file in E-VRML file, as a Texture2 or Movie2 field.
- frame:(in)
- frame no(0 - (number of frame-1)).
- Return:
- Nothing.
- Example:
-
[tcl]
proc RandFrame {movieobj} {
vsPause3DMovie $movieobj
vsSet3DMovieInfo $movieobj cur
vsSet3DMovieSetFrame $movieobj [expr $cur/2]
}
Back to Index.
- Function:
- Play a 2D video on the Viewer window.
- Name:
- vsPlay2DVideo filename
- Args:
-
- filename:(in)
- Movie filename. AVI is currently supported format.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
vsPlay2DVideo "foo.avi"
Back to Index.
Sound Control Functions
- Function:
- Set condition of ambient sound object to play.
- Name:
- vsPlayAmbientSoundByName name loop
- vsPlayAmbientSound obj loop
- Args:
-
- obj:(in)
- Object.
- name:(in)
- Node name of ambient sound object.
- loop:(in)
- 1 for repeated sound.
- Retrun:
- Success : $vsSuccess
- Failure : Unspecified
Back to Index.
- Function:
- Stop sound.
- Name:
- vsStopSoundByName name
- vsStopSound obj
- Args:
-
- obj:(in)
- Object.
- name:(in)
- Node name of sound object.
- Retrun:
- Success : $vsSuccess
- Failure : Unspecified
Back to Index.
- Function:
- SpotSound Play
- Name:
- vsPlaySpotSoundByName name loop
- vsPlaySpotSound obj loop
- Args:
- Same as vsPlayAmbientSound*
- Retrun:
- Success : $vsSuccess
- Failure : Unspecified
Back to Index.
- Function:
- Set sound volume.
- Name:
- vsSetSoundVolumeByName name volume
- vsSetSoundVolume name volume
- Args:
-
- name:(in)
- Node name of sound object.
- volume:(in)
- 0-255
- Retrun:
- Success : $vsSuccess
- Failure : Unspecified
Back to Index.
-
Function:
- Sound Suspend and Resume.
- Name:
- vsSuspendSuspendByName name
- vsSuspendSound obj
- vsSuspendAllSound
- vsResumeSoundByName name
- vsResumeSound obj
- vsResumeAllSound
- Args:
-
- obj:(in)
- Object.
- name:(in)
- Node name of sound object.
- Retrun:
- Success : $vsSuccess
- Failure : Unspecified
Back to Index.
WWW Browser Control Function
- Function:
- Open URL on WWW Browser.
- Name:
- vsWwwOpenUrl urlString
- Args:
-
- urlString:(in)
- URL string.
- Return:
- Success : $vsSuccess. This dose not mean necessarily that the URL was successfully open.
- Failure : Unspecified
- Example:
-
[tcl]
global vsSuccess
set ret [vsWwwOpenUrl "http://www.sony.co.jp"]
if {$ret != $vsSuccess} {
vsWarning "vsWwwOpenUrl failed"
}
Back to Index.
- Function:
- Download URL file to local disk.
- Name:
- vsWwwGetFile urlString
- Args:
-
- urlString:(in)
- URL string.
- Return:
- Local file name. If file dose not exist, empty string returns.
- Example:
-
[tcl]
set localfile [vsWwwGetFile "../movie/run.avi"]
if {$localfile != ""} {
vsPlay2DVideo $localfile
}
Back to Index.
- Function:
- Open local file on WWW Browser.
- Name:
- vsWwwOpenFile Filename
- Args:
-
- Filename:(in)
- Filename. This file must be a local file.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
vsWwwOpenVRML "foo.wrl"
Back to Index.
Browser Control Functions
- Function:
- E-VRML browser's menu exec function.
- Name:
- vsBackwardPage
- vsForwardPage
- vsMenuExec VsMenuId
-
-
- Args:
-
- VsMenuId :
- $vsForward
- $vsBackward
- $vsFileExit
- $vsFileOpenUrl
- $vsFileOpenFile
- $vsAddBookmark
- $vsAbout
- $vsReload
- $vsStopLoading
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
global vsFileOpenUrl
vsMenuExec $vsFileOpenUrl ; # popup OPEN-URL dialog of browser.
Back to Index.
Misc Functions
- Function:
- Output the string in a popup dialog box.
there.
- Name:
- vsMessageDlg string
- Args:
-
- string:
- Message string.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
- Example:
-
[tcl]
vsMessageDlg "message from vsMessage"
Back to Index.
- Function:
- Convert 3D position in world coordinates to screen coordinates.
- Name:
- vs3DPosTo3DPos x y z xx yy
Args:
- x y z:(in)
- Position in world coordinates.
- xx yy:(out)
- Position in Screen coordinates.
- Return:
- Success : $vsSuccess
- Failure : Unspecified
Example:
[tcl]
vsGetObjWRT $obj x y z
vs3DPosTo2DPos $x $y $z xx yy
Back to Index.
- Function:
- Returns a pseudorandom integer between 0 to 32767.
- Name:
- vsRand
- Args:
-
- Nothing.
- Return:
- 0 - 32767
Example:
[tcl]
set v [vsRand]
Back to Index.
- Function:
- Get current system date and time.
- Name:
- vsGetLocalTime [sec min hour mday mon year wday yday isdst]
- Args:
-
- sec:(out)
- seconds after the minute - [0,59]
- min:(out)
- minutes after the hour - [0,59]
- hour:(out)
- hours since midnight - [0,23]
- mday:(out)
- day of the month - [1,31]
- mon:(out)
- months since January - [0,11]
- year:(out)
- years since 1900
- wday:(out)
- days since Sunday - [0,6]
- isdst:(out)
- daylight savings time flag
- Return:
- Number of seconds elapsed since midnight(00:00:00),January 1,1970,
universal coordinate time,according to the system clock.
Example:
[tcl]
vsGetLocalTime sec min hour
vsWarning "$hour hour $min min $sec sec."
[result]
12 hour 10 min 10 sec.
Back to Index.
- Function:
- Returns a current system time string.
- Name:
- vsGetCTime
- Args:
-
- Nothing.
- Return:
- Example:
Fri Nov 24 00:00:00 1995.
Example:
[tcl]
set v [vsGetCTime]
Back to Index.
- Function:
- Initialize the Tk interface.
- Do not call this function in Tcl proc.
- Name:
- vstkInit
- Args:
-
- Nothing.
- Return:
- Nothing
Example:
[tcl]
vstkInit
proc event {obj ev data} {
wm deiconify . ; # Map the default toplevel window.
}
Back to Index.