View flags get applied to main camera

Posted By: Dooley

View flags get applied to main camera - 04/02/18 20:15

I have successfully implemented my top down mapping camera, however, I am left with some odd errors.

On some levels, it seems like the flags I have set for my second VIEW bitmap get applied to the main camera view.

On the map, I set it to NOSHADOW and NOPARTICLE, and indeed on some levels, in the main camera, particles that should be there do not show, and shadows do not appear up to a certain distance (roughly the distance that would be covered by the second VIEW's camera).

This does not happen on every level, just some. Sometimes if I revisit that level, it will behave properly.

Here is my code for the actual entity on which the secondary view is projected.

Quote:
action scan_screen()
{
set(my,PASSABLE | UNLIT | LIGHT);
my.material = mtl_scanner;
ent_screen = my;

while(scan_view == NULL)
{
wait(1);
}

sys_marker("SC2");
if(scan_view != NULL)
{
testing_var -= 10000;
scan_view.bmap = scan_bmp;
scan_view.layer = -1;
scan_view.pos_x = 0;
scan_view.pos_y = 0;
scan_view.size_x = 256;
scan_view.size_y = 256;
scan_view.arc = 120;
scan_view.aspect = 1;
scan_view.ambient = 100;
scan_view.clip_near = 0;
scan_view.clip_far = 12000;
set(scan_view,SHOW|NOPARTICLE|NOSHADOW|UNTOUCHABLE|ISOMETRIC);
}

while(player_started != 1)
{
wait(1);
}

scan_bmp = bmap_for_entity(my,1);

sys_marker("SC5");
while(level_loading == 0 && planet_character != NULL)
{
vec_set(my.x,ent_scanner.x);
vec_set(my.pan,ent_scanner.pan);
vec_set(scan_view.x,vector(planet_character.x,planet_character.y,planet_character.z + 1200)); // set the view positions here
vec_set(scan_view.pan,vector(planet_character.pan,-90,0)); // set the view angles here

scan_view.bmap = scan_bmp;

wait(1);
}

// //REMOVE THE SCANNER AND ALL REFERENCES TO IT
sys_marker("SCC");
reset(scan_view,SHOW);
bmap_purge(scan_bmp);
ptr_remove(scan_view);
ptr_remove(scan_bmp);
ent_purge(me);
ent_remove(me);
ent_remove(ent_scanner);
scan_bmp = NULL;
scan_view = NULL;
ent_scanner = NULL;
ent_screen = NULL;

}
Posted By: Dooley

Re: View flags get applied to main camera - 04/02/18 21:57

I have this bad habit of answering my own questions. I think I may have solved this by adding
Quote:
bmap_zbuffer(scan_bmp);
just after setting up the scan_view VIEW.

My biggest question about using bmap_zbuffer is whether this needs to be called for each new level, or just once in the beginning of the game?

I don't fully understand how this works. But so far I have not seen the errors I mentioned. I am reading up in the manual, but a lot of the language about "views" "render targets" is hard to understand.
Posted By: txesmi

Re: View flags get applied to main camera - 04/03/18 12:27

As far as I understand, bmap_zbuffer only resizes the engine internal buffers, so it has to be called only once.

Do you wait a frame between setting the variable that breaks the last loop and the new level load? If not, the last code block will never be executed since level_load deletes the entity from the scene and the action from the scheduler.

You have to set scan_view.bmap to NULL. Otherway it points to a removed bmap.

Both problems could be the cause of that ZTARG error you wrote about.

Morover, you are deleting scan_bmp and it is an entity skin. You should not do such a thing. It will be removed with the entity.
Posted By: Dooley

Re: View flags get applied to main camera - 04/03/18 20:58

Thanks! I will try that.
© 2024 lite-C Forums