vertical mirror help....

Posted By: Blink

vertical mirror help.... - 07/15/10 21:00

ok guys... i found this script for a vertical mirror. how do i use it? how do you turn this into an action for a entity? i use c-script btw.
Code:
VIEW* mirror = 
{
       layer = 10;
} 

function mirror_startup() 
{ 
       while (!player) {wait (1);}
       camera.portal = mirror; 
       set (mirror, NOSHADOW); // suppress shadows in the mirror 
       set (mirror, NOPARTICLE); // suppress particles in the mirror 
       set (mirror, PORTALCLIP); // clip at portal plane 
       while (1) 
       { 
               proc_kill(4);
               mirror.genius = camera.genius; 
               mirror.aspect = camera.aspect; 
               mirror.arc = -camera.arc; 
               mirror.x = camera.x; 
               mirror.y = camera.portal_y - (abs(camera.portal_y - camera.y)); 
               mirror.z = camera.z; 
               mirror.pan = -camera.pan; 
               mirror.tilt = camera.tilt; 
               mirror.roll = camera.roll; 
               wait(1); 
       } 
}


Posted By: badapple

Re: vertical mirror help.... - 07/16/10 04:58

well its a view entity , so its not for a 3d object in your world at a quick glance it looks like a rear view mirror code for a driving game or something , but im not 100 % sure
Posted By: Blink

Re: vertical mirror help.... - 07/16/10 13:16

i think i copied the wrong code,lol. i guess i don't need a vertical mirror, i just thought it would be cool. Thanks Bad.
Posted By: Blink

Re: vertical mirror help.... - 08/07/10 03:05

can someone give me instructions on how to properly use the mirror function? i have A6:60 pro. i think this is the right code. how do you set up the mirror, which wall, etc?

Code:
//////////////////////////////////
//vertical mirror//////////////
/////////////////////////////
function mfx_mirror();


VIEW view_mirror { layer = -1; };

function mfx_mirror()
{
// do nothing if mirror is already running
	if (view_mirror.visible == on) { return; }

	view_mirror.visible = on;
	view_mirror.noshadow = on;	// suppress shadows in the mirror
	view_mirror.nocull = on;    // view through walls
	 
	view_mirror.portalclip = on; // clip at portal plane
	vec_set(view_mirror.portal_x,vector(0,0,my.z + my.max_z)); // at top entity position
	vec_set(view_mirror.pnormal_x,vector(0,0,1.0)); // horizontal plane
	
	while (view_mirror.visible == on)
	{
		proc_late();	// place it at the end of the function list - the camera must be moved before
		view_mirror.genius = camera.genius;
		view_mirror.aspect = camera.aspect;
		view_mirror.arc    = camera.arc;
		view_mirror.fog_start = camera.fog_start;
		view_mirror.fog_end   = camera.fog_end;
		view_mirror.clip_far  = camera.clip_far * 0.5;
		view_mirror.clip_near = camera.clip_near * 2;
		view_mirror.x 	   = camera.x;
		view_mirror.y 	   = camera.y;
		view_mirror.z 	   = 2*view_mirror.portal_z-camera.z;	// move the camera at its mirror position
		view_mirror.pan    = camera.pan;
		view_mirror.tilt   = -camera.tilt;	// flip the vertical camera angle
		view_mirror.roll   = -camera.roll;
		wait(1);
	}
}
action mirrored 			
{
	mfx_mirror();
}


Posted By: bart_the_13th

Re: vertical mirror help.... - 08/07/10 06:01

Yes, it's an old mirror script.
I made a vertical mirror effect using C-script a while ago(JuOn?). But it's gone along with my old HDD grin.
B2T, to create a mirror effect in C Script, there are some 'rules':
1. The mirror surface must be flagged mirror(of course). And the other surface of the block should be flagged none.
2. The block should be the outer area(doh, how should I describe this). There must not any block or model behind/intersecting the block
3. Creating vertical mirror is a bit tricky since each mirror direction needs different code, which I forgot, sorry :D, but the point is, rather than changing the view_mirror.z, you change, view_mirror.x or view_mirror.y(depends on which direction the mirror is facing). The same applies to view_mirror.pan, tilt and roll
Posted By: Blink

Re: vertical mirror help.... - 08/07/10 06:21

i almost understand. so i can use a simple map entity for that, right? and the code i posted above should work for a6?
Posted By: bart_the_13th

Re: vertical mirror help.... - 08/07/10 06:38

Of course, any simple map should work. For your code above, only floor mirror work, so just mirror flag the floor top surface while other surfaces(for the same block) get none flag.
Posted By: Blink

Re: vertical mirror help.... - 08/07/10 06:55

so, this code wont work for the vertical mirror?
Posted By: Nidhogg

Re: vertical mirror help.... - 08/07/10 07:23

I done something like this when I first started with A6 and from memory I think what I did was play around with tilt and either x or y eg:" + instead of -"
but I think you get the idea laugh .

Try that anyway and see how you go, It may help you to solve your problem if anything.
Posted By: Blink

Re: vertical mirror help.... - 08/14/10 00:40

does anyone understand how to change the x and or y to make this a vertical mirror. i guess thats why it isnt working? i just want a mirror effect in my room. can anyone explain the steps to make it work as well?
Posted By: painkiller

Re: vertical mirror help.... - 08/14/10 10:16

Blink, take a look at unanswered questions on the last aum 94, there is an example of how to make an object to be a mirror.
Posted By: Blink

Re: vertical mirror help.... - 08/14/10 19:57

its probably in lite-c, so i may have trouble. thanks for the tip.
Posted By: Blink

Re: vertical mirror help.... - 08/14/10 23:18

ok... i got it to work somewhat, but i am getting an invalid arguement error in
mirror_startup(), in this line: mirror_view.bmap = bmap_for_entity(mirrorsprite, 0);

here's the code:

Code:
entity* mirrorsprite;

 

VIEW* mirror_view;

 

action mirror_sprite() // attach this action to a sprite / model that will be used for the mirror

{

       mirrorsprite = my;        

      

}

 

function mirror_startup()

{
       
       while (!mirror_sprite) 
       {
       	wait (1);
       }

       mirror_view = view_create(10); // set the layer value for the new view to 10

       wait (2);

       mirror_view.size_x = 128;

       mirror_view.size_y = 128; // the mirror sprite has 128x128 pixels

       mirror_view.bmap = bmap_for_entity(mirrorsprite, 0); 
       mirror_view.visible = on; 

       vec_set(mirror_view.x, vector(1000, 500, 100)); // set the position of the mirror "eye"

       vec_set(mirror_view.pan, vector(0, -10, 0)); // set the angles of the mirror "eye"

}



i am using A6.60 pro btw.
Posted By: Blink

Re: vertical mirror help.... - 08/17/10 18:49

ok...so no one with any ideas? at least how i can get rid of the error? i got it to work, but the bitmap attaches to the window in the upper left corner of my screen, and the actual bitmap is on the level., when the player faces it, the image is shown, but thats not how it should be. so,...anyone?
Posted By: Blink

invalid arguement error ????? - 08/18/10 06:42

ok, let's try this approach. does anyone know how to fix the error. the mirror works, it just not where its supposed to be, and i get the invalid arguement error. anyone????
Posted By: Nidhogg

Re: invalid arguement error ????? - 08/19/10 00:05

Can you post a couple of pics and your new code so we can see what might be the problem.
Posted By: Blink

Re: invalid arguement error ????? - 08/19/10 03:13

its the code i posted above. Thanks for responding, Nidhogg.
Posted By: Blink

Re: invalid arguement error ????? - 08/19/10 03:24

see it? in the upper left top corner? it should be on the sprite i am facing.


By beatsncredible at 2010-08-18
Posted By: Blink

Re: invalid arguement error ????? - 08/19/10 03:25

it placed like a panel unusually.
Posted By: Nidhogg

Re: invalid arguement error ????? - 08/19/10 11:37

Hi Blink, I think you need to create the entity mirrorsprite first,
From the manual "I hope it suits A6" you = ent_create("flash.pcx", temp, flash_action).
Have a look in the manual for this under Engine Functions/Entity Functions for more info.

Then have a look at the bmap_for_entity function. I am sure you will need a wait(1) right after you create the entity to give the engine time for creation.
You may also need the proc_late as well.
If you can give me a day or two I might still have my old A6 verticle mirror code lying around.
Posted By: Blink

Re: invalid arguement error ????? - 08/19/10 14:16

thanks, i appreciate whatever help you can give me. i am pulling my hair out trying to get this to work. the examples in the aums wasnt helpful, and i cant make heads or tails of the manuals instructions. now i wish i took more time learning c-script instead of modelling and level designs.
© 2024 lite-C Forums