Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
1 registered members (AndrewAMD), 599 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ang_add example fails #260971
04/14/09 23:01
04/14/09 23:01
Joined: Feb 2008
Posts: 6
vic Oz
Ddee Offline OP
Newbie
Ddee  Offline OP
Newbie

Joined: Feb 2008
Posts: 6
vic Oz
The ang_add example in the manual I have is a chase camera.
The example for the chase camera generates errors.



// A camera is hunting a target and turns with it, keeping the target always in the middle of the view.
function chase_camera(ENTITY* target)
{
// calculate the camera view's direction angle to the target
var cam_dist[3] = {-200,-100,-100}; // xyz distance vector from the camera to the target
var cam_ang[3]; // direction angle of the camera to the target.
vec_to_angle(cam_ang,cam_dist);
cam_ang.roll = 0; // roll didn't change vec_to_angle

// permanently updating the camera's position and angle
while (1)
{
// place the camera at the right position to the target
vec_diff(camera.x,nullvector,cam_dist);
vec_rotate(camera.x,target.pan);
vec_add(camera.x,target.x);
// Set the camera angles to the camera view direction
vec_set(camera.pan,cam_ang);
// and rotate it about the target angle
ang_add(camera.pan,target.pan);
wait(1);
}
}

So...

the line - cam_ang.roll = 0; // roll didn't change vec_to_angle
says roll not member of 'function'

the line - vec_rotate(camera.x,target.pan);
says pan not member of 'VECTOR'

the line - ang_add(camera.pan,target.pan);
says pan not member of 'VECTOR'

if I comment out these lines it works to a certain degree but is too lame to include in my project.

So... what am I doing wrong this time?

Help would be appreciated. Thank you


i7-930 8g (2*Nvidia 250 1gVRAM in SLI) Audigy A7.7pro
Re: ang_add example fails [Re: Ddee] #260979
04/15/09 01:23
04/15/09 01:23
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
The target isn't defined as a vector. Try this.

var target[3];

Put it among the other variable definitions.
If it doesn't work, change the name target to something different.

Re: ang_add example fails [Re: Pappenheimer] #260998
04/15/09 08:25
04/15/09 08:25
Joined: Feb 2008
Posts: 6
vic Oz
Ddee Offline OP
Newbie
Ddee  Offline OP
Newbie

Joined: Feb 2008
Posts: 6
vic Oz
Thank you for your time Pappenheimer,

I tried the var target[3]; but unfortunately it did not work.

I tried the substitution in various forms and alas, it did not work either.

My machine is acting strange (In WED, the standard.wad loads but no icons for textures are there)
I suspect there are lost chains on the disk that may be including 3DGS7 files so I will do a re-install.

I shall then attempt it again and post response. Thanks again for the help.


i7-930 8g (2*Nvidia 250 1gVRAM in SLI) Audigy A7.7pro
Re: ang_add example fails [Re: Ddee] #261015
04/15/09 09:58
04/15/09 09:58
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
This was a mistake of mine. The name "target" is already used for a predefined vector, therefore the error message.

Replace "target" with a different name, f.i. "ent".

Re: ang_add example fails [Re: Ddee] #261019
04/15/09 10:27
04/15/09 10:27
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Originally Posted By: Ddee
I tried the substitution in various forms and alas, it did not work either.


I don't think there is any re-installing needed, at least not because of this problem.

I have to apologize for posting my first guess instead of looking closer into the code.

I didn't see that "target" was used as a pointer:

function chase_camera(ENTITY* target)

You know that you had to replace any appearance of "target" in the code?
How did you implement this code in your script?

If you have a player action, and you the camera chase the player, then you can write into that action before its while loop:

chase_camera(my);

... and the camera should chase the player.
I don't know how much experiences you have with coding. It is possible, that I tell you something that you already know, or that don't understand as all. confused

Re: ang_add example fails [Re: Pappenheimer] #261029
04/15/09 11:08
04/15/09 11:08
Joined: Feb 2008
Posts: 6
vic Oz
Ddee Offline OP
Newbie
Ddee  Offline OP
Newbie

Joined: Feb 2008
Posts: 6
vic Oz
Pappenheimer, Please do not worry, even if you are telling me something I know, I am grateful for the assistance and re-assurance that members can find concerned mentors that are willing to help.

I have been building my project from scratch to learn lite-c coding so I did not use the template system. I have converted some GTKradiant maps in WED for the different levels and am ever-so-slowly developing my game. I still find it difficult with some conventions (particularly the physics system) but I am enjoying the experience.

I copy/pasted the example from the manual to the appropriate places in my script and called the function with the ENTITY* name in the parameter brackets.
It was difficult to work out what to do with your advice as the (ENTITY* target) part seemed to me to say the ENTITY pointer had nominated the name target as an entity.

when I renamed the variable to try the substitution I called it pappen1. Thanks again.


Jcl, I did not know that the name 'target' was reserved. Is there a page to find the reserved or key words in the manual? Thank you for your time also.


i7-930 8g (2*Nvidia 250 1gVRAM in SLI) Audigy A7.7pro
Re: ang_add example fails [Re: jcl] #261030
04/15/09 11:11
04/15/09 11:11
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
JCL : Looking at your reply, does that mean that "prefined" variables/pointers/etc
CANNOT be over-ridden by local definitions?
Or is it just something that SHOULDNT be done as the results are unpredictable?
Or can the predifined variables/pointers/etc be over-ridden by local definitions
and still used safely if they stay the same type?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: ang_add example fails [Re: Ddee] #261043
04/15/09 12:16
04/15/09 12:16
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Originally Posted By: Ddee
It was difficult to work out what to do with your advice as the (ENTITY* target) part seemed to me to say the ENTITY pointer had nominated the name target as an entity.

I'm not sure whether I understand you. "ENTITY* target" normally marks only the place where you have to insert the pointer of your entity. As far as I understood this.

action player_walk_around
{
player = me;
chase_camera(player);
while(1)
{
my.pan += key_cul-key_cur;
my.x += key_cuu-key_cud;
wait(1);
}
}

Before that action you have to insert the function, I replaced target with "ent_for_cam":

function chase_camera(ENTITY* ent_for_cam)
{
// calculate the camera view's direction angle to the ent_for_cam
var cam_dist[3] = {-200,-100,-100}; // xyz distance vector from the camera to the ent_for_cam
var cam_ang[3]; // direction angle of the camera to the ent_for_cam.
vec_to_angle(cam_ang,cam_dist);
cam_ang.roll = 0; // roll didn't change vec_to_angle

// permanently updating the camera's position and angle
while (1)
{
// place the camera at the right position to the target
vec_diff(camera.x,nullvector,cam_dist);
vec_rotate(camera.x,ent_for_cam.pan);
vec_add(camera.x,ent_for_cam.x);
// Set the camera angles to the camera view direction
vec_set(camera.pan,cam_ang);
// and rotate it about the ent_for_cam angle
ang_add(camera.pan,ent_for_cam.pan);
wait(1);
}
}

Re: ang_add example fails [Re: Pappenheimer] #261155
04/16/09 01:41
04/16/09 01:41
Joined: Feb 2008
Posts: 6
vic Oz
Ddee Offline OP
Newbie
Ddee  Offline OP
Newbie

Joined: Feb 2008
Posts: 6
vic Oz
Assigning the action has made quite a difference and now the chase_camera is working well
(except I still have to comment out the cam_ang.roll = 0; bit.
I have added a camera.roll = 0; to my 'function (main)'
and this seems to keep the roll angle stable)

It has given me quite a lesson adjusting it into my script as well.

Thank you


i7-930 8g (2*Nvidia 250 1gVRAM in SLI) Audigy A7.7pro
Re: ang_add example fails [Re: Ddee] #261181
04/16/09 08:20
04/16/09 08:20
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Great, that its working now. smile

What if you place the

camera.roll = 0;

after:

ang_add(camera.pan,ent_for_cam.pan);

and before the wait(1);

?

The

cam_ang.roll = 0;

actually doesn't makes any sense in the function. That's right.


Moderated by  aztec, Inestical, Matt_Coles, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1