Jump to content

[SOLVED] Is it possible to rotate the origin of InternalModule with a PartModule KSPEvent?


Recommended Posts

Hello everyone, I have a question about IVA animation/rotation.
Is it possible to rotate / animate the origin of an InternalModule through a KSPEvent tied to a PartModule?

The reason why I'm asking this is one, I'm very new to plugin development (very ignorant about what's possible or not), and two, I don't want to waste time trying to solve the impossible since this is the only reason I have to learn plugin development.

For context, let me explain what I'm attempting to do. The plugin I'm trying to write is a PartModule called ModuleCentrifuge.

  • I would like to (ideally) define a KSPField public integer called rotationalVelocity which defines the speed of rotation for the centrifuge animation. It is important that the craft be rotated through animation in a non-physical manner, to avoid physics calculations.
  • A animation is then defined which rotates the part along the y axis (up / down in the VAB) as well as an expected attached internal space
  • Another KSPField public float called ecRate defines the amount of electric charge consumed when the centrifuge rotates.
  • Two KSPEvents are defined which are called "Start Centrifuge" and "Stop Centrifuge" which starts or stops the rotation of both the PartModule and InternalModule

The impetus for creating this plugin, is to facilitate proper window view orientation in rotating centrifuge habitat IVAs.

Any help / clarity / advice would be very much appreciated!

EDIT:

After teaching myself enough about both c# and the KSP plugin API, I have determined that, yes, everything I wanted to achieve is possible.

  • Instead of rotational velocity I used rotational degrees per second (well, actually rotations per minute divided by 60).
  • instead of two separate KSPEvents I use one to toggle between start and stop states utilizing Events["nameOfEvent"].guiName = "newGuiName"
  • rotating the external model is accomplished by accessing the parent Part class, part.FindModelTransform(name of transform), assigning the found transform to a variable and then using Transform.Rotate(0, angle, 0)
  • rotating the internalModel is accomplished by accessing the parent Part class child object internalModel which has the same method of FindModelTransform, so part.internalModel.FindModelTransform
  • both the external model and internal model are accessible from within the partModule class, so there's no need to mess around with making a separate instance of internalModel.
Edited by Bonus Eventus
solved my own question, inserted the answer
Link to comment
Share on other sites

So poking around some more I found this thread by @Mihara from 2013 

Here @Mihara says quite explicitly:

Quote
xEvilReeperx said:
If you can make PartModule work, that's absolutely the way to go. I've never worked with IVA stuff so I had no idea you could use PartModules there.

You can't. :) An InternalModule can pretty easily find a PartModule that lives inside a specific part and make use of it's KSPField indirectly, though.

This answers whether or not a PartModule can communicate with an InternalModule. What I need to do now is try to find out if it's feasible to mimic the rotation of the external centrifuge with the internal centrifuge. I'm thinking I can do it by setting a ksp field through fixedupdate. Then retrieving the transform quaternion on start from within the internal centrifuge module and updating the iva origin rotation through fixed update from that transform reference.

I'm planning on releasing this as a tiny plugin for mod makers to make centrifuge IVA creation easier. This might be of interest to, @Badsector@Porkjet, @ShotgunNinja

 

Edited by Bonus Eventus
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...