Terranim2Chan

Started by neuspadrin, March 05, 2009, 12:42:24 AM

Previous topic - Next topic

neuspadrin

*edit*
i'm moving this over to file sharing section.
http://forums.planetside.co.uk/index.php?topic=5808
download will be there.
**

I was bored tonight, and was thinking about how it was nice and easy to use terranim with the original tg.  I thought about it and was thinking, why can't we use this with terragen 2? 

* ~4 hours of code later *

So I came up with a file converter for the .tgs file output to the newer tg2 chan system.  Few annoying conversions, tweaks to fix it so when imported to tg2 it would work, and I think I have a nice little java program that will work for all.  It's getting late right now and I got a midterm tomorrow and still have a few more little tweaks I need to fix and spruce up the code, but then I'll be uploading it and you guys can try it out.

some side notes of where it wont work as well: if you do shader displacements it is going to mess it up.  this works best with only generated terrain that you then saved, and switched to a load, or by a terrain that was by load originally anyways.  so kinda restrained to that currently unless there's someway to export a .ter that includes the shader's displacement that I don't know about.

Pull out the old terranim, and get some animations going. :)

Currently, it asks you for 4 things. 
1. The input .tgs file
2. the size of the terrain (for example, the default generated terrain i was working on is 1000x1000, so you would put 1000 in there)
3. the size of terrain in meters (for example, the default generated is at 10000 meters)
4. where to output the file.

then you click convert and shazam, a nice little txt file that you can import into tg2 as a chan file.


for those curious in how done:

It needs to have the .ter size and the size in terragen to calculate the ratio of the coordinates.  As when in terranim you animate it on a 1000x1000 grid, but when in tg2 it's stretched to to be 10000x10000, so all coordinates need to be multiplied by 10. 

The tgs file had a point of the camera, and the point the camera looked at, usually very small movements from one another.  I simply applied some basic knowledge of 3d coordinates, and trig, to convert the looking at point into the various pitch and such. 

formula example: arctan( (y2-y) / sqrt((x2-x)^2 +(z2-z)^2))

first you need to find the hypotenuse in one pair of coordinates, depending on what you want.  this is now the length of the adjacent side, with the rate of change of the last variable the opposite side.  to find the angle we need, it's arctan, as with opposite and adjacent, we can calculate tan(theta), so we then to get theta (the angle we need) we just arctan(change of y / hypotenuse of others)

things along those lines, etc.

rcallicotte

I'd like to check this out, but I'm not sure when.  As soon as it's available, I'll download and make plans to see what can happen.
So this is Disney World.  Can we live here?

neuspadrin

#2
Uploaded, check first post.  It's quite basic and can't account for everything that can be modified in Terragen2, but with simple landscapes without a ton of displacement shaders, and based around 0,0,0, it works quite well from my quick tests.

*edit updated the readme for the download, forgot to spell check first :P *

Readme File:
QuoteTerranim2Chan
-----------------------------
Created by: Spencer Brooks
Terragen Forums: neuspadrin
Date: 05/03/2009
Version: 1.0

-----------------------------
About:
-----------------------------
Terranim2Chan will take the output Terragen script from Terranim (.tgs),
and convert it into a .txt file that is readable as a chan file in
Terragen 2 for camera movement through frames.

-----------------------------
How To Use:
-----------------------------
Double click the Terranim2Chan file to run the jar file.  It should come
up with a small window.
- First browse to find the tgs file you wish to convert.
- Then double check the ter size and meters size for the conversion.
   By default TG2 generated terrain is 1000 ter size, and 10000 meters.
- Now browse to find where to save the file to.  You can save to an
   existing txt file, or type in a name for a new one.  If you do not
   set the file type to .txt, the program will automatically add it for you.
- Click convert.  The process should only take a second or two, but may be
   longer depending on the length of the animation.
- Once finished, it should pop up telling you it successfully completed, and
   inform you how many frames were processed from the tgs file.

-----------------------------
Tips to make it work:
-----------------------------
- Keep things as close to default, such as the terrain location when imported.
- Keep things square, ter size and meters.  Not 100% sure if it will work
  otherwise.
- Displacement outside the ter (shaders for example) will not be shown when
  creating the animation in Terranim, and thus, might cause it hard to animate
  later as the terrain will be different heights/positions, etc.  Try to keep
  shader displacements as small as possible.
- Compensate for vegetation.  If you are doing close fly by's make sure you keep
  in mind where the vegetation will be too.

-----------------------------
Updates to come:
-----------------------------
Modify start position of the camera to allow to start on different areas
besides default.

-----------------------------
Requirements:
-----------------------------
Java Runtime Environment to run the jar file.

-----------------------------
Where can I get...
-----------------------------
Terranim:
http://www.ashundar.com/index.php?topic=3840.msg29642#msg29642
It also comes inside the original Terragen .9 download now it seems.

Java:
http://www.java.com/

-----------------------------
Questions? Bugs?
-----------------------------
Just PM me on the official Terragen forums, user neuspadrin.

neuspadrin

I think I might've not tried enough tgs converts against it, i just had 2 quick simple animations run through and they ran fine, but now i just tried a longer more complex around places one, and it didn't convert correctly.  I think it has to do with direction of the camera, and how I calculate it.  I should have fix by tonight. I believe its a stupid little calculation that I didn't think about but made a boo-boo :P Sorry about that.  Ill get a fix asap.

rcallicotte

Please - no hurry on my account.  I'm very busy this week, though I'm very interested.  I actually can't wait to see what Planetside does next with this.
So this is Disney World.  Can we live here?

neuspadrin

#5
Well, its some easy fixes, glancing at code....

Apparently I shouldn't do trig in 3d at 1am in the morning.... :P Some stupid mistakes, forgetting to compensate for angle calculations :P thus the camera starts spinning wild sometimes....

Should be easy to just recalculate once I'm done with class in a bit, and fix it.  Should have an updated version by tonight that SHOULD work :P

*edit*
Fixed, almost 100% sure it should work given the limits i already stated, such as keeping it anchored at 0,0, and no shader displacements that are large.

also, for those wanting to see a very quick 8 seconds at 25 frames/second video, 320x240, very low quality render example: http://www.youtube.com/watch?v=8N9Q7TtHViU

theres a small lil glitch in the animation, i relized later i had forgotten to render one frame, as i had to stop rendering for a bit and then restarted, but restarted on the wrong frame.  so it glitches near the end.

neuspadrin

moved download into file sharing section, future updates will be from there, cleaner thread.
http://forums.planetside.co.uk/index.php?topic=5808