Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AbrahamR), 717 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
an emulated shadow for my models!? #414729
01/07/13 09:41
01/07/13 09:41
Joined: Jan 2013
Posts: 23
France
M
Mo222 Offline OP
Newbie
Mo222  Offline OP
Newbie
M

Joined: Jan 2013
Posts: 23
France
Hello,

I am trying to make a script to add shadows for my models.
I am having big troubles with vectors and angles.

my biggest problem so far is my ignorance of the whole C-script.I know the basics of C-script , but when it comes to angles , it becomes illogic in my head.

I searched in the manual and i know that 3 angles affect the orientation of the model in the world :
-pan
-tilt
-roll

While pan and roll are 0-360 , tilt is -90 to 0 to 90 ......
Why is tilt different from pan and roll? i can find a solution yet for my shadows.

Since A6 doesnt cast model shadow on another model, then i decided(as superku advised me) to create a homemade function for shadows to cast on any surface.

In order to do that , lets say there is a little toon running in levels made of cubes(cubes that are models).

-i made the script of the little toon(gravity, move,etc..)
-i attach to the little toon his shadow (his shadow is the same model that i would shrink and make dark)
-i let the toon perform a trace from him to the ground in the direction of the sun.
-Where the trace hit the ground , i put the shadow there.
-I animate the shadow like the little toon (my.frame=you.frame)

And now the problem.
-Now i want the shadow to give the right face of the toon on the ground. For example : if the toon gives his side to the sun, then i want the shadow to show his side on the ground . If the toon gives his back to the sun, then the shadow is showing her back on the ground,etc...

I understood that it was not possible to change pan,tilt,roll directly , because A6 then confuses tilt and roll, and it doesnt work. After you tilted the shadow to make it horizontal on the ground, i cant make it turn like the pan of the toon with direct changes of pan,tilt,roll . 1 angle is blocked.

Then i tried with ang_add .
And now i have the problem of the tilt range(-90,0,+90) which doesnt match with pan and roll range(0,360) , then how can i use that to make an instruction that would something like:
shadow_toon.tilt=toon.pan; and the whole combination in an ang_add instruction.........

Somebody tried to make this kind of shadow?

Re: an emulated shadow for my models!? [Re: Mo222] #414730
01/07/13 09:50
01/07/13 09:50
Joined: Jan 2013
Posts: 23
France
M
Mo222 Offline OP
Newbie
Mo222  Offline OP
Newbie
M

Joined: Jan 2013
Posts: 23
France
Maybe for comparisons of angles , the instruction ang(x) can help me!

Re: an emulated shadow for my models!? [Re: Mo222] #414740
01/07/13 11:08
01/07/13 11:08
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The angles are not limited, you can keep pan/ roll between -180 and 180 and still describe the whole sphere (see spherical coordinates on Wikipedia)/ all angles.

Try something as follows:

// in the player function after c_move:
c_trace(my.x,vector(my.x,my.y,my.z-2000),IGNORE_PASSABLE | IGNORE_ME);
if(trace_hit)
{
vec_rotate(normal,vector(-my.pan,0,0));
my_shadow.tilt = -asin(normal.x);
my_shadow.roll = -asin(normal.y);
}


"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: an emulated shadow for my models!? [Re: Superku] #414756
01/07/13 12:53
01/07/13 12:53
Joined: Jan 2013
Posts: 23
France
M
Mo222 Offline OP
Newbie
Mo222  Offline OP
Newbie
M

Joined: Jan 2013
Posts: 23
France
Hey superku !

i dont use the A6 template scripts, so my engine doesnt recognize "my_shadow" .
However,I finally achieved to turn the pan of my shadow as the little toon turn , with a part of your help .
In fact, i finally tried to use cosinus for angles , and this time it worked.

There is another problem that i encountered !

Since the shadow is an instance of the little toon model , i thought that i could shrink it flat to the ground , no matter how it would be oriented in the world.

But i cant find a way to shrink it arbitrarily! in order to let the shadow be always flat to the ground.
There are only scale_x, scale_y ???

I found out this problem because when i achieved to turn the pan of the shadow, it would turn like a flat model would turn.

Re: an emulated shadow for my models!? [Re: Mo222] #414760
01/07/13 13:30
01/07/13 13:30
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I fear your system won't work without the use of shaders, even then it won't be easy. I suggest you simply use blop shadows, simple blurred round or cornered sprites.

my_shadow obviously is just a pointer for the shadow entity, I thought you would understand that without in detail explanation:

ENTITY* my_shadow = ent_create("toon_shadow.mdl",my.x,NULL);
my_shadow passable + unlit (forgot how to write it in C-Script)
...
the code from above


"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: an emulated shadow for my models!? [Re: Superku] #414770
01/07/13 14:33
01/07/13 14:33
Joined: Jan 2013
Posts: 23
France
M
Mo222 Offline OP
Newbie
Mo222  Offline OP
Newbie
M

Joined: Jan 2013
Posts: 23
France
yes i think you are right.

For my system it would require too much work , and i am not ready for that .

thanks for the my_shadow explanation.

I realize now that my goal was too high ...i 've worked on that system for 2 days , and it just adds a problem each time i solve the previous one.

Blop shadows!

Re: an emulated shadow for my models!? [Re: Mo222] #414772
01/07/13 14:52
01/07/13 14:52
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Good!
As a hobby game developer with rather limited time and no pressure I think it's a good way to put things aside when they don't want to work after a few days and instead continue to work on other things (except when you have a game in an advanced state and the feature/ issue is important).


"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: an emulated shadow for my models!? [Re: Superku] #414799
01/07/13 22:08
01/07/13 22:08
Joined: Jan 2013
Posts: 23
France
M
Mo222 Offline OP
Newbie
Mo222  Offline OP
Newbie
M

Joined: Jan 2013
Posts: 23
France
cool Yep , i am happy you agree with that because sometimes its just a waste of time and fun to keep focusing on the same problem.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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