Unity API

F3Ping

Declaration
private static extern double F3Ping();

Parameters

(none)

 

Returns
double
 The version of Unity (example 2021.1).

Description
Convenience function to help make sure you connected to the (unmanaged C++) SDK from C# correctly.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)]    private static extern double   F3Ping();
double year = F3Ping();

F3GetSurfacePointElement

Declaration
public static extern double F3GetSurfacePointElement(int index, double u, double v,);

 Parameters

dimension

Dimension (0 = x, 1 = y, 2 = z) in 3D.

u

Position u in (u,v) parametric representation.

v

Position v in (u,v) parametric representation.

Returns
double The resulting dimension of the vertex at (u,v) in parametric space.

Description
Get one of three dimensions of the vertex position in parametric space.

Usage
[DllImport(“F3_64.dll”, CallingConvention = CallingConvention.Cdecl)]   
private static extern double F3GetSurfacePointElement(int index, double u, double v);
double u = 0.5;
double v = 0.5;
double px = F3GetSurfacePointElement(F3Dims.eX, u, v);
double py = F3GetSurfacePointElement(F3Dims.eY, u, v);
double pz = F3GetSurfacePointElement(F3Dims.eZ, u, v);

F3GetSurfacePoint

Declaration
private static extern void F3GetSurfacePoint(out Vector3 vPtF, double u, double v);

Parameters

vPtF

Vector3 out parameter 

u

Position u in (u,v) parametric representation.

v

Position v in (u,v) parametric representation.

Returns
void

Description
Get (float x,y,z) triplet for 3D point at (u,v) in parametric space.

Usage
[DllImport(“F3_64.dll”, CallingConvention = CallingConvention.Cdecl)]   
private static extern void F3GetSurfacePoint(out Vector3 vPtF, double u, double v);

double u = 0.5;
double v = 0.5
Vector3 position = new Vector3(0, 0, 0);
Figment3DSDK.F3GetSurfacePoint(out position, u, v);

F3GetSurfaceMatrixElement

Declaration
public static extern double F3GetSurfaceMatrixElement(int indexI, int indexJ, double u, double v,); 

Parameters

indexI

Index across in 4×4 matrix.

indexJ

Index down in 4×4 matrix.

u

Position u in (u,v) parametric representation.

v

Position v in (u,v) parametric representation.

Returns
double The resulting matrix (indexCol, indexRow) for location defined by (u,v) in parametric space.

Description
Get specified 4×4 matrix element. Note: this is in right handed coordinates.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)]    private static extern double   F3GetSurfaceMatrixElement(int indexI, int indexJ, double u, double v);
var mat44 = new Matrix4x4();
double u = 0.5;
double v = 0.5;
for (int i = 0; i < 4; i++)
{
    for (int j = 0; j < 4; j++)
    {
        mat44[i,j]=(float)F3GetSurfaceMatrixElement(i, j, u, v);
    }
}
// Convert to left handed
var mat44L = new Matrix4x4();
mat44L[0, 0] = 0;  mat44L[0, 1] = 2;  mat44L[0, 2] = 1;  mat44L[0, 3] = 3;
mat44L[1, 0] = 8;  mat44L[1, 1] = 10; mat44L[1, 2] = 9;  mat44L[1, 3] = 7;
mat44L[2, 0] = 4;  mat44L[2, 1] = 6;  mat44L[2, 2] = 5;  mat44L[2, 3] = 11;
mat44L[3, 0] = 12; mat44L[3, 1] = 14; mat44L[3, 2] = 13; mat44L[3, 3] = 15;

F3GetSurfaceMatrixRow

Declaration
public static extern void F3GetSurfaceMatrixRow(out Vector4 pRow, int nRow, double u, double v); 

Parameters

out Vector4 pRow

Vector4 out parameter to store row.

nRow

Zero based int specifying which of 4 rows to fetch.

u

Position u in (u,v) parametric representation.

v

Position v in (u,v) parametric representation.

Returns
void

Description
Get specified row of 4 floats. Note: this is in right handed coordinates.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)] public static extern void F3GetSurfaceMatrixRow(out Vector4 pRow, int nRow, double u, double v);

Vector4 vRow = new Vector4(0,0,0,0);

F3GetSurfaceMatrixRow(out vRow, 2, u, v);  // Get Row 2 of 4, zero based.

F3GetSurfaceMatrixCol

Declaration
public static extern void F3GetSurfaceMatrixCol(out Vector4 pCol, int nCol, double u, double v); 

Parameters

out Vector4 pCol

Vector4 out parameter to store column.

nCol

Zero based int specifying which of 4 columns to fetch.

u

Position u in (u,v) parametric representation.

v

Position v in (u,v) parametric representation.

Returns
void

Description
Get specified column of 4 floats. Note: this is in right handed coordinates.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)] public static extern void F3GetSurfaceMatrixRow(out Vector4 pRow, int nRow, double u, double v);

Vector4 vCol = new Vector4(0,0,0,0);

F3GetSurfaceMatrixRow(out vCol, 1, u, v);  // Get Column 1 of 4, zero based.

F3GetSurfaceMatrixCols

Declaration
public static extern void F3GetSurfaceMatrixCols(out Vector4 pC0, out Vector4 pC1, out Vector4 pC2, out Vector4 pC3, double u, double v); 

Parameters
out Vector4 pC0

Vector4 out parameter to store column 0.

out Vector4 pC1

Vector4 out parameter to store column 1.

out Vector4 pC2

Vector4 out parameter to store column 2.

out Vector4 pC3

Vector4 out parameter to store column 3.

u

Position u in (u,v) parametric representation.

v

Position v in (u,v) parametric representation.

Returns
void

Description
Get specified 4×4 matrix in four pieces, each represented by a Vector4. Note: this is in right handed coordinates and is converted in the GetQuaternionFromMatrix convenience function.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)] public static extern void F3GetSurfaceMatrixCols(out Vector4 pC0, out Vector4 pC1, out Vector4 pC2, out Vector4 pC3, double u, double v);

Vector4[] carray = new Vector4[4];

F3GetSurfaceMatrixCols(out carray[0], out carray[1], out carray[2], out carray[3], u, v);

Matrix4x4 m44 = new Matrix4x4(carray[0], carray[1], carray[2], carray[3]);

F3GetCurveScale

Declaration
private static extern double F3GetCurveScale(F3Curve curve);

 Parameters

F3Curve

curve (spine, slice or lathe)

Returns
double Returns the scale of the specified curve.

Description
Get the scale of the specified curve.  For example, a hula hoop would have a smaller slice scale (.05) than spine scale (1.0). 

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)] private static extern double F3GetCurveScale(F3Curve curve);

F3IsCurveClosed

Declaration
private static extern bool F3IsCurveClosed(F3Curve curve);

 Parameters

F3Curve

curve (spine, slice or lathe)

Returns
bool Whether curve specified by parameter is closed.

Description
Get the closed state of the specified curve.  For example:  A tube has one open curve and one closed curve so an object traveling on the surface would potentially want to know when to bounce versus wrap. A torus has two closed curves while a plane has two open curves. This function returns whether the specified curve is closed.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)]    private static extern bool     F3IsCurveClosed(F3Curve curve);
bool     bClosedSpine = F3IsCurveClosed(F3Curve.eCurveSpine);

F3SelectNodeByName

Declaration
private static extern bool F3SelectNodeByName(string name);

 Parameters

name

string indicating node to select in Figment3D scene graph

Returns
bool Whether node was found in Figment3D scene graph. Adding a node can change the currently selected node.

Description
Select the node in the Figment3D scene graph with the given name.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.Cdecl)]    private static extern bool     F3SelectNodeByName(string str);
string szFigName = “Tube”;
bool b = F3SelectNodeByName(szFigName);

F3GenerateOBJ

Declaration
private static extern void F3GenerateOBJ(F3Arguments argstruct,  string name);

Parameters

F3Arguments

Structure of Figment3D data

string

Name of .FIG file to load (optional)

Returns
void 

Description
Returns whether the specified curve is closed.

Usage
[DllImport(“F3_64”, CallingConvention = CallingConvention.StdCall)]  private static extern void     F3GenerateOBJ(Arguments argstruct, string str);
F3Prim nPrim = F3Prim.PRIM_TUBE;
F3Arguments mystruct = new F3Arguments { nResX = nSpineRes, nResY = nSliceRes, nAutoPrim = nPrim, bSkipNameDecor = true };
mystruct.fNodeSize = hSliderSize * hSizeScalar;
mystruct.fScaleSpine = hSliderScaleSpine;
float fRat = 1.0F;
if (bVolumeControl)
{
    fRat = hOrigSliderScaleSpine / hSliderScaleSpine;
}
mystruct.fScaleSlice = hSliderScaleSlice * fRat;
mystruct.fScaleLathe = hSliderScaleLathe;
mystruct.fSetCoil = (double)fCoil;
mystruct.fSetTwist = (double)fTwist;
F3GenerateOBJ(mystruct, szFigName);