Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / [Problem] - Making TPC with PureBasic with Object Position Problem

Author
Message
MikeK
20
Years of Service
User Offline
Joined: 13th Sep 2004
Location: Apparently
Posted: 2nd Jan 2009 22:19 Edited at: 3rd Jan 2009 06:10
Hey all,

Just a quick request for help on creating a TPC with PureBasic and getting a specified object's position;

The following procedures I have (as well as the InvokeCorePtr,etc) to get an objects are;



Now when another procedure (defined as CDLL to be used in dbpro) in the TPC code attempts to get an object's position (that does exist in the 3d space), all 3 procedures return '0'..?

When changing the function called from "?GetXPosition@@YAMH@Z" to "?GetXSize@@YAKH@Z", It works fine...

Anyone have any idea's?

Thanks

Mikey

:: HybridTwo Sound & Music Production Studio : BinaryZoo Studios ::
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jan 2009 01:56
Ok, I think I might take a shot at this one.

Correct me if I'm wrong, but you are storing the result of the call to GetXPosition in a 'long'. Then you are converting it to a float. Then you are passing back the float.

If that's the case, then don't bother converting to a float - just pass back the 'long'.

DBPro requires you to pass back floats as if they were DWORD values, or in your case 'long' values.

MikeK
20
Years of Service
User Offline
Joined: 13th Sep 2004
Location: Apparently
Posted: 4th Jan 2009 02:19
The result of the returns a constant value, which to me indicates a handle to a memory allocation storing the value, but I have tried just using the returned value from the call, peeking a long/dword from the call, and a float, but nothing seems to want to give me the location of the object in 3d space...

:: HybridTwo Sound & Music Production Studio : BinaryZoo Studios ::
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jan 2009 12:10
I've taken a closer look at the functions available.

What I said applies to ?GetXPositionEx@@YAKH@Z - it returns a float held within a DWORD.

You are using ?GetXPosition@@YAMH@Z - that returns a straight float value that you may be able to use directly.

I know that the first one works correctly as I use it myself and DBPro uses it (the OBJECT POSITION X maps to it). You'll need to test yourself to see if the one that you use works correctly, but I don't see why it shouldn't.

MikeK
20
Years of Service
User Offline
Joined: 13th Sep 2004
Location: Apparently
Posted: 4th Jan 2009 15:57
Hey again, (sorry for being a pain in the ass lol)

Right, IanM, using the Get Position Ex call works fine, it returns a value that actually changes when the object's position changes;

One more question though;

The value returned with the Get Position Ex returns quite a high figure, which isn't at all expected... I'll explain;


Say I make a cube primitive of 100 pixels in size, and position it 100, 100, 100 - When using the Get Position Ex call, for the X position (only axis tested so far) it returns '1120403456' as the value... Which obviously isn't expected...

Is there a solution to correcting these values? or am I going to have to make do with that?

Thankyou so much again

Mikey

:: HybridTwo Sound & Music Production Studio : BinaryZoo Studios ::
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jan 2009 16:28
That's the binary value for the float value of 100. Now all you need to do is pass that back to DBPro using a DWORD return type, but tell DBPro that the parameter is of type 'F' for float.

Unfortunately, I can't tell you how to do that in PureBasic because I don't know the language. If you were using C or C++ I'd have already shown you what to do with code.

MikeK
20
Years of Service
User Offline
Joined: 13th Sep 2004
Location: Apparently
Posted: 4th Jan 2009 20:28 Edited at: 4th Jan 2009 20:29
That's great,

Works perfectly now

Thankyou kindly, Ian


- For any other PB users who may be stuck on the same problem;

The way to extract the Float from the Dword, is to use PeekF then to use the Handle of the variable.

I.e.




Thanks again

Mike

:: HybridTwo Sound & Music Production Studio : BinaryZoo Studios ::

Login to post a reply

Server time is: 2024-11-23 06:54:28
Your offset time is: 2024-11-23 06:54:28