SUGGESTION: RawDrawCharacter & RawDrawObject

Started by GarageGothic, Fri 23/03/2007 10:50:32

Previous topic - Next topic

GarageGothic

I'm aware that CJ is currently working on the new editor and probably won't implement new features for a while. But I thought this was a good idea and would rather suggest it before forgetting it:

Many of the coolest graphical effects in AGS require the use of RawDraw. But there's always the problem of RawDrawn items appearing behind characters and objects. It's possibly to also RawDraw the character (with manual scaling of the sprite to match area scaling), but any light effects or walkbehinds will not affect the RawDrawn sprite. To solve this, I suggest two new functions:

RawDrawCharacter(Character* cha, optional int x, optional int y, optional transparency)
RawDrawObject(Object* obj, optional int x, optional int y, optional transparency)

The functions would RawDraw the character and objects on-screen just as they would normally appear - behind walkbehinds according to baselines, with proper scaling, tinted or lit according to area/global settings, at the coordinates of the original character/object unless anything else is specified (for ease of use, the coordinates for each function share the same inconsistencies as normal object/character coords). Since it's assumed that the real character will be 100% transparent to hide it, the default transparency for RawDrawing the character is 0 - this is the only parameter not carried over from the character but must be changed manually if transparency is needed.

I realize that there may be some problems in realizing this, as sprite/walkbehind handling may use different allegro libraries than the RawDraw functions. In that case I see why it's not possible. But either way, thanks for taking the time to read and consider this suggestion.

Gilbert

I'm not sure if these functions are really useful if the raw draw on sprites feature is eventually implement. Personally I'll find this more useful as you can use that dynamic sprite in characters, objects and overlays, that possibly will satisfy your needs anyway.

Of course, currently you can rawdraw stuff at off-screen areas and grab them as sprites, but this is never too handy.

GarageGothic

#2
Gilbot, can you please explain what you mean? I'm not sure if we're talking about the same thing.

If by "raw draw on sprites" mean that I should RawDraw on top of the character sprite before placing him on the screen (which is already possible by using the background as a buffer), you're missing the point. If you did this, any RawDrawn objects in front of the character - for example raindrops - would be affected by the same light effects and walkbehinds as the character, which makes it useless.
My biggest wish for a new feature would be to allow color/light manipulation directly on DynamicSprites - then we could get rid of character rendering altogether and RawDraw everything directly.

But anyway, none of this is crucial. I have an OK workaround which works fine for me, but just sucks when scripting modules to share with others.

Gilbert

Actually I think I couldn't understand much of your original post now.

What I got from your original post was that, you want convenient ways of using the powerful raw draw functions for advanced graphics manipulations, however currently the raw draw functions only work directly on top of the background raster, so the raw drawn sprites couldn't be affected by the walkbehinds, lightings, etc. But you want the raw drawn sprites to be affected by these room factors, as suggested in your paragraph (except the 'unless anything else is specified' part):
Quote from: GarageGothic on Fri 23/03/2007 10:50:32
The functions would RawDraw the character and objects on-screen just as they would normally appear - behind walkbehinds according to baselines, with proper scaling, tinted or lit according to area/global settings, at the coordinates of the original character/object unless anything else is specified (for ease of use, the coordinates for each function share the same inconsistencies as normal object/character coords).
So, if the raw drawn stuff could be made into a sprite (or drawn on sprites) you can just use the sprite as character/ovject/whatever so it could be affected by these room settings (which as I mentioned, possible currently by raw drawing to offscreen areas and grab as dynamic sprite,but it's not handy).

However, in your recent post, it seems to me that you want to raw draw characters, etc. but they are not affected by room settings. I'm confused.

Can you elaborate on your suggestions further?


GarageGothic

#4
Heh, I want to RawDraw characters, yes - and then draw stuff on top of them which ISN'T affected by the light. walkbehinds etc. that the character is affected by. Perhaps a better way to explain is like this:

1) RawDraw stuff on background (normally)
2) RawDraw character on top of this (as a character would normally be drawn) - this is the function I suggested
3) RawDraw stuff on top of everything drawn previously (normally)

My current workaround (for my particle system) consists of first RawDrawing the particles that are in front of the character and within his x,y,sprite dimension. This is grabbed as a DynamicSprite and overlaid using a GUI (to allow for transparency which Overlays don't). Then I RawRestoreScreen and RawDraw the rest of the particles. It works fine for me, but for modules the use of a GUI is a bit of a mess - as will it be if there are multiple objects/characters on-screen.

Edit: Of course a problem in all of this, which I hadn't really considered since it hasn't been an issue on my backgrounds, is that in fact the background layer RawDraw should also adapt to the walkbehinds. In the end I think all of this is too messy to implement in the engine, especially as there are workarounds. Any moderators, please lock/delete this thread as you see fit.

Snarky

So with the RawDraw on sprites solution, couldn't you just:

1) RawDraw stuff on background (normally)
2) Draw character on top of this (normally)
3) RawDraw stuff on a sprite
4) Draw the sprite on top of everything

GarageGothic

#6
No... :)

Well, depends what you mean by "Draw". If you mean RawDraw - well, then:
2) RawDrawing a character wouldn't allow light/tint values for him

If you mean drawn as characters are normally drawn, then what do you mean by "draw" in step 4?

Edit: Anyway, I'm all for the RawDrawOnSprite function - it's a bit superfluous, but it would make some things slightly easier. In this case I don't see what it can do, which can't already by done easily using the background as a buffer though.

Edit 2: Come to think of it, a lot of this could be solved if CJ just allowed x, y, width, height coordinates for the DynamicSprite.CreateFromScreenShot function as I suggested another time (because grabbing the entire screen to a sprite, then cropping it causes a big performance hit in hi-res). Then you could just grab the area with the character, hide the character, then rawdraw that area again.

Pumaman

What Gilbert and Snarky are suggesting should work if raw drawing onto sprites is implemented, ie:

1. Create a dynamic sprite and rawdraw your "on top" stuff onto it
2. Set an object or character to use this sprite and set its baseline to make it top-most
3. Rawdraw your background stuff on the background. The normal character and your rawdrawn character will then by drawn on top automatically.

GarageGothic

Thanks for replying CJ.

Yes, I am aware that these things are perfectly possible, even WITHOUT the RawDrawOnSprite function. Pretty much all my visual effects use this exact technique, RawClearing the screen to RGB(255, 0, 255), RawDrawing sprites and the creating a DynamicSprite from this. For some effects I use characters to display the DynamicSprites, for some I use GUIs. For some even objects if it's a single-room effect.
The reason for my suggestion was to try to avoid the hackish use of characters, GUIs etc. which would make it more usable for modules distributed to the public. I realized after posting the suggestion that I should probably be satisfied that I have my own little workarounds and not worry too much about future modules which I may or may not release.

Please, feel free to lock or delete this thread.



SMF spam blocked by CleanTalk