Sign in to follow this  
Followers 0
bogQ

3impact for autoit

3 posts in this topic

#1 ·  Posted (edited)

For some time i have problems with D3DXVECTOR3() and D3DXVECTOR4() that i can't solve myself, commands that use vectors r working but only from second parameter and after, i dono why dllcall dont react on first vector parametar so instead when i use light color (red green blue) i lose red color and it dont reflect on the any command, identical thing is happening when i try to use it for 3d position i lose X parametar so my position is off the track.

If needed for testing

The engine download is located at www.3impact.com

default_res folder need to b located at location of AutoIt3.exe so that filess can b loaded

Im trying to remake BallGame example "_Init()"

3ImpactApp.cpp is already replicated (not 100%) it shud b working for this example with no problems

3impactDLL_defs.h holds D3DXVECTOR3 and D3DXVECTOR4 structure

Reference.txt holds command usage

Any help to solve this problem is apriciated

#include <WindowsConstants.au3>
#Include <Timers.au3>
$dll = DllOpen("dll3impact.dll")

#Region 3ImpactApp.cpp  for autoit
$hFullScreen = i3ImpactOpen("win name",639,479,0,0)
If i3ImpactSettings() Then
    $bCanceled = FALSE
    While i3ImpactIsRendering()
        If i3ImpactIsActive() Then
            $msg = GUIGetMsg()
        Else
            $msg = ""
        EndIf
        If $msg Then
            ;do something
        Else
            If i3ImpactIsActive() And i3ImpactIsReady() Then
                i3ImpactMain()
                If i3ImpactIsExecuting() Then
                    If i3ImpactIsInitializing() Then
                        i3ImpactInitBegin()
                        _Init();load loop
                        i3ImpactInitEnd()
                        If i3ImpactErrorFlag() Then _error();goto error
                    EndIf
                    If Not i3ImpactIsRendering() Then ExitLoop
                    If Not i3ImpactIsSkippingRunPhase() Then
                        i3ImpactRunBegin()
                        _Run();run loop
                        If i3ImpactErrorFlag() Then _error();goto error
                        i3ImpactRunEnd()
                    EndIf
                    if Not i3ImpactIsSkippingRenderPhase() Then
                        i3ImpactRender()
                    EndIf
                EndIf
            EndIf
        EndIf
    WEnd
    _error();goto error
EndIf
i3ImpactClose()
WinKill($hFullScreen)
#endregion 3ImpactApp.cpp  for autoit



#Region any example
Func _Init();body of the script
    $Camera=iCameraCreate(0,0,1,1)
    iCameraLocationSet($Camera,0.0,3.0,-10.0)
    iLightDirectionalSet(1.0, -1.0, 1.0, 5.0, 1.0, 1.0, 0.35)
    Global $LoadingMessage=iSpriteCreate("default_res\sprites\loading.x","")
    iSpriteRender($LoadingMessage,False)
    $SkyBox=iSkyBoxCreate("default_res\skyboxes\skybox01.sky")
    $Terrain=iBodyCreate("default_res\terrain_5.00.ply")
    $TerrainMesh=iBodyMeshCreate("default_res\terrain.x",$Terrain)
    $Ball=iBodySGCreate("default_res\ball_.spg",0.13)
    $BallMesh=iBodyMeshCreate("default_res\ball.x",$Ball)   
    iBodyLocationSet($Ball,0,5,0,TRUE)  
    
    
    
    
    
    
    
    iMeshShow($TerrainMesh)
    iMeshShow($BallMesh)
    iSkyBoxShow($SkyBox)
EndFunc


Func _Run();main loop

EndFunc
#endregion any example



#Region 3ImpctApp.cpp  sub functions
Func _Exit();before exit
    
EndFunc

Func _error();goto error
    i3ImpactExitBegin()
    _exit()
    i3ImpactExitEnd()
EndFunc
#endRegion 3ImpctApp.cpp  sub functions










#region 3ImpctApp.cpp  functions
Func i3ImpactOpen($guiname,$winwidth,$winheight,$posx,$posy)
    $return = GUICreate($guiname,$winwidth,$winheight,$posx,$posy,$WS_POPUP+$WS_CAPTION)
    GUISetState(@SW_SHOW)
    $return1 = DllCall($dll, "int:cdecl", "i3ImpactOpen", "HWnd", $return)
    If @error Then
        MsgBox(0,"error","i3ImpactOpen"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return
    EndIf
EndFunc
Func i3ImpactIsRendering()
    $return = DllCall($dll, "int:cdecl", "i3ImpactIsRendering")
    If @error Then
        MsgBox(0,"error","i3ImpactIsRendering"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactIsActive()
    $return = DllCall($dll, "int:cdecl", "i3ImpactIsActive")
    If @error Then
        MsgBox(0,"error","i3ImpactIsActive"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactIsReady()
    $return = DllCall($dll, "int:cdecl", "i3ImpactIsReady")
    If @error Then
        MsgBox(0,"error","i3ImpactIsReady"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactMain()
    $return = DllCall($dll, "int:cdecl", "i3ImpactMain")
    If @error Then
        MsgBox(0,"error","i3ImpactMain"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactIsExecuting()
    $return = DllCall($dll, "int:cdecl", "i3ImpactIsExecuting")
    If @error Then
        MsgBox(0,"error","i3ImpactIsExecuting"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactIsInitializing()
    $return = DllCall($dll, "int:cdecl", "i3ImpactIsInitializing")
    If @error Then
        MsgBox(0,"error","i3ImpactIsInitializing"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactInitBegin()
    $return = DllCall($dll, "int:cdecl", "i3ImpactInitBegin")
    If @error Then
        MsgBox(0,"error","i3ImpactInitBegin"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactInitEnd()
    $return = DllCall($dll, "int:cdecl", "i3ImpactInitEnd")
    If @error Then
        MsgBox(0,"error","i3ImpactInitEnd"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactErrorFlag()
    $return = DllCall($dll, "int:cdecl", "i3ImpactErrorFlag")
    If @error Then
        MsgBox(0,"error","i3ImpactErrorFlag"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactExitBegin()
    $return = DllCall($dll, "int:cdecl", "i3ImpactExitBegin")
    If @error Then
        MsgBox(0,"error","i3ImpactExitBegin"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactExitEnd()
    $return = DllCall($dll, "int:cdecl", "i3ImpactExitEnd")
    If @error Then
        MsgBox(0,"error","i3ImpactExitEnd"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactIsSkippingRunPhase()
    $return = DllCall($dll, "int:cdecl", "i3ImpactIsSkippingRunPhase")
    If @error Then
        MsgBox(0,"error","i3ImpactIsSkippingRunPhase"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactRunBegin()
    $return = DllCall($dll, "int:cdecl", "i3ImpactRunBegin")
    If @error Then
        MsgBox(0,"error","i3ImpactRunBegin"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactRunEnd()
    $return = DllCall($dll, "int:cdecl", "i3ImpactRunEnd")
    If @error Then
        MsgBox(0,"error","i3ImpactRunEnd"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactIsSkippingRenderPhase()
    $return = DllCall($dll, "int:cdecl", "i3ImpactIsSkippingRenderPhase")
    If @error Then
        MsgBox(0,"error","i3ImpactIsSkippingRenderPhase"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactRender()
    $return = DllCall($dll, "int:cdecl", "i3ImpactRender")
    If @error Then
        MsgBox(0,"error","i3ImpactRender"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactClose()
    $return = DllCall($dll, "int:cdecl", "i3ImpactClose")
    If @error Then
        MsgBox(0,"error","i3ImpactClose"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
#endregion 3ImpctApp.cpp  functions


#Region any example commands
Func iSkyBoxCreate($char)
    $return = DllCall($dll, "ptr:cdecl", "iSkyBoxCreate","str",$char)
    If @error Then
        MsgBox(0,"error","iSkyBoxCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc

Func iSkyBoxShow($sb)
    $return = DllCall($dll, "int:cdecl", "iSkyBoxShow", "ptr", $sb)
    If @error Then
        MsgBox(0,"error","iSkyBoxCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func iCameraCreate($top,$left,$width,$height)
    $return = DllCall($dll, "ptr:cdecl", "iCameraCreate","float",$top,"float",$left,"float",$width,"float",$height)
    If @error Then
        MsgBox(0,"error","iCameraCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func iCameraLocationSet($CAMERA,$D3DXVECTOR3_temp_1,$D3DXVECTOR3_temp_2,$D3DXVECTOR3_temp_3)
    $return = DllCall($dll, "ptr:cdecl", "iCameraLocationSet", "ptr", $CAMERA, "ptr",D3DXVECTOR3($D3DXVECTOR3_temp_1,$D3DXVECTOR3_temp_2,$D3DXVECTOR3_temp_3))
    If @error Then
        MsgBox(0,"error","iCameraLocationSet"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func iLightDirectionalSet($D3DXVECTOR3_temp_1,$D3DXVECTOR3_temp_2,$D3DXVECTOR3_temp_3,$D3DXVECTOR4_temp_1,$D3DXVECTOR4_temp_2,$D3DXVECTOR4_temp_3,$D3DXVECTOR4_temp_4)
    $return = DllCall($dll, "ptr:cdecl", "iLightDirectionalSet","ptr",D3DXVECTOR3($D3DXVECTOR3_temp_1,$D3DXVECTOR3_temp_2,$D3DXVECTOR3_temp_3),"ptr",D3DXVECTOR4($D3DXVECTOR4_temp_1,$D3DXVECTOR4_temp_2,$D3DXVECTOR4_temp_3,$D3DXVECTOR4_temp_4))
    If @error Then
        MsgBox(0,"error","iLightDirectionalSet"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func D3DXVECTOR3($D3DXVECTOR3_1,$D3DXVECTOR3_2,$D3DXVECTOR3_3)
    $D3DXVECTOR3_temp = DllStructCreate("float 1;float 2;float 3")
    DllStructSetData($D3DXVECTOR3_temp,'1',$D3DXVECTOR3_1)
    DllStructSetData($D3DXVECTOR3_temp,'2',$D3DXVECTOR3_2)
    DllStructSetData($D3DXVECTOR3_temp,'3',$D3DXVECTOR3_3)
    Return DLLStructgetPtr($D3DXVECTOR3_temp)
EndFunc
Func D3DXVECTOR4($D3DXVECTOR4_1,$D3DXVECTOR4_2,$D3DXVECTOR4_3,$D3DXVECTOR4_4)
    $D3DXVECTOR4_temp = DllStructCreate("float 1;float 2;float 3;float 4")
    DllStructSetData($D3DXVECTOR4_temp,'1',$D3DXVECTOR4_1)
    DllStructSetData($D3DXVECTOR4_temp,'2',$D3DXVECTOR4_2)
    DllStructSetData($D3DXVECTOR4_temp,'3',$D3DXVECTOR4_3)
    DllStructSetData($D3DXVECTOR4_temp,'4',$D3DXVECTOR4_4)
    Return DLLStructgetPtr($D3DXVECTOR4_temp)
EndFunc
Func iSpriteCreate($char,$cam="")
    $return = DllCall($dll, "ptr:cdecl", "iSpriteCreate","str",$char,"ptr",$cam)
    If @error Then
        MsgBox(0,"error","iSpriteCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func iSpriteRender($SPR,$rp)
    $return = DllCall($dll, "ptr:cdecl", "iSpriteRender","ptr",$SPR,"int",$rp)
    If @error Then
        MsgBox(0,"error","iSpriteCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc

Func iBodyCreate($char)
    $return = DllCall($dll, "ptr:cdecl", "iBodyCreate","str",$char)
    If @error Then
        MsgBox(0,"error","iSpriteCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc

Func iBodySGCreate($char,$FLOAT)
    $return = DllCall($dll, "ptr:cdecl", "iBodySGCreate","str",$char,"float",$FLOAT)
    If @error Then
        MsgBox(0,"error","iBodySGCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func iBodyLocationSet($BODY,$D3DXVECTOR3_temp_1,$D3DXVECTOR3_temp_2,$D3DXVECTOR3_temp_3,$BOOL)
    $return = DllCall($dll, "int:cdecl", "iBodyLocationSet","ptr",$BODY,"ptr",D3DXVECTOR3($D3DXVECTOR3_temp_1,$D3DXVECTOR3_temp_2,$D3DXVECTOR3_temp_3),"int",$BOOL)
    If @error Then
        MsgBox(0,"error","iBodyLocationSet"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func i3ImpactSettings()
    $str = "dword 1;dword 2;dword 3;dword 4;float 5;float 6"
    $a = DllStructCreate($str)
    DllStructSetData($a,"1","0")
    DllStructSetData($a,"2","0")
    DllStructSetData($a,"3","640*480*16")
    DllStructSetData($a,"4","0")
    DllStructSetData($a,"5",0)
    DllStructSetData($a,"6",0)
    $return = DllCall($dll, "int:cdecl", "i3ImpactSettings", "ptr", DLLStructgetPtr($a))
    If @error Then
        MsgBox(0,"error","i3ImpactSettings"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func iBodyMeshCreate($char,$BODY)
    $return = DllCall($dll, "ptr:cdecl", "iBodyMeshCreate","str",$char,"ptr",$BODY)
    If @error Then
        MsgBox(0,"error","iBodyMeshCreate"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
Func iMeshShow($MESH)
    $return = DllCall($dll, "ptr:cdecl", "iMeshShow","ptr",$MESH)
    If @error Then
        MsgBox(0,"error","iMeshShow"&" "&@error)
        Return Seterror(1,0,False)
    Else
        Return $return[0]
    EndIf
EndFunc
#endRegion any example commands

Edit:

added picture of a problem

Posted Image

autoit on the left

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites



Think of the mistake of creating an object inside a function, return a

pointer to it's memory, but it's already released when function returns.

Func D3DXVECTOR3($D3DXVECTOR3_1,$D3DXVECTOR3_2,$D3DXVECTOR3_3)
    $D3DXVECTOR3_temp = DllStructCreate("float 1;float 2;float 3")
    DllStructSetData($D3DXVECTOR3_temp,'1',$D3DXVECTOR3_1)
    DllStructSetData($D3DXVECTOR3_temp,'2',$D3DXVECTOR3_2)
    DllStructSetData($D3DXVECTOR3_temp,'3',$D3DXVECTOR3_3)
    Return DLLStructgetPtr($D3DXVECTOR3_temp)
EndFunc

Func D3DXVECTOR4($D3DXVECTOR4_1,$D3DXVECTOR4_2,$D3DXVECTOR4_3,$D3DXVECTOR4_4)
    $D3DXVECTOR4_temp = DllStructCreate("float 1;float 2;float 3;float 4")
    DllStructSetData($D3DXVECTOR4_temp,'1',$D3DXVECTOR4_1)
    DllStructSetData($D3DXVECTOR4_temp,'2',$D3DXVECTOR4_2)
    DllStructSetData($D3DXVECTOR4_temp,'3',$D3DXVECTOR4_3)
    DllStructSetData($D3DXVECTOR4_temp,'4',$D3DXVECTOR4_4)
    Return DLLStructgetPtr($D3DXVECTOR4_temp)
EndFunc

Should be:

Func D3DXVECTOR3($D3DXVECTOR3_1,$D3DXVECTOR3_2,$D3DXVECTOR3_3)
    $D3DXVECTOR3_temp = DllStructCreate("float 1;float 2;float 3")
    DllStructSetData($D3DXVECTOR3_temp,'1',$D3DXVECTOR3_1)
    DllStructSetData($D3DXVECTOR3_temp,'2',$D3DXVECTOR3_2)
    DllStructSetData($D3DXVECTOR3_temp,'3',$D3DXVECTOR3_3)
    Return $D3DXVECTOR3_temp
EndFunc

Func D3DXVECTOR4($D3DXVECTOR4_1,$D3DXVECTOR4_2,$D3DXVECTOR4_3,$D3DXVECTOR4_4)
    $D3DXVECTOR4_temp = DllStructCreate("float 1;float 2;float 3;float 4")
    DllStructSetData($D3DXVECTOR4_temp,'1',$D3DXVECTOR4_1)
    DllStructSetData($D3DXVECTOR4_temp,'2',$D3DXVECTOR4_2)
    DllStructSetData($D3DXVECTOR4_temp,'3',$D3DXVECTOR4_3)
    DllStructSetData($D3DXVECTOR4_temp,'4',$D3DXVECTOR4_4)
    Return $D3DXVECTOR4_temp
EndFunc

..then in the dllcall, make a temporary variable to hold and keep the vectors structures.

Share this post


Link to post
Share on other sites

Think of the mistake of creating an object inside a function, return a

pointer to it's memory, but it's already released when function returns.

..then in the dllcall, make a temporary variable to hold and keep the vectors structures.

Yes, you are correct, it was pretty dumb from my side,

ty alot Authenticity


TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 

Share this post


Link to post
Share on other sites

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  
Followers 0