ok, done. Thanks A LOT Spike! Your advice really helped me! So, again, a little tutorial is a must!
Environment models at runtime with nice collisions
1) Model your object, in this case an arc, in your favourite app - I used Blender but any 3d app that support natively or via plugin WaveFront's OBJ export should work
I saved it in models/test/arc.obj
Note: In Blender, it's better, to use FTEQW's orientation, to model the object using side view as front view and front view as side view so your front is game front
2) Export the object like image - remember orientation
3)create in common.shader the transparent entry (it will be used as collision hull)
Code: Select all
textures/common/transparent
{
surfaceparm nodraw2
surfaceparm nolightmap
{
map textures/common/transparent.tga
alphaFunc GE128
depthWrite
rgbGen vertex
}
}
For transparent.tga just create a 32x32 (or whatever) black image with a black alpha channel and exported as 32 bit .tga
my arc model has this shader (this is just an example, for the misc_model you can, of course use the shader you want)
Code: Select all
textures/test/arc
{
nomipmaps
{
map $nearest:textures/test/arc.tga
rgbGen entity
alphaGen entity
}
}
4)In Radiant (I chose NetRadiant because GTKRadiant seems to have problem importing OBJ models) create a misc_model and choose models/test/arc.obj (or whatever / wherever you saved your obj )
5)Now surround your arc misc_model with thin boxes with transparent shader applied to it. I used 1-unit wide boxes because we only need their collision
6) Compile. I used q3map2 with only -bsp pass, without nor -vis neither -light
<build name="q3map 32bit with collisions only BSP">
<command>[q3map2] -custinfoparms -meta -v "[MapFile]"</command>
</build>
With my version of q3map2 it yells a "MAP LEAKED" warning but it compiles fine anyway. Don't know if yours will compile too. Let me know if it doesn't.
7) add in quakeC just add this constant string and this function:
Code: Select all
string MAPMODEL1 = "maps/miscmodel2.bsp";
void SpawnArcBSP(entity e,vector where)
{
e = spawn();
e.classname="scene_mesh";
e.solid = SOLID_BSP;
precache_model(MAPMODEL1);
setmodel(e,MAPMODEL1);
setsize (e, [-8, -8 ,-8], [8, 8, 8]);//fake size just to display the model, otherwise collisions are present but no model is displayed!
setorigin(e,where);
}
A shot in game
Now you can use that function in worldspawn() function to spawn that at level loading or using it via other code or via impulse or whatever
I didn't test it too much tonight so I don't know how constant creation / deletion of BSP models can affect framerate / stability but I'll make more experiments and I'll let you know
Done! Now you can have complex environment models at runtime with good collisions!
Thanks again Spike!!