Camera code for Lite-C? Anyone?

Posted By: Galen

Camera code for Lite-C? Anyone? - 10/25/09 18:22

I need Lite-C code for a basic camera. Not attached to a player, not attached to an entity. Just something to let me move my pos_000 camera around. I was able to in C-script, but since updating everything to Lite-C, I can't move.

Please, if anyone can point me to some Lite-C code for basic camera movement, I sure would appreciate it!
Posted By: Blackchuck

Re: Camera code for Lite-C? Anyone? - 10/25/09 18:47

here that must work;


action free_camera()
{
// c_setminmax(my);

VECTOR camera_force;
set(my,INVISIBLE|POLYGON);
// set(my,PASSABLE);

camera_force.z = 0;
vec_set(camera.x,my.x);
vec_set(camera.pan,my.pan);

while(1)
{
camera_force.x = (key_w - key_s)*10*time_step;
camera_force.y = (key_a - key_d)*10*time_step;
vec_add(my.pan,vector(mouse_force.x*(-7)*time_step,mouse_force.y*7*time_step,0));

c_move(my,camera_force,nullvector,GLIDE+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_PUSH);
vec_set(camera.x,vector(my.x,my.y,my.z+15));
vec_set(camera.pan,my.pan);

wait(1);
}
}
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/25/09 19:09

Thank you very much for the reply!

I just tried running this though and I get an "Acknex.exe has shut down" error that I wasn't getting before.

I'll try setting some breakpoints in the script to see if I can pin down where the issue is...
Posted By: Blackchuck

Re: Camera code for Lite-C? Anyone? - 10/25/09 19:12

no problem
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/25/09 19:19

Okay, I think my mistake was just adding it to my main level .c file, so instead I made a separate file and did an "#include" on it and that stopped the crashing. However when my level loads I still can't move around. I looked for a way to attach the free_camera action to my pos_000 camera, but there doesn't seem to be any option for doing so.

Am I just missing something basic here? Should I be using something other than pos_000 for my camera?
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/25/09 19:29

Okay, I removed the pos_000 and added a model and assigned the free_camera action to it, and it works!!!!


THANK YOU!
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/25/09 21:18

Oh, one quick question:
I'm trying to make the camera isometric, via:
camera.flags |= ISOMETRIC;
but it doesn't seem to be working. Any tips on how to apply this to the script you supplied? I tried adding it in after the vec_set statements but it didn't make a difference.
Posted By: Blackchuck

Re: Camera code for Lite-C? Anyone? - 10/26/09 16:18

Hmmm...
The only functions you can use with "flag" is;

VISIBLE;
OVERLAY;
TRANSLUCENT;
FILTER;
LIGHT;

(It stays like that in the handbook)

but try it with "var ISOMETRIC;" also;

action free_camera()
{

VECTOR camera_force;
var ISOMETRIC;// Give it to a var
set(my,INVISIBLE|POLYGON);
camera.flags |= ISOMETRIC;// Now no errors should show up

camera_force.z = 0;
vec_set(camera.x,my.x);
vec_set(camera.pan,my.pan);

while(1)
{
camera_force.x = (key_w - key_s)*10*time_step;
camera_force.y = (key_a - key_d)*10*time_step;
vec_add(my.pan,vector(mouse_force.x*(-7)*time_step,mouse_force.y*7*time_step,0));

c_move(my,camera_force,nullvector,GLIDE+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_PUSH);
vec_set(camera.x,vector(my.x,my.y,my.z+15));
vec_set(camera.pan,my.pan);

wait(1);
}
}

Not tested.
Hope it helped
Posted By: Quad

Re: Camera code for Lite-C? Anyone? - 10/26/09 16:25

@Blackchuck, who the hell told you that?(k, before the edit, there was a clear statement that, you should NOT set ISOMETRIC as a flag, but as a var.)

ISOMETRIC is a flag. and Galen is doin it right.

@Galen, what do you mean by it doesn't seem to be working? be more clear(screenshots?), so we can help better.
Posted By: Blackchuck

Re: Camera code for Lite-C? Anyone? - 10/26/09 16:27

Sorry I changed my post.

I reed "ISOMETRIC" wrong blush
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/26/09 17:32

Okay, I'll post a screenshot when I get home tonight. But in the meantime as explanation, the view doesn't look any different than normal. I'm not seeing things from one angle only, as per isometric...
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/27/09 00:23

Okay, here's a screenshot:


I need it to be more like this (fixed angle of perspective, though from a steeper angle):


EDIT: also, I tried it with the "var ISOMETRIC;" but it didn't work--threw a syntax error in fact.
Posted By: badapple

Re: Camera code for Lite-C? Anyone? - 10/27/09 03:37

for the perspective you want lock the cameras pan and tilt outside of a while loop and move the cam around inside a while loop like so


camera.tilt=-60;
camera.pan=315;


while (1)
{

camera.x+=6*(key_cul-key_cur)*time_step;
camera.y+=6*(key_cud-key_cuu)*time_step;

wait(1);
}


at least that should be close to the angles you want , judging from the pic
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/27/09 12:27

I'll give that a try tonight after work.

Does this mean that ISOMETRIC doesn't work?

Also, will I need to do anything with the camera arc?

Thanks.
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/28/09 03:03

Didn't work. Camera view didn't change at all.

I'm really at a loss as to what I'm doing wrong here.
Posted By: badapple

Re: Camera code for Lite-C? Anyone? - 10/28/09 05:41

you must be useing the templetes

i thought you were making standalone
Posted By: JibbSmart

Re: Camera code for Lite-C? Anyone? - 10/28/09 06:22

The angle isn't his issue, badapple. It's the perspective -- ISOMETRIC is supposed to make the view orthogonal.

Jibb
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/28/09 13:29

I'm going to try updating my A7 from .77 to .80 and see if that fixes things.
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/29/09 02:51

Well, updating to 7.8 made no difference. I'm still seeing the same thing (wrong perspective).

I have my camera action attached to a "camera" model I made.

Here's that script again:

action free_camera()
{

video_set(1920,1200,0,1);
d3d_antialias = 1;



VECTOR camera_force;
set(my,INVISIBLE|POLYGON);


camera_force.z = 0;
vec_set(camera.x,my.x);
vec_set(camera.pan,my.pan);
camera.flags |= ISOMETRIC;


while(1)
{
camera_force.x = (key_w - key_s)*50*time_step;
camera_force.y = (key_a - key_d)*50*time_step;
vec_add(my.pan,vector(mouse_force.x*(-6)*time_step,mouse_force.y*6*time_step,0));

c_move(my,camera_force,nullvector,GLIDE+IGNORE_PASSABLE+IGNORE_PASSENTS+IGNORE_PUSH);
vec_set(camera.x,vector(my.x,my.y,my.z));
vec_set(camera.pan,my.pan);



wait(1);
}





}

Posted By: EvilSOB

Re: Camera code for Lite-C? Anyone? - 10/29/09 04:18

I dont have an answer, Ive never played with the ISOMETRIC flag ever,
but try checking the view.arc entry in the manual.

It looks to me that this NEEDS to be shanged if you use the ISOMETRIC flag.
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/29/09 13:04

Thanks for the idea--I'll give that a try tonight.
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/30/09 03:39

Changing the camera.arc didn't work for me either. I am beginning to get depressed. frown
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/30/09 12:49

Since I'm not seeing anything obviously wrong with "my" code (and there's not a lot of it, and it's not too complex), does anyone know if there is anything in any of the standard "include" files that can clash with the ISOMETRIC flag? The following standard files are being included in my project:

#include "gid01-c.c" // copy of global ids
#include <acknex.h>
#ifndef gid_wdl
#define gid_wdl
Posted By: JibbSmart

Re: Camera code for Lite-C? Anyone? - 10/30/09 15:20

What edition do you have? The feature page says "ISOMETRIC" is only supported in Commercial and Pro.

Jibb
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/30/09 17:35

GAH!!!

Seriously?!?!


I have the "Extra".

*grumble grumble*

Well then, problem solved. I guess I'll need to upgrade to the Commercial version then. If it still doesn't work after that though, I'm going to scream like a little girl who DIDN'T get the pony she wanted for Christmas, lol
Posted By: JibbSmart

Re: Camera code for Lite-C? Anyone? - 10/31/09 00:31

Extra is about to become free, so for those who've bought Extra (I don't know if it's only those who got it recently) the upgrade from Extra to Com is only $50 I think.

Check the "Updates and Announcements" forum where jcl announced Extra free.

Jibb
Posted By: Galen

Re: Camera code for Lite-C? Anyone? - 10/31/09 02:37

Thanks for the tip! Nice discount too.

EDIT: ah, well, it looks like the discount will only apply for people who've purchased it since September of this year. I got mine years ago, so I guess I'll have to pay the whole upgrade price.
© 2024 lite-C Forums