Hiya all!
Ive got a WIP snippet of a function to generate a BMAP 'preview' of an entity by filename.
Sometimes its works and sometimes it doesent.
By "works" I mean it creates a snapshot from a temporary view.
And by 'doesnt work' I mean it renders to the BMAP OK, but the entity isnt visible...
(or in the viewable area at least)
And by sometimes I mean ... sometimes...
I cant see any pattern. Run the script, hit the spacebar and ...nothi8ng
Wait a few seconds, hit it again, and BANG! It works.
But sometimes it will never work, sometimes it works first try.
There is nothing special about the model, have tried with various ones.
All behave the same way...
Here is the complete script, just give it your own model in the 'test_1' function...
(model should be smaller that 100 quants diameter to fit)
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "Models\Mapobjects";
//
//
//=======================================================================================
//
function SnapShot_Event() { if(me!=render_view.genius) return(1); }
//
MATERIAL *SnapShot_mat = { event=SnapShot_Event; flags=ENABLE_TREE; }
//
//=======================================================================================
void preview_create(STRING* ent_name, BMAP* targ_bmap)
{ if((!ent_name)||(!targ_bmap)) return; //invalid capture parameter/s.
ENTITY* targ_ent = NULL; var old_mode=preload_mode; preload_mode = 3+4+8;
targ_ent = ent_create(ent_name, nullvector, NULL);
preload_mode=old_mode; if(targ_ent==NULL) return; //invalid entity name
vec_set(targ_ent.pan,vector(35,10,0)); vec_set(targ_ent.x,vector(-999,-999,-999));
//------------------------------------------------------------------------------------
VIEW *view = view_create(1000); view.genius = targ_ent; view.bmap = targ_bmap;
view.size_x = targ_bmap.width; view.size_y = targ_bmap.height;
c_updatehull(targ_ent, targ_ent.frame); VECTOR box;
vec_set(view.x, targ_ent.x); view.x -= 110;
vec_to_angle(view.pan,vec_diff(0,targ_ent.x,view.x)); view.material=SnapShot_mat;
//------------------------------------------------------------------------------------
set(view, SHOW); wait(1); ptr_remove(view);
ent_purge(targ_ent); ent_remove(targ_ent); beep(); }
//=======================================================================================
//
//
BMAP* targ_map;
//
void test_1() { preview_create("stair.mdl", targ_map); }
//
void main()
{
wait(1); level_load(NULL); wait(1); diag("\n\n\n");
//------------------------------------------------------------------------------------
//
targ_map = bmap_createblack(256,256,32); bmap_fill(targ_map, COLOR_BLACK, 100);
on_space = test_1;
//
while(1)
{
DEBUG_BMAP(targ_map, 10, 2);
wait(1);
}
}
Any ideas anyone???