Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 01-24-2019, 12:33 AM   #1
fred18
Addon Developer

Default Get actual vertexes in sim...

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
fred18 is offline   Reply With Quote
Old 01-24-2019, 05:35 AM   #2
jarmonik
Beta Tester

Default

Quote:
Originally Posted by fred18 View Post
 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.
jarmonik is offline   Reply With Quote
Thanked by:
Old 01-24-2019, 07:36 AM   #3
jedidia
shoemaker without legs
 
jedidia's Avatar
Default

Quote:
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.
jedidia is offline   Reply With Quote
Thanked by:
Old 01-24-2019, 08:04 AM   #4
fred18
Addon Developer

Default

Thanks for the replies guys!

Quote:
Originally Posted by jarmonik View Post
 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


Quote:
Originally Posted by jedidia View Post
 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:
Quote:
Originally Posted by jedidia View Post
 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 by fred18; 01-24-2019 at 08:11 AM.
fred18 is offline   Reply With Quote
Old 01-25-2019, 08:04 PM   #5
jarmonik
Beta Tester

Default

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.
Attached Files
File Type: zip D3D9ClientBeta28.5-forBETA r84(r1054).zip (1.70 MB, 3 views)
jarmonik is offline   Reply With Quote
Thanked by:
Old 01-26-2019, 02:08 AM   #6
fred18
Addon Developer

Default

Quote:
Originally Posted by jarmonik View Post
 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!!!
fred18 is offline   Reply With Quote
Old 02-10-2019, 02:13 PM   #7
fred18
Addon Developer

Default

Quote:
Originally Posted by Soll1943 View Post
 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?
fred18 is offline   Reply With Quote
Old 02-18-2019, 01:07 AM   #8
Zandy12
Add-on Developer
 
Zandy12's Avatar
Default

hahahahaha you guys are such nerds.
Zandy12 is offline   Reply With Quote
Thanked by:
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 02:07 PM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright ©2007 - 2017, Orbiter-Forum.com. All rights reserved.