Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: td on Wed 19/07/2006 19:02:52

Title: Shadow for 3D character (SOLVED)
Post by: td on Wed 19/07/2006 19:02:52
Well is that not same like "shadow for 2D character" (seems                                    FollowCharacterEX(shadow, character, follow_exactly, 1);
     Set Trasparency(shadow, 50);
dosn't work...)
i suppose. Who know how can i make shadow for 3D character???
Title: Re: Shadow for 3D character
Post by: DoorKnobHandle on Wed 19/07/2006 19:08:10
Hehe, as far as I know, it's really not as simple. There are various approaches to real-time shadows in 3d-environments such as "Shadow Mapping" or "Shadow Volumes". But all that is not implementable in AGS at the moment, maybe the developer of the Character 3d-module could do this in C++, but he would need to know what kind of level-file you're using as well, because when calculating a 3d-shadow, you need to know where to project it.

Or, aren't you even using the character3d-module? Give us more information, please.
Title: Re: Shadow for 3D character
Post by: td on Wed 19/07/2006 19:16:23
I using Character3D plugin ver. 0.93 by Ferri Gabriel - besh81. Well it is not necessarily to use realistic real-time shadow for me. i wanna just "black spot" thats of it...
Title: Re: Shadow for 3D character
Post by: DoorKnobHandle on Wed 19/07/2006 19:18:55
Ah, in that case you might simple draw a black dot (circle or ellipsoid) shape as sprite and then try to always position it underneath the player. You could have it as object and make it transparent as well. However, I don't know if objects will be infront or behind characters from the module and it won't look good from all perspectives.
Title: Re: Shadow for 3D character
Post by: td on Wed 19/07/2006 20:24:06
As i understand is a problem to create a "spot" sprite in MilkShape3D because this soft not for creating, but for changing existing 3D models. Anyway i think using 3D models  is a future of AGS and shadows is the next step...
Title: Re: Shadow for 3D character
Post by: Besh on Thu 20/07/2006 03:07:51
Hey dkh knows my plugin better than meÃ,  ;D

Inside the plugin there is the code for generateÃ,  "Shadow Volumes" but the problem is: (as dkh said) "you need to know where to project it".

Second problem: the speed, with "Shadow Volumes" enable the fps drastically decrease.
Title: Re: Shadow for 3D character
Post by: GarageGothic on Thu 20/07/2006 03:24:24
But wouldn't it be possible to just project it directly below the character, as if he was standing under a lamp? Then you would have the equivalent of a blob shadow but matching the character's movement and have no problems with it projecting onto objects or walls.
Title: Re: Shadow for 3D character
Post by: DoorKnobHandle on Thu 20/07/2006 11:22:22
Good idea, GG, but what if you want the character to float in the air for example? Or if the character is lit from one side, so that a long shadow in one direction is created and he stands in front of a wall, the shadow should wrap around the wall? And what if the character stands on a ramp?

You could use this "hack" and just make sure that the light is always on top of every character so that the shadow always is really small underneath it and then pretend that you know that the character always stands on an even ground.

Another, way better possibility would be to combine the AGS3D-module (which is great for the levels) and this Character3d-module (which is great for characters) and allow them to communicate together for things like this!
Title: Re: Shadow for 3D character
Post by: GarageGothic on Thu 20/07/2006 13:48:55
dkh, the floating in air situation should be quite simple since the shadow coordinates would still be (character.x, character.y) if you use the  the character.z to make the character float. Most AGS users only use shadows for making the character seem "grounded", or in the floating situation, do define his depth position in the room.

The problem with combining the character module with AGS3D for shadow rendering is that the basic geometry of the room has to be mapped on in a 3D space. For most users this would be way too much work just for shadows and would be quite impossible with some art styles that don't rely on realistic perspective.

I wrote a shadow rendering module for 2D characters which uses geometry and basic rules of drawing to project a dynamic shadow of a character onto the floor, walls and ceiling of a basic room. The light source is defined using x, y and a height coordinate, and if it is possible to grab a DynamicSprite of the character rendered from this point in the room, the module would work just as fine with 3D characters. I'm sure it could be speeded up greatly if the rendering was done in a plugin instead, but I would suggest an approach similar to this instead of one that requires full modelling of the room (one of the main reasons I gave up on the WinterMute engine).
Title: Re: Shadow for 3D character
Post by: td on Thu 20/07/2006 19:40:56
Besh, could u give me a simple example of code?? I wanna project swadow right under character... well nevermind what of side shadow will turn i just need a code example...
Title: Re: Shadow for 3D character
Post by: Besh on Fri 21/07/2006 05:52:16
With the actual version of C3D it is impossible since the code for generate shadow is inside but there isn't the AGS interface.
Also this routine works with the scene light so the shadows isn't project under the character but in the right direction.
Title: Re: Shadow for 3D character
Post by: td on Fri 21/07/2006 14:11:07
So maybe exists some way to realize a shadow with standart AGS instruments? Please... i need just a BLACK CIRCLE under the character...
Title: Re: Shadow for 3D character
Post by: GarageGothic on Fri 21/07/2006 14:20:58
You said something about FollowCharacter not working, which I don't really understand. But anyway, just create another character (not 3D), create a black blob sprite for it's view, set it's transparency to 50 or so and place it at (player.x, player.y) every loop through the repeatedly_execute_always.

(Or rather at (player.x, player.y - (shadowheight/2)) to make it seem beneath the character - but then I would suggest resizing it manually to avoid it being a different scale than the character).
Title: Re: Shadow for 3D character
Post by: td on Fri 21/07/2006 19:39:54
Please tell me what should i do exactly??? I has been created another character (black spot), set the view and type in global script :

FollowCharacterEX(shadow, (character name), follow_exactly, 1);
Set Trasparency(shadow, 50);

But there was error line 17: Undefined token FollowCharacterEX

Whaaat wrong?

Title: Re: Shadow for 3D character
Post by: GarageGothic on Fri 21/07/2006 20:41:31
Ok, the problem in this case is the capitalization of the X I think. You've written FollowCharacterEX instead of FollowCharacterEx. There may be other problems, but since I'm using a later version of AGS, I'm only familiar with the new object-oriented versions of the commands.

The 'Set Trasparency' line should be SetCharacterTransparency though, I think. Be very careful with correct spelling, spaces and capitalization.
Title: Re: Shadow for 3D character
Post by: td on Sat 22/07/2006 09:47:26
Do'h!

FollowCharacterEx (... < error undefined token ...
                               follow_exactly < error undefined symbol

I has been followed AGS help, but where i misspelled???

Edit:

It's FOLLOW_EXACTLY, capitalized. Solved.