File: cs_122.html

package info (click to toggle)
crystalspace 0.94-20020412-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 62,276 kB
  • ctags: 52,843
  • sloc: cpp: 274,783; ansic: 6,608; perl: 6,276; objc: 3,952; asm: 2,942; python: 2,354; php: 542; pascal: 530; sh: 430; makefile: 370; awk: 193
file content (125 lines) | stat: -rw-r--r-- 4,488 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- Created by texi2html 1.64 -->
<!-- 
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Olaf Bachmann <obachman@mathematik.uni-kl.de>
Send bugs and suggestions to <texi2html@mathematik.uni-kl.de>
 
-->
<HTML>
<HEAD>
<TITLE>Crystal Space: HOWTO Level Loading</TITLE>

<META NAME="description" CONTENT="Crystal Space: HOWTO Level Loading">
<META NAME="keywords" CONTENT="Crystal Space: HOWTO Level Loading">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META NAME="Generator" CONTENT="texi2html 1.64">

</HEAD>

<BODY LANG="" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080" ALINK="#FF0000">

<A NAME="SEC250"></A>
<TABLE CELLPADDING=1 CELLSPACING=1 BORDER=0>
<TR><TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_121.html#SEC247"> &lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_123.html#SEC254"> &gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_108.html#SEC209"> &lt;&lt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_116.html#SEC225"> Up </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_128.html#SEC290"> &gt;&gt; </A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT"> &nbsp; <TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="index.html#SEC_Top">Top</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_toc.html#SEC_Contents">Contents</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_285.html#SEC711">Index</A>]</TD>
<TD VALIGN="MIDDLE" ALIGN="LEFT">[<A HREF="cs_abt.html#SEC_About"> ? </A>]</TD>
</TR></TABLE>
<HR SIZE=1>
<H3> 5.8.6 Loading a Level </H3>
<!--docid::SEC250::-->
<P>

This section describes how you can load a level in your game.
</P><P>

<A NAME="SEC251"></A>
<H4> Getting the Level Loader Plugin </H4>
<!--docid::SEC251::-->
<P>

To load a level you need the level loader plugin. There are two
ways to make sure you have this plugin in your application. You can put
a line in your config file like this:
</P><P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>System.Plugins.iLoader = crystalspace.level.loader
</pre></td></tr></table></P><P>

Or you can add the following line to the call to
<CODE>csInitializer::RequestPlugins()</CODE> in your <CODE>main()</CODE> function:
</P><P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>CS_REQUEST_LEVELLOADER,
</pre></td></tr></table></P><P>

To finally be able to use the level loader in your application you
need to do:
</P><P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>iLoader* level_loader = CS_QUERY_REGISTRY (object_reg, iLoader);
</pre></td></tr></table></P><P>

When you don't need it anymore you must call <CODE>level_loader-&#62;DecRef ()</CODE>.
</P><P>

<A NAME="SEC252"></A>
<H4> Loading a Map </H4>
<!--docid::SEC252::-->
<P>

Loading a map is simple. You just do:
</P><P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>VFS-&#62;ChDir ("/lev/mymap");
level_loader-&#62;LoadMapFile ("world");
engine-&#62;Prepare ();
</pre></td></tr></table></P><P>

This will first set the current directory to the right VFS dir
(see section <A HREF="cs_161.html#SEC340">7.2 Virtual File System (VFS)</A>) and then it will load the map file which is called 'world' (this
is not a requirement).
</P><P>

Note that this will clear all other geometry that might have been
loaded in the engine before. If you don't want that then you need to
set the second parameter of <CODE>LoadMapFile</CODE> to <CODE>false</CODE>.
</P><P>

The line <CODE>engine-&#62;Prepare()</CODE> will make sure that everything that
is loaded is correctly set up (i.e. materials and texture will be registered,
lightmaps will be loaded from the cache, ...).
</P><P>

<A NAME="SEC253"></A>
<H4> Include Files     </H4>
<!--docid::SEC253::-->
<P>

The include files useful for this section are:
</P><P>

<TABLE><tr><td>&nbsp;</td><td class=example><pre>#include "isys/vfs.h"
#include "imap/parser.h"
#include "iengine/engine.h"
</pre></td></tr></table><A NAME="HOWTO Pixmaps"></A>
<HR SIZE=1>
<BR>  
<FONT SIZE="-1">
This document was generated

using <A HREF="http://www.mathematik.uni-kl.de/~obachman/Texi2html
"><I>texi2html</I></A>

</BODY>
</HTML>