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.

DarkBASIC Professional Discussion / Correct mesh position using jGfx instances

Author
Message
Kuper
14
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 13th Feb 2022 04:10 Edited at: 13th Feb 2022 04:14
Hi! Little stuck here
I found that objects created with jGfx instance system need their position/rotation correction.
I have object with limb inside, and limb is offseted a little bit, so if you call "limb position x(1)" it will be not zero. After that when I positioned object in scene it is not the same as object which was created by DBPro ( not using Jgfx ).
So I guess that JGfx doesn't use position/rotation/scale of particular limb and i need to offset each limb in Jgfx instance - according to saved limb data manually.
Ok it works fine with position only, but with added rotation not.
So I think that maybe I need to recalculate something like WorldMatrix based onbject pos/angle plus limb pos/angle , then get from it new position/scale values and then reposition my Jgfx Instance?
Also there is "GeoInst_SetWorldMatrixPtr" command - maybe using it will give more correct results?
Or there is an easier way?
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 13th Feb 2022 06:54 Edited at: 13th Feb 2022 06:55
I'm doing same thing at the moment, but reading in DBO files and manipulating the transform matrix (y position) per frame plus the animation position (quat or matrix) on the y axis which works perfectly for my needs.
I'm doing this by getting a pointer to the object and finding the transform data and updating it and then saving back out as a new model object.
I'll have a look at the JGFx as I have looked at that but not messed with it much.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 13th Feb 2022 07:32 Edited at: 13th Feb 2022 09:10
just a quick glance at the jgfx commands again, it looks like you need:
Poke Mat4=jGfx\Poke_Mat4.html=pMem, _11#, _12#, _13#, _14#, _21#, _22#, _23#, _24#, _31#, _32#, _33#, _34#, _41#, _42#, _43#, _44#

I will try this out on my current project see if it works. it should do. my current code uses :



So logical value 13 is actually physical value 14=pos y (OR row=3 and col=1 in my array), refer to directx SDK (transform matrix). So I'm basically grabbing _42# value and changing it.

Same will apply to rotations.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Kuper
14
Years of Service
User Offline
Joined: 25th Feb 2008
Playing: Planescape:Torment
Posted: 14th Feb 2022 05:16
Thanks!
I choose to update instance positon/rotation/scale per instance. ( because i so weak in matrixes )
Project attached. It is also useful if you need to create planet and moon for example ( or any objects which are parented to each over )
For angle reorienting you can also use EZRotate plugin ( which is free ) It provides a little bit different values though.

I try to use double floats to provide more accurate values in DBPro functions but results are still little-little different. Anyway for me everything works totally fine in both ways.
By the way there is newer version of Jgfx instance plugin called GeoInst here on the last pages: https://forum.thegamecreators.com/thread/220206?page=2
I got that there are no issues there.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2023-02-01 12:45:19
Your offset time is: 2023-02-01 12:45:19