diff options
Diffstat (limited to 'Runtime/Video/ScriptBindings')
-rw-r--r-- | Runtime/Video/ScriptBindings/MovieTextureBindings.txt | 92 | ||||
-rw-r--r-- | Runtime/Video/ScriptBindings/UnityEngineWebCamTexture.txt | 200 |
2 files changed, 292 insertions, 0 deletions
diff --git a/Runtime/Video/ScriptBindings/MovieTextureBindings.txt b/Runtime/Video/ScriptBindings/MovieTextureBindings.txt new file mode 100644 index 0000000..b3b07d3 --- /dev/null +++ b/Runtime/Video/ScriptBindings/MovieTextureBindings.txt @@ -0,0 +1,92 @@ +C++RAW + + +#include "UnityPrefix.h" +#include "Configuration/UnityConfigure.h" +#include "Runtime/Mono/MonoManager.h" +#include "Runtime/Graphics/Transform.h" +#include "Runtime/Utilities/PathNameUtility.h" +#include "Runtime/Profiler/ProfilerHistory.h" +#include "Runtime/Misc/PlayerSettings.h" +#include "Runtime/Allocator/MemoryManager.h" +#include "Runtime/Audio/AudioClip.h" +#if ENABLE_AUDIO +#include "Runtime/Audio/AudioSource.h" +#include "Runtime/Audio/AudioListener.h" +#include "Runtime/Audio/AudioManager.h" +#include "Runtime/Audio/AudioReverbZone.h" +#include "Runtime/Audio/AudioReverbFilter.h" +#include "Runtime/Audio/AudioHighPassFilter.h" +#include "Runtime/Audio/AudioLowPassFilter.h" +#include "Runtime/Audio/AudioChorusFilter.h" +#include "Runtime/Audio/AudioDistortionFilter.h" +#include "Runtime/Audio/AudioEchoFilter.h" +#endif +#include "Runtime/Animation/Animation.h" +#include "Runtime/Video/MovieTexture.h" + +using namespace Unity; + +/* + Mono defines a bool as either 1 or 2 bytes. + On windows a bool on the C++ side needs to be 2 bytes. + We use the typemap to map bool's to short's. + When using the C++ keyword and you want to export a bool value + to mono you have to use a short on the C++ side. +*/ + + +void PauseEditor (); +using namespace std; + +CSRAW +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Collections; +using System.Collections.Generic; +using UnityEngineInternal; + +namespace UnityEngine +{ + + +// Movie Textures (Pro only) are textures onto which movies are played back. +CONDITIONAL ENABLE_MOVIES +CLASS MovieTexture : Texture + + // Starts playing the movie. + AUTO void Play (); + + // Stops playing the movie, and rewinds it to the beginning + AUTO void Stop (); + + // Pauses playing the movie. + AUTO void Pause (); + + // Returns the [[AudioClip]] belonging to the MovieTexture. + + CONDITIONAL ENABLE_AUDIO + AUTO_PTR_PROP AudioClip audioClip GetMovieAudioClip + + // Set this to true to make the movie loop. + + AUTO_PROP bool loop GetLoop SetLoop + + // Returns whether the movie is playing or not + + AUTO_PROP bool isPlaying IsPlaying + + // If the movie is downloading from a web site, this returns if enough data has been downloaded so playback should be able to start without interruptions. + + AUTO_PROP bool isReadyToPlay ReadyToPlay + + // The time, in seconds, that the movie takes to play back completely. + AUTO_PROP float duration GetMovieDuration + +END + + + +CSRAW } + diff --git a/Runtime/Video/ScriptBindings/UnityEngineWebCamTexture.txt b/Runtime/Video/ScriptBindings/UnityEngineWebCamTexture.txt new file mode 100644 index 0000000..278d7dd --- /dev/null +++ b/Runtime/Video/ScriptBindings/UnityEngineWebCamTexture.txt @@ -0,0 +1,200 @@ +C++RAW + +#include "UnityPrefix.h" +#include "Configuration/UnityConfigure.h" +#include "Runtime/Scripting/ScriptingManager.h" +#include "Runtime/Scripting/ScriptingExportUtility.h" +#include "Runtime/Mono/MonoBehaviour.h" +#include "Runtime/Video/VideoTexture.h" + +CSRAW + +namespace UnityEngine +{ + +CONDITIONAL ENABLE_WEBCAM +// *undocumented* +ENUM WebCamFlags + // Camera faces the same direction as screen + FrontFacing = 1, +END + + +CONDITIONAL ENABLE_WEBCAM +// A structure describing the webcam device. +STRUCT WebCamDevice + // A human-readable name of the device. Varies across different systems. + CSRAW public string name { get { return m_Name; } } + + // True if camera faces the same direction a screen does, false otherwise. + CSRAW public bool isFrontFacing { get { return (m_Flags & ((int)WebCamFlags.FrontFacing)) == 1; } } + + CSRAW internal string m_Name; + CSRAW internal int m_Flags; +END + + +CONDITIONAL ENABLE_WEBCAM +// WebCam Textures are textures onto which the live video input is rendered +CLASS WebCamTexture : Texture + + CUSTOM private static void Internal_CreateWebCamTexture ([Writable]WebCamTexture self, string device, int requestedWidth, int requestedHeight, int maxFramerate) + { + WebCamTexture* texture = NEW_OBJECT_MAIN_THREAD (WebCamTexture); + texture->Reset(); + Scripting::ConnectScriptingWrapperToObject (self.GetScriptingObject(), texture); + texture->AwakeFromLoad(kInstantiateOrCreateFromCodeAwakeFromLoad); + texture->SetRequestedWidth (requestedWidth); + texture->SetRequestedHeight (requestedHeight); + texture->SetRequestedFPS (maxFramerate); + texture->SetDevice (device); + } + + // Create a WebCamTexture + + CSRAW public WebCamTexture (string deviceName, int requestedWidth, int requestedHeight, int requestedFPS) + { + Internal_CreateWebCamTexture (this, deviceName, requestedWidth, requestedHeight, requestedFPS); + } + + ///*listonly* + CSRAW public WebCamTexture (string deviceName, int requestedWidth, int requestedHeight) + { + Internal_CreateWebCamTexture (this, deviceName, requestedWidth, requestedHeight, 0); + } + + ///*listonly* + CSRAW public WebCamTexture (string deviceName) + { + Internal_CreateWebCamTexture (this, deviceName, 0, 0, 0); + } + + ///*listonly* + CSRAW public WebCamTexture (int requestedWidth, int requestedHeight, int requestedFPS) + { + Internal_CreateWebCamTexture (this, "", requestedWidth, requestedHeight, requestedFPS); + } + + ///*listonly* + CSRAW public WebCamTexture (int requestedWidth, int requestedHeight) + { + Internal_CreateWebCamTexture (this, "", requestedWidth, requestedHeight, 0); + } + + ///*listonly* + CSRAW public WebCamTexture () + { + Internal_CreateWebCamTexture (this, "", 0, 0, 0); + } + + // Starts the camera + AUTO void Play(); + + // Pauses the camera. + AUTO void Pause(); + + // Stops the camera + AUTO void Stop(); + + // Returns if the camera is currently playing + AUTO_PROP bool isPlaying IsPlaying + + // Set this to specify the name of the device to use. + CUSTOM_PROP string deviceName { return scripting_string_new(self->GetDevice ()); } { self->SetDevice (value); } + + // Set the requested frame rate of the camera device (in frames per second). + AUTO_PROP float requestedFPS GetRequestedFPS SetRequestedFPS + + // Set the requested width of the camera device. + AUTO_PROP int requestedWidth GetRequestedWidth SetRequestedWidth + + // Set the requested height of the camera device. + AUTO_PROP int requestedHeight GetRequestedHeight SetRequestedHeight + + CONDITIONAL UNITY_IPHONE_API + CUSTOM_PROP bool isReadable { return self->IsReadable(); } + + CONDITIONAL UNITY_IPHONE_API + CUSTOM void MarkNonReadable() { self->SetReadable(false); } + + // Return a list of available devices. + CUSTOM_PROP static WebCamDevice[] devices + { + MonoWebCamDevices devs; + WebCamTexture::GetDeviceNames(devs, true); + + ScriptingClassPtr klass = GetScriptingManager().GetCommonClasses().webCamDevice; + ScriptingArrayPtr array = CreateScriptingArray<MonoWebCamDevice>(klass, devs.size()); + + for (MonoWebCamDevices::size_type i = 0; i < devs.size(); ++i) + { + #if UNITY_WINRT + ScriptingObjectPtr dev = CreateScriptingObjectFromNativeStruct(klass, devs[i]); + Scripting::SetScriptingArrayElement<ScriptingObjectPtr>(array, i, dev); + #else + Scripting::SetScriptingArrayElement<MonoWebCamDevice>(array, i, devs[i]); + #endif + } + + return array; + } + + // Returns pixel color at coordinates (x, y). + CUSTOM Color GetPixel (int x, int y) { + return self->GetPixel (x, y); + } + + // Get a block of pixel colors. + CSRAW public Color[] GetPixels() + { + return GetPixels( 0, 0, width, height ); + } + + // Get a block of pixel colors. + CUSTOM Color[] GetPixels(int x, int y, int blockWidth, int blockHeight) + { + int res = blockWidth * blockHeight; + if (blockWidth != 0 && blockHeight != res / blockWidth) { + return SCRIPTING_NULL; + } + ScriptingArrayPtr colors = CreateScriptingArray<ColorRGBAf>(GetScriptingManager().GetCommonClasses().color, res ); + self->GetPixels( x, y, blockWidth, blockHeight, &Scripting::GetScriptingArrayElement<ColorRGBAf>(colors, 0)); + return colors; + } + + // Returns the pixels data in raw format + + CUSTOM public Color32[] GetPixels32(Color32[] colors = null) + { + int w = self->GetDataWidth(); + int h = self->GetDataHeight(); + if (colors != SCRIPTING_NULL) + { + int size = GetScriptingArraySize(colors); + if (size != w * h) + { + ErrorStringMsg ("Input color array length needs to match width * height, but %d != %d * %d", size, w, h); + return SCRIPTING_NULL; + } + } + else + colors = CreateScriptingArray<ColorRGBA32>(GetScriptingManager().GetCommonClasses().color32, w * h); + self->GetPixels(kTexFormatRGBA32, &Scripting::GetScriptingArrayElement<ColorRGBA32>(colors, 0), GetScriptingArraySize(colors) * 4); + return colors; + } + + // Returns an clockwise angle, which can be used to rotate a polygon so camera contents are shown in correct orientation. + CUSTOM_PROP int videoRotationAngle { return self->GetVideoRotationAngle(); } + + CUSTOM_PROP bool videoVerticallyMirrored + { + return self->IsVideoVerticallyMirrored(); + } + + // Did the video buffer update this frame? + AUTO_PROP bool didUpdateThisFrame DidUpdateThisFrame + +END + +CSRAW +} |