ユーザ用ツール

サイト用ツール


この翻訳は元のページよりも更新日が古く、内容が古い可能性があります。 変更点を参照して下さい。
Language:

サイドバー

en:vci:script:reference:exportstudio

以前のリビジョンの文書です


vci.studio(ExportStudio)&(ExportSystemItem)


A function required to get pieces of information in the studio.
It is generally used for acquiring state of items and performing operation on items from VCI script.
For information on items in VirtualCast, refer to VirtualCast TOP.


List of methods

For the latest list of the methods, refer to “types.lua” file in “EmbeddedScriptWorkspace” folder.

ExportStudio

Has functions and Get functions exist for each of the preset items in VirtualCast.
Has function is a function to check if the item exists in the studio and Get function is a function to acquire the instance of an item.
Using Get on items that don't exist in the studio will give you null, so only use Get when the result of the Has function is true.
Note that, as of 29th August 2019, items that can also be spawned by guests cannot be acquired.

Method Description
shared vci.studio.shared(ExportShared)
GetMic fun(): ExportSystemItem Instantiate a microphone
HasMic fun(): bool True when a microphone exists in the studio
GetLightSource fun(): ExportSystemItem Instantiate a lightsource
HasLightSource fun(): bool True when a lightsource exists in the studio
GetMirror fun(): ExportSystemItem Instantiate a mirror
HasMirror fun(): bool True when a mirror exists in the studio
GetHarisen fun(): ExportSystemItem Instantiate a fan
HasHarisen fun(): bool True when a fan exists in the studio
GetMosaic fun(): ExportSystemItem Instantiate a mosaic
HasMosaic fun(): bool True when a mosaic exists in the studio
GetHammer fun(): ExportSystemItem Instantiate a squeaky hammer
HasHammer fun(): bool True when a squeaky hammer exists in the studio
GetWindowCamera fun(): ExportSystemCamera Instantiate a camera monitor
HasWindowCamera fun(): bool True when a camera monitor exists in the studio
GetHandiCamera fun(): ExportSystemCamera Instantiate a handy camera
HasHandiCamera fun(): bool True when a handy camera exists in the studio
GetAutoFollowCamera fun(): ExportSystemCamera Instantiate a tracking Camera
HasAutoFollowCamera fun(): bool True when a tracking camera exists in the studio
GetSwitchingCamera fun(): ExportSystemCamera Instantiate a switching camera
HasSwitchingCamera fun(): bool True when a switching camera exists in the studio

SystemItem

Method Description
_new fun(interactableItemController: usertype, controller: usertype): ExportSystemItem
GetName fun(): string
GetLocalPosition fun(): Vector3 Get the position of an item
(The origin point is the local coordinate at the time of spawn )
GetPosition fun(): Vector3 Get the position of an item
(The origin point is (0,0,0) of the world coordinate)
GetLocalRotation fun(): Quaternion Get the rotation of an item
(The basis is the attitude at the time of spawn)
GetRotation fun(): Quaternion Get the rotation of an item
(Based on the world coordinate)
GetLocalScale fun(): Vector3 Get the scale of an item
GetRight fun(): Vector3 The vector of the right direction (+X) of an item
GetUp fun(): Vector3 The vector of the up direction (+Y) of an item
GetForward fun(): Vector3 The vector of the forward direction (+Z) of an item
GetLocalToWorldMatrix fun(): Matrix4x4 Matrix when converting from the local coordinate to the world coordinate of an item
SetPosition fun(position: Vector3): number Change the position of an item
(World coordinate) ※1
SetRotation fun(rotation: Quaternion): number Change the rotation of an item
(World coordinate) ※1
SetLocalPosition fun(localPosition: Vector3): number Change the position of an item
(Local coordinate) ※1
SetLocalRotation fun(localRotation: Quaternion): number Change the rotation of an item
(Local coordinate) ※1
IsGrabbed fun(): bool True when grabbed
GetHashCode fun(): number Generate a hash value
ToString fun(): string Convert a SystemItem into a string

※1
SetPosition SetRotation SetLocalPosition SetLocalRotation are only valid on the VCIs spawned by the studio owner.


ExportSystemCamera

It's basically the same with the SystemItem, but there exist some functions unique to the camera.

Method Description
_new fun(interactableItemController: usertype, controller: usertype): ExportSystemItem
GetFieldOfView fun(): number Get the field of view (FOV) of the camera
GetName fun(): string
GetLocalPosition fun(): Vector3 Get the position of an item
(The origin point is the local coordinate at the time of spawn )
GetPosition fun(): Vector3 Get the position of an item
(The origin point is (0,0,0) of the world coordinate)
GetLocalRotation fun(): Quaternion Get the rotation of an item
(The basis is the attitude at the time of spawn)
GetRotation fun(): Quaternion Get the rotation of an item
(Based on the world coordinate)
GetLocalScale fun(): Vector3 Get the scale of an item
GetRight fun(): Vector3 The vector of the right direction (+X) of an item
GetUp fun(): Vector3 The vector of the up direction (+Y) of an item
GetForward fun(): Vector3 The vector of the forward direction (+Z) of an item
GetLocalToWorldMatrix fun(): Matrix4x4 Matrix when converting from the local coordinate to the world coordinate of an item
SetPosition fun(position: Vector3): number Change the position of an item
(World coordinate) ※1
SetRotation fun(rotation: Quaternion): number Change the rotation of an item
(World coordinate) ※1
SetLocalPosition fun(localPosition: Vector3): number Change the position of an item
(Local coordinate) ※1
SetLocalRotation fun(localRotation: Quaternion): number Change the rotation of an item
(Local coordinate) ※1
IsGrabbed fun(): bool True when grabbed
GetHashCode fun(): number Generate a hash value
ToString fun(): string Convert a SystemItem into a string

※1
SetPosition SetRotation SetLocalPosition SetLocalRotation are only valid on the VCIs spawned by the studio owner.


Summary

Example

main.lua
function onUse(use)
    -- When PositionReset is used
    if use == "CameraPositionReset" then
        -- Reset the position of the camera
        CameraPositionReset()
    end
end
 
function CameraPositionReset()
    -- End if handy camera doesn't exist
    if vci.studio.HasHandiCamera() == false then
        print("Handy camera doesn't exist. End.")
        return
    end
 
    -- The coordinate to reset
    local position = Vector3.__new(0, 1, 0)
    -- Instance of the camera
    local camera = vci.studio.GetHandiCamera()
    -- Change the position of the camera
    camera.SetPosition(position)
    print("Camera position :"..tostring(camera.GetPosition()))
end

The result

Camera position : (0,1,0)
(The camera moves to (0,1,0) in the world coordinate)

Explanation

In this example, the position of the handy camera is reset to (0,1,0) when a SubItem called CameraPositionReset is reset.

    if vci.studio.HasHandiCamera() == false then
        print("Handy camera doesn't exist. End.")
        return
    end

Executing vci.studio.GetHandiCamera() when the handy camera is non-existent in the studio will cause an error.
So when vci.studio.HasHandiCamera() == false (handy camera doesn't exist), it returns to end the process.

When vci.studio.HasHandiCamera() == true, the return will not be executed and it reaches camera.SetPosition(position), which will reset the camera.
Therefore, you must always use Has function to check the existence of an item before instantiating an item with Get function.

It's a case-by-case, but it is recommended to use when Has function is false, then return idiom.
While there is no big deal with when true, then do this strategy, it tends to result in variables being kept inside the scope of the if statement. It could also result in if statements nested inside the if statement.
When Has function is false, then don't do this is more definitive, so we recommend you to bring this in the front.
This way of writing a program is called the Guard.


en/vci/script/reference/exportstudio.1570693726.txt.gz · 最終更新: 2019/10/10 16:48 by h-eguchi

ページ用ツール