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 / How do I access internal "struct tagMatrixData" to use in a plugin?

Author
Message
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 20th Apr 2012 01:23
I'm hoping it is as simple as GetObject(ID) or something similar. I've been reading through the google source for DBP and just to speed things up I'm trying the get the tagMatrixData pointer for a Matrix's ID.

Although through the code "CMatrix.cpp", I've noticed "m_ptr" being used in the dll and I'm hoping that this can be accessed somehow globally. I've got the header file ready.

I'm planning on adding some real-time noise commands to the Matrix set to set the heights and calculate the normals but I'm currently at a brick wall.

Any help would be greatly appreciated, and mega thanks in advance.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 20th Apr 2012 17:14 Edited at: 20th Apr 2012 17:17
There's a hack to access it by writing to the camera's projection matrix, updating a matrix from the camera and then restoring the original projection matrix:

See Dmitry K's post:
http://forum.thegamecreators.com/?m=forum_view&t=124926&b=22

You can get the camera struct declaration here, which is not necessary but makes it less hacky:
http://forum.thegamecreators.com/?m=forum_view&t=112858&b=18

[b]
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Apr 2012 04:10
@Diggsey - Thanks for that info on the Camera hack. I've come up with an idea for using that. It wasn't what I was looking for though. It's DBP Matrix functions for handling matrix terrains is what I am hoping to get to the internal data for.

I've finished a function which calculates the normals for a matrix terrain but if I had access to the internal data it would be even more useful for larger terrains on-the-fly normals calculating.

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Apr 2012 14:42
Ah, my mistake. It seems like it's impossible to do without some serious hacks.

[b]
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 21st Apr 2012 15:15
It looks so far that the Matrix terrain internal data can only be accessed by recompiling and update of the dll for DBP.

So far using dbGetObject() returns the sObject* pointer for an object and you can get to the internal data of Images and possibly other things too which I've not come across yet. Maybe a request to the update posts for DBP to pass these pointers (even if they're not available in DBP but they're in the dll). Hmm...

Thanks man...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Apr 2012 16:18
Well there are hacky ways to do it as I said:
- The address of "m_ptr" will be at a fixed offset from the address returned by GetModuleHandle/LoadLibrary for the matrix dll. If you can find this offset using a debugger you can use it in your program. Beware that this offset may change if the matrix dll is recompiled.

- Exported commands will access "m_ptr", and you can get the address of exported commands with GetProcAddress(). You could then search through the code at that address for the address of "m_ptr". This is more complicated but is much more resilient to changes in the matrix dll.

[b]
WLGfx
16
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 22nd Apr 2012 14:23 Edited at: 22nd Apr 2012 14:58
I've been having a good think about this so I dug out dependency walker to browse through the dll. I did find some things which I'll have a check up on. Fingers crossed it's what I need to speed some of these things up as I've got a few more matrix additions I want to do.



As well as that there's got to be a link to the outside world from the dll for g_pGlobStruct, but all I can find so far is the dll pointer. It looks like the GetProcAddress() is the route to go down as I can initialise the function pointers when my dll loads up.

I'm also going to look into an external debugger other than the built in one that comes with Visual Studio Express...

Thankyou...

EDIT: I think I'll use DGDK and browse the functions using the debugger anyway...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-04-16 11:29:36
Your offset time is: 2024-04-16 11:29:36