Advanced Question Get actual vertexes in sim...

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
Hi guys,

I'll make it very brief. I would like to build a mesh file from an existing one, but, since the original is animated, I would like to build it at the moment in which I am looking at the sim, so the animation is at a certain point.

Now, I got familiar with various oapiMeshGroup, oapiGetMeshGroup and whatever is there, I could modify the mesh myself in any way I want and get the proper vertexes in that case, but not from a vessel running by itself in the sim... It seems like GROUPREQUESTSPEC retrieve the original vertexes if I the animation is performed by the vessel itself instead than from my plugin.

The vertexes are for sure there, somewhere in the graphics RAM, since I see the animated mesh on the sreen, but how can I get them?

Maybe the D3D9 team can be more on the ball about this? it seems to me a very complicated question, hope someone can help :cheers:
 

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
The vertexes are for sure there, somewhere in the graphics RAM, since I see the animated mesh on the sreen, but how can I get them?

There are no animated vertices in a graphics RAM just the original non-animated. Animation Matrix is applied in the original vertex data to transform it into a specific animation state. This is done in a vertex shader.

There is some kind of mechanics to transform vertices (or vectors) that is usually used to compute a grapple points in a robotic arms but I have no experience about it.

I suppose it should be possible to implement something in the D3D9 to retrive a set of transformed vertices. Most likely solution would be to acquire the animation matrix: Something like FMATRIX4 gcGetGroupAnimMatrix(VISHANDLE, mesh_idx, group_idx); After that you would need to multiply the original vertices/normals with the matrix.
 

jedidia

shoemaker without legs
Addon Developer
Joined
Mar 19, 2008
Messages
10,842
Reaction score
2,105
Points
203
Location
between the planets
I'll make it very brief. I would like to build a mesh file from an existing one, but, since the original is animated, I would like to build it at the moment in which I am looking at the sim, so the animation is at a certain point.

You can get a copy of the mesh, and you can get at the animations, but in order transform the actual mesh data you'd have to apply the animations yourself. Not impossible, but quite a bit of work, as you'd basically have to re-implement animations on a higher level than orbiter is handling them at.

Maybe if you state the use case the functionality is intended for, somebody could see a better way to do it.
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
Thanks for the replies guys!

I suppose it should be possible to implement something in the D3D9 to retrive a set of transformed vertices. Most likely solution would be to acquire the animation matrix: Something like FMATRIX4 gcGetGroupAnimMatrix(VISHANDLE, mesh_idx, group_idx); After that you would need to multiply the original vertices/normals with the matrix.

I understand the concept, but I have no idea on how to implement this. If I can have the "current" animation matrix of a mesh then my issues would surely be solved, but I wouldn't know how to code this at all :shrug:


You can get a copy of the mesh, and you can get at the animations, but in order transform the actual mesh data you'd have to apply the animations yourself. Not impossible, but quite a bit of work, as you'd basically have to re-implement animations on a higher level than orbiter is handling them at.

Maybe if you state the use case the functionality is intended for, somebody could see a better way to do it.

How can you get the animations?

Sure, the use is the following:

You probably saw that recently Zandy12 has published the udpated version of Donamy and Thorston ISS A to Z, which is an amazing work. In time I really had lost track of that wonderful addon because of the enormous quantity of vessels and modules that were included in the package, at the moment around 245 vessels.
So, as promised in THIS post I started to work on a simplification and I quite made a lot of way along the path:
I managed to get all the meshes, located them in the right offsets, rotated them to the right attitude, and then write a big mesh file which merges all of them. The code of the plugin that made it made me quite scratch my head for all the docking and attachment rotation matrixes but it works really well now.
The issue is that most of the vessels have animations... Most of them are "dead" animations, like docking petals opening (which won't be closed anymore) or solar panels deploying (which won't be closed anymore...) etc, so in order to write the big mesh file I need to get the animated vertexes, not the base ones.
In the end I would anyway take out from the merged vessels all the "live" components, such as robotic arms, CMG, Cupola and solar panels. But still the 245 vessels could be reduced to let's say 10, and that would be a huge simplification and with such simplification at least I would use that ISS much much more.
Now, many vessels are SC3 vessels, so if I can't get the animated meshes from the sim, I could go and parse the SC3 ini file, create the animation matrixes myself, then go and parse the scenario file to get the animation statuses and apply it, but it's quite a long way to go compared to get the vertexes directly from the sim... and that would anyway work only for sc3 vessels

you said this:
and you can get at the animations,

that would be my solution since there is no issues in implementing the vertexes editing myself, but how can I do it? is the GetAnimPtr function something I should start from?

Thanks!
 
Last edited:

jarmonik

Well-known member
Orbiter Contributor
Addon Developer
Beta Tester
Joined
Mar 28, 2008
Messages
2,651
Reaction score
785
Points
128
I have added gcGet/SetMatrix() functionality in the D3D9. However, I have not been able to test it.

So, the function call to get the matrix you need is:

gcGetMatrix(gcMatrix::combined, hVessel, mesh_idx, group_idx, oapi::FMATRIX4 *pAminOut);

See gcAPI.h for additional details.

The combined matrix is (MeshAnim * GroupAnim * Offset), so, there are three matrices defining the final position for vertex in local vessel coordinates. If there are issues then please check the latest commit from D3D9 SVN.
 

Attachments

  • D3D9ClientBeta28.5-forBETA r84(r1054).zip
    1.7 MB · Views: 4

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
I have added gcGet/SetMatrix() functionality in the D3D9. However, I have not been able to test it.

So, the function call to get the matrix you need is:

gcGetMatrix(gcMatrix::combined, hVessel, mesh_idx, group_idx, oapi::FMATRIX4 *pAminOut);

See gcAPI.h for additional details.

The combined matrix is (MeshAnim * GroupAnim * Offset), so, there are three matrices defining the final position for vertex in local vessel coordinates. If there are issues then please check the latest commit from D3D9 SVN.

WOW! I have no words to thank you for your support, everytime I'm looking for something which somehow can be dealt in the nieghborhood of D3D9 you always give super help in such a short time!!!

In the meantime I found the way to trace back from GetAnimPtr to everything about animations and vertex editing, it's a bit crazy but it's working... Anyway this new method you just provided will be super useful for this application and for many more to come :) I will test it and get back to you if there is anything which does not work!

Thanks!!! :hailprobe:
 

fred18

Addon Developer
Addon Developer
Donator
Joined
Feb 2, 2012
Messages
1,666
Reaction score
100
Points
78
By the way, talking about solar panels. How this technology could be used in the future?
For now, it is necessary for the computer industry. NASA’s has also successfully deployed solar panels – needed to power the lander – on the Red Planet. The process of installing the solar panels (see this link is in the testing stage. But I think the principles and scheme of an alternative source of energy are more complicated.

?? wrong thread?
 

Zandy12

Add-on Developer
Donator
Joined
Nov 19, 2017
Messages
170
Reaction score
2
Points
18
Location
Ames
hahahahaha you guys are such nerds. :cheers:
 
Top