Jump to content

Camera question


nistur

Recommended Posts

First of all, greetings! I've been playing KSP off and on for quite a while now, and I've been lurking around here for a little while. I figured a while back that I'd try my hand at some plugin dev stuff. My plugin(s) will address little itches I have about the game, so whether or not they're useful or interesting to other people will remain to be seen.

For my first trick, I thought I'd make a docking cam system. I quickly found a 3D model I could use1 and started poking at the code. Making a RenderTexture and displaying it was the easy part. Took a little while to figure out the positioning and direction from the model. The issue now is that I don't seem to be able to render the scene properly. Initially I could just see the components of the rocket, the launchpad and everything else was Unity's lovely shade of blue default clear colour. I figured I'd be clever and copy near/far clipping planes, culling mask and clear flags from the main camera, but then what I get is this:

GPtvPk4.png

And for reference, it's mounted thusly with nothing above it2

g00fJ9o.png

Does anyone have any experience with creating cameras for KSP that I could look at your code for how you set them up?

The camera renders to a 128x128 RenderTexture currently. I was playing with the idea of sticking a post processor on there and making it fuzzy and/or black and white. Maybe for a different camera model. I have 4 different cameras planned right now: standard cheap-o CCTV box (the current model) webcam (surface mount like linear RCS thrusters) HD cam (more round model CCTV with 256x256 RenderTexture) and one with limited movement. Also going to (when I figure out how this all works) plug it in so the cams only display when they are enabled. As well as help with why my cameras are playing up, I'd love to hear feedback.

1 although in hindsight, I may have to resize it a little, as it looks very out of place next to larger, clunkier parts.

2 I am, at best, a poor 3D modeller, but I'm a terrible texturer, right now it has some default material on it that makes it go black. I will try and texture it at some point, when I'm done arguing with the code perhaps.

Edit: After taking a little while away from this and coming back, the answer is relatively obvious, KSP is rendered with (at least) 2 cameras normally. One for a custom "skybox" and one for the player. I haven't been able to tell if there are more cameras yet. That does, however explain why the camera was going crazy.

Edit: I just checked the number of cameras present in the game scene on launch. 10. Eek. Well, I'm going to do some digging. With any luck I can pick a couple that I will need to use. I think adding 10 more game cameras per docking cam is more than a little unrealistic

Edited by nistur
Link to comment
Share on other sites

Thanks. This is exactly what I was looking for. I feel a bit silly replicating an existing mod, but as I said in my other thread, I sort of want my stuff to be complete and standalone. Knowing that this exists, I'll make sure the two can be used together without conflicts though.

Thanks again

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...