JRowe Posted May 3, 2010 Share Posted May 3, 2010 (edited) My questions is this: I have a dllCall expecting a struct to be passed. The struct is 3 separate floats, not arrays. I build them like so: Local $StartVectorStruct = DllStructCreate("float;float;float") DllStructSetData($StartVectorStruct, 1 , $a_StartVector[0]) DllStructSetData($StartVectorStruct, 2 , $a_StartVector[1]) DllStructSetData($StartVectorStruct, 3 , $a_StartVector[2]) My question is this: when I pass it to the DllCall, do I want to pass ptr* or float* to pass the struct? or is it just a ptr? ;This DllCall($_irrDll, "none:cdecl", "IrrGetCollisionPoint", "float*", DllStructGetPtr($StartVectorStruct)) ;Or This... DllCall($_irrDll, "none:cdecl", "IrrGetCollisionPoint", "ptr*", DllStructGetPtr($StartVectorStruct)) ;Or even this? DllCall($_irrDll, "none:cdecl", "IrrGetCollisionPoint", "ptr", DllStructGetPtr($StartVectorStruct)) Also, what is the reason for struct indices starting at 1, instead of 0? Edited May 3, 2010 by JRowe [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
bo8ster Posted May 3, 2010 Share Posted May 3, 2010 I would say the third one since DllStructGetPtr returns a pointer to a structure. Regardless of your intent you have created a structure then sending it in, the help file specifes the same thing but with ints. float* is a pointer to a float which DllStructGetPtr does not return. ptr* is a pointer to a pointer which would mean DllStructGetPtr would have to return a ponter to another pointer for that to be valid. As for the second question, pass DllCall($_irrDll, "none:cdecl", "IrrGetCollisionPoint", "float*", DllStructGetPtr($StartVectorStruct, 1)) This might work also for the first element within the structure. Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic] Link to comment Share on other sites More sharing options...
JRowe Posted May 3, 2010 Author Share Posted May 3, 2010 Cool - I went with the third one in the end, but it started to get pretty funky for a while. Thanks! [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
trancexx Posted May 3, 2010 Share Posted May 3, 2010 I'm confused What is the description for IrrGetCollisionPoint? What's expected for the parameter to be? ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
JRowe Posted May 3, 2010 Author Share Posted May 3, 2010 (edited) integer = IrrGetCollisionPoint ( start as IRR_VECTOR, line_end as IRR_VECTOR, collision group as irr_selector, collision point as IRR_VECTOR ) The actual code I ended up with is: Func _IrrGetCollisionPoint($a_StartVector, $a_EndVector, $h_CollisionGroup) Local $StartVectorStruct = DllStructCreate("float;float;float") DllStructSetData($StartVectorStruct, 1, $a_StartVector[0]) DllStructSetData($StartVectorStruct, 2, $a_StartVector[1]) DllStructSetData($StartVectorStruct, 3, $a_StartVector[2]) Local $EndVectorStruct = DllStructCreate("float;float;float") DllStructSetData($EndVectorStruct, 1, $a_EndVector[0]) DllStructSetData($EndVectorStruct, 2, $a_EndVector[1]) DllStructSetData($EndVectorStruct, 3, $a_EndVector[2]) Local $CollisionVectorStruct = DllStructCreate("float;float;float") DllCall($_irrDll, "none:cdecl", "IrrGetCollisionPoint", "ptr", DllStructGetPtr($StartVectorStruct), "ptr", DllStructGetPtr($EndVectorStruct), "ptr", $h_CollisionGroup, "ptr", DllStructGetPtr($CollisionVectorStruct)) Local $result[3] = [DllStructGetData($CollisionVectorStruct, 1), DllStructGetData($CollisionVectorStruct, 2), DllStructGetData($CollisionVectorStruct, 3)] Return $result EndFunc An AutoIt version of a vector, then, would just be an array of 3 floats. edit: 0.o Looks like I have some revising to do. Edited May 3, 2010 by JRowe [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
trancexx Posted May 3, 2010 Share Posted May 3, 2010 edit: 0.oLooks like I have some revising to do.That looks better now to me. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now