anachronox-sdk/docs/envmap/step1-cube.html

189 lines
6.9 KiB
HTML
Raw Permalink Normal View History

2002-01-21 00:00:00 +00:00
<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HTML>
<HEAD>
<META name="generator" content="HTML Tidy, see www.w3.org">
<TITLE>Step 1: Creating a Cube Map</TITLE>
<LINK type="text/css" rel="stylesheet" href="../webdocs.css">
</HEAD>
<BODY>
<P><A href="step2-povray.html">[Next - Step 2: POVray]</A></P>
<H1>Step 1: Creating a Cube Map</H1>
<P>The first thing you need to do before making an Anachronox
environment map is to create a cube map. A cube map is a neat
way to represent a 360&deg; view of an environment by using
only six textures, fitting together as a cube. Below is an
image showing how six images of a cube map fit together.</P>
<TABLE summary="Reference Cube Map with caption">
<TR>
<TH>Reference Cube Map</TH>
</TR>
<TR>
<TD><IMG src="cubemap-reference.gif" alt=
"Reference Cube Map Image"></TD>
</TR>
</TABLE>
<P>The names <B>up</B>, <B>dn</B>, and so forth correspond with
the names of the sky textures used in Anachronox (which are
themselves cube environment maps) which can be found in <B>
/anoxdata/graphics/sky/</B>. The numbers represent the naming
scheme that must be used for the textures before feeding them
into POVray (that is a later step in our process). Here is a
sample view from inside the cube, so you can get an idea of how
the sides fit together:</P>
<TABLE summary="Cube Interior with caption">
<TR>
<TH>Cube Interior</TH>
</TR>
<TR>
<TD><IMG src="cubemap-view.gif" alt="Cube Interior Image">
</TD>
</TR>
</TABLE>
<P>I put underlines on the top and bottom labels so the
orientation isn't confused (if you write "up" upside-down you
get "dn"). This cube map was generated from inside an actual
Anachronox level, specifically, the computer room in <B>map
hive</B>. If you go into this room in Anachronox, you should
see the reflective entity that is using the Anachronox
environment map generated from this cube map.</P>
<H4>Generating Cube Maps with 3D Programs</H4>
<P>Any 3D rendering package, just as Lightwave, Maya, or
Bryce3D, can be used to create complex and beautiful
environment maps. You can use these paint programs to generate
cube maps by rendering your scene six times at right angles,
making sure that the horizontal and vertical FOV are both
exactly 90&deg;. You should consult the documentation for your
paint program to learn how to do this.</P>
<H4>Generating Cube Maps with Anachronox</H4>
<P>The process is relatively straightforward and more useful
for generating contextual environment maps than using an
external 3D program. First, find a computer where you can run
Anachronox at 1280x960 or higher. The environment map will look
much nicer than if you do this method running only at 640x480. Once Anox
is running, execute the following commands:</P>
<PRE>
exec q2.cfg
forcecursormode 1
r_novis 1
r_nocull 1
debug 0
bind p "paused 666"
bind o "paused 0"
bind f12 "r_envshot 1"
</PRE>
<P>You can bind the commands to anything, I just used these
keys because they are convenient for my config. Here is an
explanation of what these commands do:</P>
<UL>
<LI>Execing q2.cfg turns off boots.</LI>
<LI>Cursor mode 1 means no cursor display.</LI>
<LI>r_novis and r_nocull makes sure that all poly are
always drawn.</LI>
<LI>Debug to zero turns off all the extra crap appearing on
the screen in development Anachronox builds.</LI>
<LI><B>&lt;P&gt;</B> will cause the game to pause without
displaying the PAUSED graphic...</LI>
<LI><B>&lt;O&gt;</B> unpauses it.</LI>
<LI><B>&lt;F12&gt;</B> will cause Anachronox to take six
strange screenshots.</LI>
</UL>
<P>So, run around until you find the place where you will want
to place your reflective entity. If you are going to put
several entities in the same area, you can just find some
pretty spot in the middle to generate your environmental
screenshots instead of making several separate ones; this saves
texture memory and people can't really tell the difference.</P>
<P>After you've found a pretty spot, press <B>&lt;P&gt;</B> to
pause the game, then press <B>&lt;F12&gt;</B>. The direction
you are facing doesn't matter, just your position. The view
becomes squished-looking and the camera should spin around,
taking six screenshots as it goes. The view distortion is
caused by the camera forcing the vertial FOV and the horizontal
FOV to BOTH be exactly 90&deg;; usually, the ratio of the
vertial and horizontal FOV matches your screen aspect ratio.
Once it is finished, bring down the console and write down the
screenshot filenames that it generated. Order matters. You may
have ended up with something like this in the console:</P>
<PRE>
Wrote v:\anachronox/anoxdata/screenshots/nox00195.tga
Wrote v:\anachronox/anoxdata/screenshots/nox00196.tga
Wrote v:\anachronox/anoxdata/screenshots/nox00197.tga
Wrote v:\anachronox/anoxdata/screenshots/nox00198.tga
Wrote v:\anachronox/anoxdata/screenshots/nox00199.tga
Wrote v:\anachronox/anoxdata/screenshots/nox00200.tga
]
</PRE>
<P>That's it! Now you have the six images needed for a cube
environment map. First, rename the files as follows:</P>
<PRE>
ren nox00195.tga env1.tga
ren nox00196.tga env2.tga
ren nox00197.tga env3.tga
ren nox00198.tga env4.tga
ren nox00199.tga env5.tga
ren nox00200.tga env6.tga
</PRE>
<H4>3D Screenshot Viewer</H4>
<P>You can distribute these six files and have other people be
able to view your cool 3D Anachronox screenshot. Resize all six
images to 512x512 using your favorite paint program, save them
in color JPEG format, and then <B>enview</B>, the Anachronox 3D
screenshot viewer, can display them.</P>
<H4>Anachronox Sky Box</H4>
<P>You can use these six textures as a sky box in an Anachronox
level. Resize all six images to 256x256 using your favorite
paint program, save them in 24-bit TGA format, and then rename
using the sky-box naming scheme. For example, if you want to
create the Anachronox sky box named "skuld" you should do the
following (using our examples files):</P>
<PRE>
ren env1.tga skuldrt.tga
ren env2.tga skuldbk.tga
ren env3.tga skuldlf.tga
ren env4.tga skuldft.tga
ren env5.tga skulddn.tga
ren env6.tga skuldup.tga
</PRE>
<P>If you forget what order "rt", "bk", etc. should be in, just
reference the image near the top of this page.</P>
<H4>Parabolic Environment Mapping</H4>
<P>This is the whole reason you're reading this doc, anyways,
right? Okay, let's go on...</P>
<P><A href="step2-povray.html">[Next - Step 2: POVray]</A></P>
</BODY>
</HTML>