Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] Simple Shadows

Author
Message
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 14th Nov 2010 18:42 Edited at: 14th Nov 2010 18:43
A neat trick to do shadows for an object above a flat plane. This will work for single colour shadows for any object (like oldskool black shadows), but for convex objects (eg sphere or box), ghost or alpha will work too.

bergice
17
Years of Service
User Offline
Joined: 5th Jun 2007
Location: Oslo,Norway
Posted: 14th Nov 2010 23:15
That's impressive.

Does it slow down quickly?

51fa1db0ec7c4af52d93a6f5d0e86bc5

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 15th Nov 2010 01:13
Thanks. I don't think it does, apart from having extra objects for shadows. DBP, DirectX or whatever uses rotation/translation/scaling matrices for objects and limbs anyway. Even if it were doing more matrix multiplications at runtime, they apply to whole limbs rather than individual vertices.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 15th Nov 2010 01:15
Neat.

Now, why does rotating limb 0 of object 2 rather than object 2 itself have that effect - and how did you work it out? Works like magic.
Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 15th Nov 2010 02:57
It's because the order of matrix multiplications. I used to assume that rotating the object was the same thing as rotating limb 0. It achieves the same end, however, what is happening is that the "object" is just a frame, and the limbs are linked to it. With hindsight it makes more sense that way.
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 16th Nov 2010 11:21
So there are separate values for the object's rotation and limb 0's rotation?

Dr Tank
15
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 16th Nov 2010 18:53
That's right.

This can be used for a lot of things. It makes it possible to shear the object or scale it along an arbitrary axis.
Dodga
14
Years of Service
User Offline
Joined: 12th Dec 2009
Location:
Posted: 17th Nov 2010 00:19
Yeah, for instance with sparky's collision you cannot scale an object and have it work correctly, if you use scale limb 0 you can scale and sparky's will actually work with it.
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 17th Nov 2010 16:10
This is a neat trick, you have done it again Dr.Tank.

Custom,intel 3.0GHz Hyper Threaded,4GB RAM,ATI X1500 256mb,
WindowsXP DBpro v7.5 Synergy
The coffee is lovely dark and deep,and I have code to write before I sleep.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Nov 2010 16:26
Quote: "Yeah, for instance with sparky's collision you cannot scale an object and have it work correctly, if you use scale limb 0 you can scale and sparky's will actually work with it."

Really, I thought you could use "SC_allowObjectScaling"?

I tend to scale objects using this code anyway but I don't tend to scale objects after setting them up with sparky's:


Login to post a reply

Server time is: 2024-11-21 20:34:58
Your offset time is: 2024-11-21 20:34:58