1 registered members (AndrewAMD),
14,661
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
WTF mate! Why does it render and sometimes not?
#389428
12/14/11 08:59
12/14/11 08:59
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
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???
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: WTF mate! Why does it render and sometimes not?
[Re: Lukas]
#389471
12/14/11 18:09
12/14/11 18:09
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
function SnapShot_Event()
{
if(render_view == camera) return(1);
return 0;
}
//
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+random(300),10,0));
vec_set(targ_ent.x,vector(-0,-0,-0));
//------------------------------------------------------------------------------------
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_diff(box,targ_ent.x,view.x);
vec_to_angle(view.pan,box);
targ_ent.material=SnapShot_mat;
//------------------------------------------------------------------------------------
set(view, SHOW | NOENT);
wait(1);
ptr_remove(view);
ent_purge(targ_ent);
ent_remove(targ_ent);
beep();
}
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: WTF mate! Why does it render and sometimes not?
[Re: Superku]
#389473
12/14/11 18:31
12/14/11 18:31
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Thanks Lukas, thats was it. Well, that AND setting the view flag back to ENABLE_RENDER instead of ENABLE_TREE where I had put it during testin.
And thanks Superku, or bringing the ONOENT flag to my attention, useful. But I see other changes on there that make no sense to me. Can you explain the reasoning behind them please?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: WTF mate! Why does it render and sometimes not?
[Re: EvilSOB]
#389474
12/14/11 18:42
12/14/11 18:42
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Ah yes there are some other changes that don't have any effect on your problem, important are the following things:
// event for disabled camera rendering function SnapShot_Event() { if(render_view == camera) return 1; return 0; } ... targ_ent.material=SnapShot_mat;
// draw only targ_ent in "view" view.genius = targ_ent; set(view, SHOW | NOENT);
Btw. is this vec_diff(0,targ_ent.x,view.x); // returns the vector pointer valid, do all appropriate vec commands allow this?
Last edited by Superku; 12/14/11 18:43.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual Check out my new game: Pogostuck: Rage With Your Friends
|
|
|
Re: WTF mate! Why does it render and sometimes not?
[Re: Superku]
#389475
12/14/11 19:28
12/14/11 19:28
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Aha, now I see.
Thanks muchly dude!
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: WTF mate! Why does it render and sometimes not?
[Re: EvilSOB]
#389506
12/15/11 09:02
12/15/11 09:02
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Firstly, I missed Superku's question regarding vector functions. "do all appropriate vec commands allow this?" Anwser:: some do, some dont. Its worth testing them yourself because some that do return the result vector ARENT shown as doing so be the manual... Bloody 'undocumented features' ...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: WTF mate! Why does it render and sometimes not?
[Re: EvilSOB]
#389508
12/15/11 09:31
12/15/11 09:31
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Back to the thread..... Its all gone up in smoke .... again .... Below you will find two scripts. The first is the 'entire' script for testing. It is utilising the SUPPOSEDLY fixed version of my original post. The second script is just the active portion of it that is utilising my version of Superku's solution. Both work fine as they stand. !! BUT !! I need to be able to turn the NOSKY flag on for that view/function. AND still have the screen-buffer (and z-buffer?) being cleared. I think! Reason being is that there is a sky-entity (ent_createlayer) that must be active in the camera view, but hidden in mine. AND the renderings of these previews want to be transparent where the background is showing through. Ive been d**king around for hours now, and just cant find a way. BUT I am a mere noob when it comes to handling views and view-materials... Also bear in mind, IN CASE it makes a difference, that there will potentially be up to 20 of these functions active during the same frame, and maybe overlapping. So, heres the scripts... COMPLETE script
#include <acknex.h>
#include <default.c>
#define PRAGMA_PATH "Models\Mapobjects";
#define PRAGMA_PATH "G:\GStudio8\templates\models";
//
//
//=======================================================================================
function SnapShot_Event() { if(me!=render_view.genius) return(1); else return(0); }
MATERIAL *SnapShot_mat = { event=SnapShot_Event; flags=ENABLE_RENDER; }
//=======================================================================================
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); vec_set(view.x, targ_ent.x);
view.x -= vec_dist(targ_ent.min_x, targ_ent.max_x);
vec_to_angle(view.pan,vec_diff(0,targ_ent.x,view.x)); view.material=SnapShot_mat;
//------------------------------------------------------------------------------------
set(view, SHOW | NOENT); wait(1); ptr_remove(view);
//
//** DEBUGGING ONLY *********************************************************************
STRING* tmp = str_create("@testing\\"); str_cat(tmp, str_for_int(0,(long)random(99999)));
str_cat(tmp, ".bmp"); bmap_save(targ_bmap, tmp); str_remove(tmp);
//*****************************************************************************************
//
ent_purge(targ_ent); ent_remove(targ_ent); }
//=======================================================================================
//
//
BMAP* targ_map;
//
void test_1() { preview_create("Stair.mdl", targ_map); }
void test_2() { preview_create("Pyramide.mdl", targ_map); }
void test_3() { preview_create("Flamezylinder2.mdl", targ_map); }
void test_4() { preview_create("Diagonal.mdl", targ_map); }
void test_5() { preview_create("earth.mdl", targ_map); }
void test_many()
{
STRING* filename = str_create("");
TEXT *dir = txt_create(50,1); reset(dir, SHOW);
var i, count = txt_for_dir(dir, "G:\\GStudio8\\templates\\models\\*.mdl");
BMAP** bmaps = (BMAP**)sys_malloc(sizeof(BMAP*)*count);
for(i=0; i<count; i++)
{
bmaps[i] = bmap_createblack(64,64,32);
str_cpy(filename, (dir.pstring)[i]);
preview_create(filename, bmaps[i]);
}
beep();
}
//
void main()
{
wait(1); level_load(NULL); wait(1); diag("\n\n\n");
draw_textmode("Times",0,32,100); warn_level = 3;
on_esc=on_f1=on_f2=on_f3=on_f4=on_f5=on_f6=on_f7=on_f8=on_f9= NULL;
//------------------------------------------------------------------------------------
//
targ_map = bmap_createblack(64,64,32); bmap_fill(targ_map, COLOR_BLACK, 100);
on_f1 = test_1;
on_f2 = test_2;
on_f3 = test_3;
on_f4 = test_4;
on_f5 = test_5;
on_space = test_many;
//
while(!key_esc)
{
DEBUG_BMAP(targ_map, 10, 2);
wait(1);
}
//
//
//
//------------------------------------------------------------------------------------
if(key_shift) exec("notepad.exe", "acklog.txt");
sys_exit(0);
}
"preview_create" snippet with material config
//=========================================================================================
function SnapShot_Event() { if(render_view == camera) return(1); return 0; }
MATERIAL *SnapShot_mat = { event=SnapShot_Event; flags=ENABLE_RENDER; }
//-----------------------------------------------------------------------------------------
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, nullvector);
//--------------------------------------------------------------------------------------
VIEW *view = view_create(1000); view.bmap = targ_bmap; view.genius = targ_ent;
view.size_x = targ_bmap.width; view.size_y = targ_bmap.height;
c_updatehull(targ_ent, targ_ent.frame); vec_set(view.x, targ_ent.x);
view.x -= vec_dist(targ_ent.min_x, targ_ent.max_x);
vec_to_angle(view.pan,vec_diff(0,targ_ent.x,view.x)); targ_ent.material=SnapShot_mat;
//--------------------------------------------------------------------------------------
set(view, SHOW | NOENT); wait(1); ptr_remove(view);
//
//** DEBUGGING ONLY *********************************************************************
STRING* tmp = str_create("@testing\\"); str_cat(tmp, str_for_int(0,(long)random(99999)));
str_cat(tmp, ".bmp"); bmap_save(targ_bmap, tmp); str_remove(tmp);
//*****************************************************************************************
//
ent_purge(targ_ent); ent_remove(targ_ent); }
//=========================================================================================
You will need to reset the PRAGMA_PATH to match your GStudio8 location, and create a folder called "@testing" in the folder where this script is, to capture all the BMAPS Im diagnosing with... Remember, both these scripts work perfectly as they are. Like this it produces the type of output I want (in the @testing folder). To get it to fail, you need to add the NOSKY flag to the "set(view,SHOW|NOENT);" at line 24. F1 -> F5 are one-at-a-time tests, but hitting the space-bar is the REAL test. [EvilSOB looks at you with sad puppydog eyes] 
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: WTF mate! Why does it render and sometimes not?
[Re: Superku]
#389584
12/15/11 23:10
12/15/11 23:10
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
OP
Expert
|
OP
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Simply set the client_id of your sky entity to the camera. Err ... what? I dont understand what you mean by this. Can you please give me an example of what you mean? Lets say that the sky entity is referenced by the global entity pointer ENTITY* sky_ent;Thanks dude...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|