Passing structure to COM-function - problems

mcmcdonald

New Member
Hello!
I have a problem accessing COM-functions of a 3D library (Truevision3D).

Some functions need data structurs in the form of D3DVECTOR, defined as
typedef struct D3DVECTOR {
float x, y, z;
} D3DVECTOR, *LPD3DVECTOR;

when i try to call the function from visual basic, all runs well:
Dim pos As DxVBLibA.D3DVECTOR
pos.x = -1
pos.y = -1
pos.z = -1
TV3D_LightEngine.CreateQuickDirectionalLight(pos, 1, 1, 1, "light", 0)

but trying the same in progress results in an error
"Unexpected error during execution of method CreateQuickDirectionalLight (5889)"

i define the vector as a memptr:

DEF VAR vec3 AS MEMPTR.
SET-SIZE(vec3) = 12.
PUT-FLOAT(vec3,1) = -1.0.
PUT-FLOAT(vec3,5) = -1.0.
PUT-FLOAT(vec3,9) = -1.0.

then i call the function as mentioned in the com-object-viewer:

tv3d_light = tv3d_light_engine:CreateQuickDirectionalLight(INPUT-OUTPUT vec3 BY-POINTER,1.0,1.0,1.0,"light",0.0).

the definition from the com-object-viewer is

[ Integer-Var = ] <com-handle>: CreateQuickDirectionalLight (
INPUT-OUTPUT <user-defined>-Direction BY-POINTER,
Decimal-red AS FLOAT,
Decimal-green AS FLOAT,
Decimal-blue AS FLOAT,
Character-lightname,
Decimal-specularscale AS FLOAT ).

It seems that the vector information does not go properly into to CreateQuickDirectionalLight function.

Are there any ideas what i am making wrong ?

Thanks
Andreas
 
Sometimes the COM viewer doesn't necessarily give you the correct type of parameters. Try changing your INPUT-OUTPUT to just INPUT.

This may not resolve the issue but it's worth a try.
 
Hi!

Thanks for reply!

Also passing the vec3 as input returned the same error.

I think it's a generell problem passing mem structures to the COM-methods.

When i try to call a function that returns such a Vector the application gets frozen:

DEF VAR vec3 AS MEMPTR.
SET-SIZE(vec3) = 12.

vec3 = pickresult:GetImpactPoint()

where GetImpactPoint is defined as
[ <user-defined>-Var = ] <com-handle>: GetImpactPoint ( ).
in com object viewer

and defined as
D3DVECTOR TVCollisionResult.GetImpactPoint()
in the documentation of the 3D library.

as mentioned D3DVECTOR is defined as
typedef struct D3DVECTOR {
float x, y, z;
} D3DVECTOR, *LPD3DVECTOR;


Thanks
Andreas
 
mcmcdonald said:
Also passing the vec3 as input returned the same error.

I think it's a generell problem passing mem structures to the COM-methods.
I don't think arrays are supported in this way:

KB 16593
Title: "Conversion from Progress to Variant Data Types with ActiveX"
http://tinyurl.com/aenyt

Can a raw be passed instead?

KB P84007
Title: "Trying to pass MEMPTR to LoadFromMemory method of TXTextControl ActiveX Control causes error 5889"
http://tinyurl.com/836df

eg. something like:

DEF VAR rawVec3 as RAW NO-UNDO.
:
rawVec3 = vec3.
:
tv3d_light = tv3d_light_engine:CreateQuickDirectionalLight(INPUT-OUTPUT rawVec3 BY-POINTER,1.0,1.0,1.0,"light",0.0).
 
Hi!


I don't think arrays are supported in this way:
Yes, it seems it's not possible to pass and get back structures with memptr.

Can a raw be passed instead?
When trying to pass a raw i get a type conflict error (progress error code 5890, COM-error 0x80020005).

Perhaps i have to wrap these function calls into a self-made COM object.

Thanks for your reply!

Andreas


13 Dec 2005 03:26 PM
 
Back
Top