Tutorial:
Blender 3D model to Crystal Space
3D sprite
(Tutorial created at Linux OS)
Important: CrystalSpace X,Y,Z == Blender3D -Y,Z,X
This means that if you plan to creating an arrow,
make sure its head is
at Blender3D 'X' axis so at CrystalSpace
it will load at 'Z' axis that is the FORWARD
vector for all calculations
csVector3(0,0,1)
STEPS (exporting 3d model: "Blender 3D" to "Quake MD2" to "Crystal
Space SPR"):
ISNTALL: blender3d 2.3.5b, phython 2.3.3, export-md2-0.14.py,
import-md2-0.14.py, Crystal Space 0.98
Meanings at Blender 3D: [window type] {mode combobox at 3d view
window type}
1 - (this substep just make it easy to set UV calculation at
image file)
[user preferences] at
combobox Datablock, select '1 - animation'
then 'ADD NEW', rename the
new one added to something like (3d/ImgUV/Btn),
set the top right to
[UV/image editor] (topLeft [3d view], botton [buttons])
[3d view] create your model
Linux terminal: put all textures to this
model in one file with the command ex.
"convert -append img1.jpg
img2.jpg modelname.jpg"
you should
create a script (modelname.tex.sh) with this command
see: `info
convert` for supported image file types (info ImageMagick)
don't change images order
later as UV map depends on it!
you shouldn't also remove
files from list as a lot of trouble setting UV calc again,
but you can add (ex.
img3.jpg before modelname.jpg) texture files later to this file :)
(*)[3d view]{UV face select} Ctrl+(right mouse click) on
mesh to change to that mesh object
[3d view] press A to select all faces
[Button] menu: panels/editing; at 'UV
calculation' choose one method (may be 'Bounds')
[UV/Image editor] adjust the result of
'Bounds' to the texture of your choice; 2 tips here:
press B to select all
vertexes at a same point;
to move them all toguether
press G instead of using 'right mouse click'
Repeat substeps from (*) to all meshes.
obs.: I had problems with
plane mesh showing texture in only one side after
importing the
.md2 file. I solved it by:
'duplicate' the plane;
Rotate the new one by 180 degress Z axis (it was a regular triangle,
you may have more trouble with non regular meshes);
Then
'join objects'(meshes) to join these 2 triangles (2 plane meshes).
The feature [3d
view]{UV face select} then
[Buttons] menu: panel/editing/texture face/twoside
does
not appear to work at MD2 exporter (yet :)
[3d view]{object mode}: (select all)
menu: object/clear apply/apply size rotation
[user preferences] menu: file/save
(modelname.blend)
2 - open file.blend (dont save this after modifing)
[3d view]{object mode} (select one of
the object meshes)
[3d view]{object mode} (select all)
menu: object/join objects/join selected meshes
press TAB
[3d view]{edit mode} (select
all) menu: mesh/faces/convert quads to triangles
[3d view]{UV face select} (select all)
press TAB
[3d view]{edit mode} menu:
mesh/faces/convert quads to triangles
Important: to make things a lot easyer
to load a reliable 3d sprite at your Crystal Space 3d project:
find the 3d center of the
final joined mesh boundary box by moving the mesh
the way this
center stay at 0,0,0 global coordinates
[3d view]{object mode}select
the final joined mesh
[3d view]{edit mode}set the
'median X,Y,Z' the way the mesh dont move but
this median
point moves to 0,0,0
now at your Crystal Space
project you will be able to load the 3d sprite
and easily
AttachColliderBox() based on 'GetWorldBoundingBox() Max-Min'
without any
other complex setup :)
[user preferences]menu: file/export/MD2
If you are creating a .md2
with only one frame see FrameListFile session below
Click Export
This message
should not appear: "Model not made entirely out of triangles?"
if
it shows up, follow step by step again.
To avoid replacing modelname.blend just
do: [user preferences]menu: file/new
To test at Blender 3D the .md2 file,
before importing it (+ .jpg texture file)
make sure the Cursor is at
0,0,0: [3d view] menu: view properties/3d cursor
this way the md2 model will
load at the same place you exported it.
3 - Linux terminal:
commands:
$CRYSTAL/bin/md22spr -s 1.0
modelname.md2 modelname
mv modelname.spr modelname.xml
rm modelname.md2
edit modelname.xml at 'mc' and change
"<material>skin" to "<material>modelname"
add both modelname.xml and modelname.jpg
files to your "Crystal Space" project, may be data.zip file
make sure you load
modelname.jpg to a texture wrapper named only "modelname" to match
"<material>"
FrameListFile (to only one frame):
create a file like MD2FrameList.txt with only these 2 lines (no
identation!)
# MD2 Frame Name List
stop 0
Files Created:
MD2FrameList.txt
modelname.tex.sh
modelname.xml
modelname.jpg
Documentation provided with absolutely NO WARRANTIES, it
worked for me and MAY
work for you.