Jump to content
Sign in to follow this  
JRowe

Complicated dll struct

Recommended Posts

JRowe

I'm working on a new project, integrating a 3D engine that just became available. I was wondering if anyone could take a stab at creating the following struct using DllStructCreate.

struct D3DXVECTOR3
{
 float x,y,z;
 D3DXVECTOR3(float x=0.0f,float y=0.0f,float z=0.0f)
 {
    this->x = x;
    this->y = y;
    this->z = z;
 }
 D3DXVECTOR3& operator+= (const D3DXVECTOR3&);
 D3DXVECTOR3& operator-= (const D3DXVECTOR3&);
 D3DXVECTOR3& operator*= (float);
 D3DXVECTOR3& operator/= (float);
 D3DXVECTOR3 operator+ () const;
 D3DXVECTOR3 operator- () const;
 D3DXVECTOR3 operator+ (const D3DXVECTOR3&) const;
 D3DXVECTOR3 operator- (const D3DXVECTOR3&) const;
 D3DXVECTOR3 operator* (float) const;
 D3DXVECTOR3 operator/ (float) const;
 BOOL operator== (const D3DXVECTOR3&) const;
 BOOL operator!= (const D3DXVECTOR3&) const;
};

The code I'm using it in is expecting a D3DXVector3 struct to be passed as one of the parameters. Using the following, I crash the 3D engine.

Func iCameraLocationSet($pCamera, $fX, $fY, $fZ)
        $D3DXVector3 = DllStructCreate("float X;float Y;float Z")
            DllStructSetData($D3DXVector3, "X", $fX)
            DllStructSetData($D3DXVector3, "Y", $fY)
            DllStructSetData($D3DXVector3, "Z", $fZ)
        DllCall($3iDLL, "none:cdecl", "iCameraLocationSet", "ptr", $pCamera, "ptr", $D3DXVector3)
EndFunc

Is there an easy way to set this up?

Other reference: http://msdn.microsoft.com/en-us/library/ee417646%28VS.85%29.aspx

http://www.3impact.com/3Impact_Engine/hulk7123/reference.htm

I've gotten the engine to initialize, etc, just haven't been able to use the structs for positioning. As soon as that gets figured out, I only have around 180 or so functions left to wrap in. Any help is appreciated :D

Edit: It appears I got ahead of myself. the function iCameraLocationSet is expecting a pointer to a valid camera object. I'd assumed that there was such a pointer being created; I was wrong. That being the case, I've gone back to figure out where the heck I went wrong, and I'll be back later. Thanks for any input, however!

Edited by JRowe

Share this post


Link to post
Share on other sites
wolf9228

I'm working on a new project, integrating a 3D engine that just became available. I was wondering if anyone could take a stab at creating the following struct using DllStructCreate.

struct D3DXVECTOR3
{
 float x,y,z;
 D3DXVECTOR3(float x=0.0f,float y=0.0f,float z=0.0f)
 {
    this->x = x;
    this->y = y;
    this->z = z;
 }
 D3DXVECTOR3& operator+= (const D3DXVECTOR3&);
 D3DXVECTOR3& operator-= (const D3DXVECTOR3&);
 D3DXVECTOR3& operator*= (float);
 D3DXVECTOR3& operator/= (float);
 D3DXVECTOR3 operator+ () const;
 D3DXVECTOR3 operator- () const;
 D3DXVECTOR3 operator+ (const D3DXVECTOR3&) const;
 D3DXVECTOR3 operator- (const D3DXVECTOR3&) const;
 D3DXVECTOR3 operator* (float) const;
 D3DXVECTOR3 operator/ (float) const;
 BOOL operator== (const D3DXVECTOR3&) const;
 BOOL operator!= (const D3DXVECTOR3&) const;
};

The code I'm using it in is expecting a D3DXVector3 struct to be passed as one of the parameters. Using the following, I crash the 3D engine.

Func iCameraLocationSet($pCamera, $fX, $fY, $fZ)
        $D3DXVector3 = DllStructCreate("float X;float Y;float Z")
            DllStructSetData($D3DXVector3, "X", $fX)
            DllStructSetData($D3DXVector3, "Y", $fY)
            DllStructSetData($D3DXVector3, "Z", $fZ)
        DllCall($3iDLL, "none:cdecl", "iCameraLocationSet", "ptr", $pCamera, "ptr", $D3DXVector3)
EndFunc

Is there an easy way to set this up?

Other reference: http://msdn.microsoft.com/en-us/library/ee417646%28VS.85%29.aspx

http://www.3impact.com/3Impact_Engine/hulk7123/reference.htm

I've gotten the engine to initialize, etc, just haven't been able to use the structs for positioning. As soon as that gets figured out, I only have around 180 or so functions left to wrap in. Any help is appreciated :D

All of these

#ifdef __cplusplus
typedef struct D3DXVECTOR3 : public D3DVECTOR
{
public:
    D3DXVECTOR3() {};
    D3DXVECTOR3( CONST FLOAT * );
    D3DXVECTOR3( CONST D3DVECTOR& );
    D3DXVECTOR3( CONST D3DXFLOAT16 * );
    D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z );

    // casting
    operator FLOAT* ();
    operator CONST FLOAT* () const;

    // assignment operators
    D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& );
    D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& );
    D3DXVECTOR3& operator *= ( FLOAT );
    D3DXVECTOR3& operator /= ( FLOAT );

    // unary operators
    D3DXVECTOR3 operator + () const;
    D3DXVECTOR3 operator - () const;

    // binary operators
    D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const;
    D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const;
    D3DXVECTOR3 operator * ( FLOAT ) const;
    D3DXVECTOR3 operator / ( FLOAT ) const;

    friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& );

    BOOL operator == ( CONST D3DXVECTOR3& ) const;
    BOOL operator != ( CONST D3DXVECTOR3& ) const;

} D3DXVECTOR3, *LPD3DXVECTOR3;

#else //!__cplusplus
typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3;
#endif //!__cplusplus

C++ Operators Compared In (FLOAT x, FLOAT y, FLOAT z) Variables

Operators Compared in Different Languages

http://msdn.microsoft.com/en-us/library/2hxce09y%28VS.71%29.aspx


صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites
ProgAndy

$D3DXVector3 = DllStructCreate("float X;float Y;float Z")

this line is correct, but you have an error in your DLLCall. You forgot to call DLLStructGetPtr :D

DLLCall(... , 'ptr', DLLStructgetPtr($D3DXVector3))


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
JRowe

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.