aboutsummaryrefslogtreecommitdiff
path: root/cvs/cvsweb.cgi/code/nel/doc/3d/3d_data.dxt?rev=1.1&content-type=text/x-cvsweb-markup&sortby=rev/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'cvs/cvsweb.cgi/code/nel/doc/3d/3d_data.dxt?rev=1.1&content-type=text/x-cvsweb-markup&sortby=rev/index.html')
-rw-r--r--cvs/cvsweb.cgi/code/nel/doc/3d/3d_data.dxt?rev=1.1&content-type=text/x-cvsweb-markup&sortby=rev/index.html170
1 files changed, 170 insertions, 0 deletions
diff --git a/cvs/cvsweb.cgi/code/nel/doc/3d/3d_data.dxt?rev=1.1&content-type=text/x-cvsweb-markup&sortby=rev/index.html b/cvs/cvsweb.cgi/code/nel/doc/3d/3d_data.dxt?rev=1.1&content-type=text/x-cvsweb-markup&sortby=rev/index.html
new file mode 100644
index 00000000..7bd04e5d
--- /dev/null
+++ b/cvs/cvsweb.cgi/code/nel/doc/3d/3d_data.dxt?rev=1.1&content-type=text/x-cvsweb-markup&sortby=rev/index.html
@@ -0,0 +1,170 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
+<HEAD><style> A { color:black }</style>
+<!-- hennerik CVSweb $Revision: 1.93 $ -->
+<TITLE>code/nel/doc/3d/3d_data.dxt - view - 1.1</TITLE></HEAD>
+<BODY BGCOLOR="#eeeeee">
+<table width="100%" border=0 cellspacing=0 cellpadding=1 bgcolor="#aaaaaa"><tr valign=bottom><td><a href="3d_data.dxt?sortby=rev"><IMG SRC="http://www.nevrax.org/inc/img/picto-up.gif" ALT="[BACK]" BORDER="0" WIDTH="14" HEIGHT="13"></a> <b>Return to <A HREF="3d_data.dxt?sortby=rev">3d_data.dxt</A>
+ CVS log</b> <IMG SRC="http://www.nevrax.org/inc/img/picto-news.gif" ALT="[TXT]" BORDER="0" WIDTH="13" HEIGHT="15"></td><td align=right><IMG SRC="http://www.nevrax.org/inc/img/picto-dir.gif" ALT="[DIR]" BORDER="0" WIDTH="15" HEIGHT="13"> <b>Up to <a href="/cvs/cvsweb.cgi/?sortby=rev">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=rev">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=rev">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/doc/?sortby=rev">doc</a> / <a href="/cvs/cvsweb.cgi/code/nel/doc/3d/?sortby=rev">3d</a></b></td></tr></table><HR noshade><table width="100%"><tr><td bgcolor="#ffffff">File: <a href="/cvs/cvsweb.cgi/?sortby=rev">Nevrax</a> / <a href="/cvs/cvsweb.cgi/code/?sortby=rev">code</a> / <a href="/cvs/cvsweb.cgi/code/nel/?sortby=rev">nel</a> / <a href="/cvs/cvsweb.cgi/code/nel/doc/?sortby=rev">doc</a> / <a href="/cvs/cvsweb.cgi/code/nel/doc/3d/?sortby=rev">3d</a> / <a href="/cvs/cvsweb.cgi/code/nel/doc/3d/3d_data.dxt?sortby=rev">3d_data.dxt</a>&nbsp;(<A HREF="/cvs/cvsweb.cgi/~checkout~/code/nel/doc/3d/3d_data.dxt?rev=1.1&amp;sortby=rev" target="cvs_checkout" onClick="window.open('/cvs/cvsweb.cgi/~checkout~/code/nel/doc/3d/3d_data.dxt?rev=1.1','cvs_checkout','resizeable,scrollbars');"><b>download</b></A>)<BR>
+Revision <B>1.1</B>, <i>Tue Jan 9 13:19:38 2001 UTC</i> (18 months, 2 weeks ago) by <i>corvazier</i>
+<BR>Branch: <b>MAIN</b>
+<BR>CVS Tags: <b>proto_0_2, proto_0_1, nel_0_4, nel_0_3, nel_0_2, georges_v2, demo_0_1, HEAD</b><PRE>
+no message
+</PRE>
+</td></tr></table><HR noshade><PRE>
+/**
+\page 3d_data_howto How to deal with 3d data
+
+\author Cyril Corvazier
+
+\subsection 3d_data_overview Overall view
+
+3d data files in NeL are managed in a specific way.
+
+NeL doesn't import proprietary 3d file format like .3ds. NeL only deal with NeL binary files.
+NeL doesn't describe the NeL binary file format, it gives interface to import and export it.
+
+Those files are generated by serializing some classes. Building those data is easy.
+With the serial's version system, data can change and stay compatible with the futur version
+of NeL.
+
+To get some NeL binary 3d files, you can:
+
+- Get some NeL files from your friend or from Nevrax. :)
+- Export some data with a specific plugin exporting NeL files.
+- Write a file converter from your format to NeL format.
+- Write a plugin for your 3d editor.
+
+\subsection mesh Build a simple mesh
+
+Ok, First you will need to build a simple mesh. A mesh is a class that handle one 3d object.
+It contains the vertices, the primitives, and pointers on materials. The mesh class is NL3D::CMesh.
+
+The class NL3D::CMesh::CMeshBuild is used to build this mesh. Just fill it with appropriate values:
+
+- VertexFlags will received flags that describe vertices format like in CVertexBuffer. Following flags can be used
+ &nbsp; &nbsp; &nbsp; &nbsp;IDRV_VF_XYZ (x, y, z local value, must be present), IDRV_VF_NORMAL (normal, should be present for lighted material),
+ &nbsp; &nbsp; &nbsp; &nbsp;IDRV_VF_COLOR (vertex diffuse color), IDRV_VF_SPECULAR (vertex specular color), IDRV_VF_UV[IDRV_VF_MAXSTAGES]
+ &nbsp; &nbsp; &nbsp; &nbsp;(flags for each UV channel used, max IDRV_VF_MAXSTAGES UV channels), IDRV_VF_W[IDRV_VF_MAXW] (flags for each
+ &nbsp; &nbsp; &nbsp; &nbsp;weighting channel used). Some exemple:
+ &nbsp; &nbsp; &nbsp; &nbsp;- IDRV_VF_XYZ|IDRV_VF_NORMAL, simple lighted vertex
+ &nbsp; &nbsp; &nbsp; &nbsp;- IDRV_VF_XYZ|IDRV_VF_NORMAL|IDRV_VF_UV[0]|IDRV_VF_UV[1], simple lighted vertex with two mapping channels
+ &nbsp; &nbsp; &nbsp; &nbsp;- IDRV_VF_XYZ|IDRV_VF_NORMAL|IDRV_VF_W[0]|IDRV_VF_W[1]|IDRV_VF_W[2]|IDRV_VF_W[3], simple lighted vertex with 4 weights for skinning matrix.
+- Materials is an array of materials. Resize it and fill it with your materials data. See material_howto for more information.
+- Vertices is the vertex array. Only local x, y and z coordinates are stored here. Resize it and fill it.
+- Faces is the triangle array. Each triangle is composed by 3 NL3D::CMesh::CCorner and a material Id. The corner must be fill like this:
+ &nbsp; &nbsp; &nbsp; &nbsp;- Vertex must receive the vertex id used at this corner.
+ &nbsp; &nbsp; &nbsp; &nbsp;- Normal must receive the local normalized normal at this corner.
+ &nbsp; &nbsp; &nbsp; &nbsp;- Uvs must receive the UV values for each mapping channels defined in VertexFlags.
+ &nbsp; &nbsp; &nbsp; &nbsp;- Color must receive the diffuse color if IDRV_VF_COLOR is defined in VertexFlags.
+ &nbsp; &nbsp; &nbsp; &nbsp;- Specular must receive the specular color if IDRV_VF_COLOR is defined in VertexFlags.
+ &nbsp; &nbsp; &nbsp; &nbsp;- Weights must receive the weight values for each weighting channels defined in VertexFlags.
+
+\code
+ &nbsp; &nbsp; &nbsp; &nbsp;// Let's assume that those namespaces are used: NL3D, NLMISC
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// My building struct
+ &nbsp; &nbsp; &nbsp; &nbsp;CMesh::CMeshBuild buildStruct;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Filling the struct..
+ &nbsp; &nbsp; &nbsp; &nbsp;...
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Create a CMesh
+ &nbsp; &nbsp; &nbsp; &nbsp;CMesh myMesh;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Build the mesh
+ &nbsp; &nbsp; &nbsp; &nbsp;myMesh.build (buildStruct);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Create a mesh for export
+ &nbsp; &nbsp; &nbsp; &nbsp;CShapeStream streamableMesh (&amp;myMesh)
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Ok, ready to export
+
+\endcode
+
+You have normals, colors and uvs per vertex per triangle.
+Once you have filled all those values, call NL3D::CMesh::build() on the mesh.
+NL3D::CMesh::build() will optimize your corners by merging the same one.
+
+To simplify the serialization of a shape, use the class NL3D::CShapeStream construct with your shape pointer and serialize it.
+This class will serial a valid .shape file with header and polymorphic serialization of the shape, materials and textures.
+Here is the code of NL3D::CShapeStream::serial():
+
+\code
+void CShapeStream::serial(NLMISC::IStream &amp;f) throw(NLMISC::EStream)
+{
+ &nbsp; &nbsp; &nbsp; &nbsp;// First, serial an header or checking if it is correct
+ &nbsp; &nbsp; &nbsp; &nbsp;f.serialCheck ((uint32)'PAHS');
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Then, serial the shape
+ &nbsp; &nbsp; &nbsp; &nbsp;f.serialPolyPtr (_Shape);
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Ok, it's done
+}
+\endcode
+
+Your mesh is ready to export.
+
+\subsection zone Build a landscape zone
+
+It's coming..
+
+\subsection serial Serial a NeL class
+
+Now you have build your data, you must know how to serial a NeL class. Let's assume that you want to read a landscape zone from a file:
+
+\code
+ &nbsp; &nbsp; &nbsp; &nbsp;// Let's assume that those namespaces are used: NL3D, NLMISC
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Your object to load into
+ &nbsp; &nbsp; &nbsp; &nbsp;CZone &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;zone;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Create an input file stream
+ &nbsp; &nbsp; &nbsp; &nbsp;CIFile &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fileIn;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Open your file for writing
+ &nbsp; &nbsp; &nbsp; &nbsp;if (fileIn.open (&quot;myZoneFile.zone&quot;))
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Catch some error
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Read your object
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;zone.serial (fileIn);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (CException&amp; except)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Handle errors. File truncated, bad version, etc...
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+\endcode
+
+Then how to write a shape in a file ? Easy too..
+
+\code
+ &nbsp; &nbsp; &nbsp; &nbsp;// Let's assume that those namespaces are used: NL3D, NLMISC
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Your shape to write
+ &nbsp; &nbsp; &nbsp; &nbsp;CShapeStream &nbsp; &nbsp; &nbsp; &nbsp;shape;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Create an output file stream
+ &nbsp; &nbsp; &nbsp; &nbsp;COFile &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fileOut;
+
+ &nbsp; &nbsp; &nbsp; &nbsp;// Open your file for writing
+ &nbsp; &nbsp; &nbsp; &nbsp;if (fileOut.open (&quot;myExportedFile.shape&quot;))
+ &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Catch some error
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;try
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Write your object
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;shape.serial (fileOut);
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;catch (CException&amp; except)
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;{
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Handle error. Disk full, etc...
+ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}
+ &nbsp; &nbsp; &nbsp; &nbsp;}
+\endcode
+
+
+
+*/
+</PRE> \ No newline at end of file