Is there a way to find out if Track motion is set to 3D Source Alpha?

Phil_P wrote on 2/4/2024, 10:22 AM

I am trying to add full 3D capability to my script but there are some items that make Vegas Crash if the Track Motion are is not set to 3D Source Alpha,

 

For example:

  MessageBox.Show("Setting Second to Defs");
  newKeyframeLater.PositionX = 0;
  newKeyframeLater.PositionY = 0;
  newKeyframeLater.PositionZ = 0;
  newKeyframeLater.Width = 0;
  newKeyframeLater.Height = 0;
  newKeyframeLater.Depth = 0;
  newKeyframeLater.OrientationX = 0;
  newKeyframeLater.OrientationY = 0;
  newKeyframeLater.OrientationZ = 0;
  newKeyframeLater.RotationX = 0;
  newKeyframeLater.RotationY = 0;
  newKeyframeLater.RotationZ = 0;
  newKeyframeLater.RotationOffsetX = 0;
  newKeyframeLater.RotationOffsetY = 0;
  newKeyframeLater.RotationOffsetZ = 0;
  MessageBox.Show("Set New Defs");


Many of these causes an instant crash if the Track Motion area is not set to 3D Source Alpha (for example "newKeyframeLater.Depth") btw. 0 could be any value.

If the Track Motion area is set to 3D Source Alpha there is no issue.

So before trying to change the values that cause the crash, I need to somehow check if the Track Motion is set to 3D.

I have tried many things, using ifs, using null to see if a value is set etc.... Failed.

Does anyone have any thought on this?

 

Thank you.

 

 

Comments

zzzzzz9125 wrote on 2/4/2024, 11:01 AM

You need to check the CompositeMode property of the VideoTrack, using the following code:

if (<VideoTrackName>.CompositeMode == CompositeMode.SrcAlpha3D)
{
    ....
}

You can also directly set it to SrcAlpha3D without checking, depending on the functionality you want.

Last changed by zzzzzz9125 on 2/4/2024, 11:09 AM, changed a total of 3 times.

Using VEGAS Pro 22 build 248 & VEGAS Pro 21 build 208.

Information about my PC:
Brand Name: HP VICTUS Laptop
System: Windows 11.0 (64-bit) 10.00.22631
CPU: 12th Gen Intel(R) Core(TM) i7-12700H
GPU: NVIDIA GeForce RTX 3050 Laptop GPU
GPU Driver: NVIDIA Studio Driver 560.70

jetdv wrote on 2/4/2024, 12:41 PM

This will let you see the "composite mode" for any track. Then just check for a match to the type you want.

            VideoTrack vidTrack = (VideoTrack)myVegas.Project.Tracks[0];
            MessageBox.Show("Composite Mode = " + vidTrack.CompositeMode);

Here's the possible composite modes:

Phil_P wrote on 2/4/2024, 10:17 PM

Thanks guys, very helpful I will post back with the code in case others need it, later on.

Phil_P wrote on 2/4/2024, 11:16 PM

Hi there, so just to update for future reference and for any beginners like me:

You can see below all the values that are required to completely reset a normal keyframe This includes Orientation Angle and Rotation Angle, which are actually OrientationZ and RotationZ. Below that, (in the if statement) the extra values needed that will reset a SrcAlpha3D keyframe.

  • Note: vwidth & vheight are to reset to the media default width and height
  • Note: If any of the SrcAlpha3D items are included in non SrcAlpha3D, Vegas will immediately crash
  • Note: the non 3D values will work on all Composite Modes and are also needed for SrcAlpha3D
     
int vwidth = vegas.Project.Video.Width;
int vheight = vegas.Project.Video.Height;
newKeyframeLater.PositionX = 0;
newKeyframeLater.PositionY = 0;
newKeyframeLater.Width = vwidth;
newKeyframeLater.Height = vheight;
newKeyframeLater.RotationOffsetX = 0;
newKeyframeLater.RotationOffsetY = 0;
newKeyframeLater.OrientationZ = 0;
newKeyframeLater.RotationZ = 0;
// 3D Only
if (videoTrack.CompositeMode == CompositeMode.SrcAlpha3D)
{
    newKeyframeLater.PositionZ = 0;
    newKeyframeLater.Depth = 0;
    newKeyframeLater.OrientationX = 0;
    newKeyframeLater.OrientationY = 0;
    newKeyframeLater.RotationX = 0;
    newKeyframeLater.RotationY = 0;                
    newKeyframeLater.RotationOffsetZ = 0;
}

Thanks for your help guys. :-)

Phil_P wrote on 2/5/2024, 12:00 AM

The finished scripts are here btw: https://everythingcreative.gumroad.com/l/zwjvi

jetdv wrote on 2/5/2024, 4:32 AM

Phil_P wrote on 2/5/2024, 4:39 AM

Hi @jetdv

Yes, I did watch these, and they were very helpful as always. The issue I was having was really that the SrcAlpha3D items were making Vegas Crash when not set to SrcAlpha3D.

So, it was just me figuring out which ones work for both, and which are for SrcAlpha3D. I kind of like to try and figure out as much as I can before asking for help, if you know what I mean.

Also, I am now using Visual Studio 2022 (which is amazing as you said, so helpful). But some of the items in the descriptions are very different now to the older versions.

:-)