Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: 1 2 [All]

Author Topic: Horizontal Scaling?  (Read 11032 times)

0 Members and 1 Guest are viewing this topic.

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Horizontal Scaling?
« on: January 23, 2005, 12:04:10 AM »

Hi guys,

Is it possible to apply a Horizontal Scale to a scene? I have a scene with a beach extending off into the distance to the right. As the character walks further right it needs to scale down?

I cant find anything in the GUI and was think I would probably have to write a script that checks the X value of the character in a region and changes the scale based on a preset algorithm.

But before I start figuring that out - is there an easy way?  ::)

Oh... and does anybody know if that would even be possible in this script language?

(If you arent too bored of this already - I have detailed my script idea below  ::rock)

Lets say that at X=400 our character should be 100% and at X=600 it should be 50%.

Script would take the difference between 400 and 600 (200 pixels) and divide that by the percentage decrease across the distance (200/50 = 4).

For every 4 pixels past 400px the scale will decrease by 1%.

 ???
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #1 on: January 23, 2005, 09:50:47 AM »

It's not natively supported by the engine because it's not a typical request, but it should be fairly easy to script.
Create a new script with the following content and attach it to your scene:

Code: [Select]
#include "scripts\base.inc"

var StartX = 0;
var EndX = 2048;

var StartScale = 100;
var EndScale = 50;


while(true)
{
  // normal scale if actor is outside the script-controlled area
  if(actor.X < StartX || actor.X > EndX) actor.Scale = null;
 
  // otherwise set the scale manually depending on X position
  else
  {
    actor.Scale = StartScale + (EndScale - StartScale) * ((actor.X - StartX) / (EndX - StartX));
  }

  // and go to sleep for some time
  Sleep(100);
}

You can tweak the scaling range/value by changing the constants in the beginning of the script.
« Last Edit: January 23, 2005, 09:53:48 AM by Mnemonic »
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #2 on: January 23, 2005, 11:29:01 PM »

Excellent! That looks like a script version of what I had in mind! Although - I hadnt taken into account what to do with the Vertical Scaling....

Thanks again for the quick response. :)
Logged

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #3 on: January 24, 2005, 10:56:40 AM »

Hmm... works perfectly!  But...  it doesnt quite look right.

It needs to work "in addition" to the scene scaling...

In the scene... the Beach extends off to the right - but into the distance. So as the character walks right he gets smaller (which works) - HOWEVER, because we disable the scene scaling - if the actor walks up/down - he doesnt scale at all... which means he cant explore the scene... we'd have to restrict movement to left/right only...

Is it possible to have the HorizScale +/- ADDED to the Normal Scene scaling? Or maybe work the HorizScale as a percentage?

Ie - if the current Actor.Scale=50(%) and the HorizScale is 50% - Actor.Scale becomes 25%.  As the Scene scale goes between 40%-60% - the HorizScale would make it range between 20%-60%.

Does that make sense?

I'll have to sit and play with the script and try to learn how to do this sort of thing myself... I can see me using a lot of custom scripts. :o)

I am loving WME by the way.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #4 on: January 24, 2005, 11:01:32 AM »

You can query the standard scene scaling by using Scene.GetScaleAt(actor.X, actor.Y). Then combine the returned value with the one calculated by the above script. I'm not sure how to combine these to make it look right, though...
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #5 on: January 24, 2005, 11:12:08 AM »

Ok guys... need a bit of help... I *think* I may have cracked the problem... but need some input from the professionals. :D

I cant run WME at work to test my theory... but does the following look like it will work?

Code: [Select]
#include "scripts\base.inc"

var StartX = 1000; //The left edge of the region where the custom scaling starts
var EndX = 1700;   //The furthest right edge of the custom scaling region
var StartY = 370;  //The top of the custom Y (Vertical) Scaling
var EndY = 558;    //The bottom of the custom Y (Vertical) Scaling

var StartScale = 40;
var EndScale = 15;

var VertDiff = 30; //The percentage difference the Vert scale will add to the custom scale

while(true)
{
  // normal scale if actor is outside the script-controlled area
  if(actor.X < StartX || actor.X > EndX) actor.Scale = null;

  // otherwise set the scale manually depending on X position
  else
  {
    // Calculate the scale based on the Horizontal Position
    actor.Scale = StartScale + (EndScale - StartScale) * ((actor.X - StartX) / (EndX - StartX));

    // Now calculate the percentage to add to the scale based on the Vertical position and ADD
    // it to the previously calculated scale.
    actor.Scale = actor.Scale + ((VertDiff / (EndY-StartY)) * (actor.Y - StartY));
  }

  // and go to sleep for some time
  Sleep(100);
}

 ???

Thanks,
Rev
« Last Edit: January 26, 2005, 12:56:46 AM by revvin »
Logged

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #6 on: January 25, 2005, 03:12:18 PM »

see above. (doh!)
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #7 on: January 25, 2005, 03:56:33 PM »

Ow, I don't really know, I'd have to try it.. (and I can't right now)
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #8 on: January 26, 2005, 01:07:48 AM »

IT WORKED!!! EUREKA!!!  ::rock

I have put the amended script above. The character seems a little jumpy - almost as if its resetting the scale every other frame? Maybe somebody could check the script?

The reason I want the scaling for both X & Y should be fairly clearly demonstrated on the image... once our character reaches the second half of the scene - the perspective shifts. So as he walks towards the RIGHT (X+) he needs to reduce in size... but also when he moves UP/DOWN (Y+-) because he may explore the beach.



Hopefully this script (or an optimised version?) could come in handy to other WME Users?

Next stop... Making him walk slower when smaller....
Logged

odnorf

  • w00t?
  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 7
  • Offline Offline
  • Gender: Male
  • Posts: 1456
  • Lamp dog!
    • View Profile
Re: Horizontal Scaling?
« Reply #9 on: January 27, 2005, 04:03:04 PM »

Next stop... Making him walk slower when smaller....

WME handles this automatically... It scales the "walking pixels" as the characters sprite get scaled. Maybe you need a more aggressive scale?
Logged
fl*p

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #10 on: January 27, 2005, 05:01:02 PM »

Maybe you need a more aggressive scale?

Hmm... I cant really scale him any more agressively - he is tiny. There doesnt seem to be any difference in speed at all? Maybe its because we are manually adjusting the scale?
Is it possible to control the walk speed in the script? I cant seem to find any variables for it?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #11 on: January 27, 2005, 06:26:13 PM »

It works like this: WME scales the "move" values for animation frames according to actor's scale. But once it reaches one pixel, it cannot scale down any further.

Unfortunately I can't think of any other feasible way of affecting walking speed at the moment..
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #12 on: February 12, 2005, 03:12:10 PM »

Sorry to drag this out... but its still causing me grief :(

In Visionaire (which I used for almost 2 years) they nailed this problem... you simply place a spot on the scene (similar to your hotspots) and just set the scale at that point. As you put different scales at different points in the scene - the engine automatically calculates the scale depending on where the actor is standing. Its very easy to use, and incredibly effective... maybe you could implement something like this in the future?

Anyway - for the timebeing I am trying to script it.... and having trouble with the character popping up in the wrong scale - or scaling when he shouldnt be... I have RAR'd up my project and uploaded to:

http://www.maroonedgame.com/wme/marooned.rar

WARNING - 14Mb download

Do you think you could have a look at the project so far and see if you can improve the method I have implemented?

Already eternally grateful,
Kevin
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #13 on: February 13, 2005, 03:54:10 PM »

I downloaded the project, but I'm a little busy these days. I'll check it when I have some free time, I'm sorry..
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #14 on: February 24, 2005, 01:51:11 AM »

Hi,
Have you had a chance to look over the project?
Thanks again
Revvin
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #15 on: February 27, 2005, 04:27:53 PM »

Ok, I tested it and in my opinion this continuous scale change will never work, because it just doesn't look very realistic. Actually this whole concept of two different perspectives in one scene is not very realistic, but I think it would work well if you took advantage of the big rock in the middle and switch to different perspective while the actor is completelly hidden. What I'm thinking of, technically, are two sets of scale levels, and switching from one to another when walking behind the rock. Of course, currently it's not possible to control scale levels at runtime, but I could add this functionality relatively easily.
So what do you think?
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #16 on: February 28, 2005, 03:53:35 PM »

I agree as far as it not looking realistic. My artist did the scene quickly and didnt take lines of perspective into account - so it would always look wrong.

He is re-doing the scene with clear lines of perspective. This will mean the character should scale realistically on the scene.

Have you seen Visionaire?  Their scaling system is superb. You basically create "POINTS" on the scene and specify the character scale at that point (as a percentage). The engine then sets the scale according to the characters proximity to each of these points.

This gives you huge amounts of control over the scaling and makes everything look perfect.  I could post a quick example if it helps?

Do you think maybe you could implement something like this instead?

Thanks again for all your help,

Regards
Revvin
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #17 on: March 01, 2005, 09:19:18 AM »

I'm not too familiar with Visionaire, but the way you describe it it sounds like the "paths" used by AGAST, where the points are also used for path-finding and coloring. In my very humble opinion, just for perspective reasons this approach is an overkill in most cases, because the perspective works much simpler than that. Unless, of course, you're using some crazy comix art... or when you're mixing different perspectives in a single scene :) In other words, I'm not sure I'd want to add something like that to WME because it's unnecessary in most cases, doesn't mix well with the current system and it would be too confusing for the users.
I still do think the way I suggested above might work well for your scene, though.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #18 on: March 02, 2005, 01:01:45 AM »

Thats ok I understand. I'll have to try your method on that particular scene. I have just included the following because I think it explains more clearly what I was trying to do.

I have uploaded the prototype I was working on in Visionaire to http://www.maroonedgame.com/wme/visionaire_prototype.exe

If you walk through the three different scenes you should see that the Scaling blends very well into the scenes.

In the below scene you can see I only set three points - and the scaling is perfect.



Do you think the standard scene scaling will work as well in these examples?

Also - if you press and hold the left button over an object (like the spoon) and let go over the PICK UP icon - it disappears and the action is performed. This is the last thing I was working on before checking out WME. Are you aware of anybody else that has created a verb coin like this so I can pick their brains? or do you know whether its possible to implement?

Thanks again for all your help,

Regards
Rev
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Horizontal Scaling?
« Reply #19 on: March 02, 2005, 10:31:55 AM »

Do you think the standard scene scaling will work as well in these examples?
Yes, I think so. At least it seems to be the standard case where the character needs to get bigger the closer to the camera he is.

Also - if you press and hold the left button over an object (like the spoon) and let go over the PICK UP icon - it disappears and the action is performed. This is the last thing I was working on before checking out WME. Are you aware of anybody else that has created a verb coin like this so I can pick their brains? or do you know whether its possible to implement?
WME Demo 3D uses a verb-coin interface. You will find all the necessary code in game.script and game_daemon.script in the demo. game.script handles the LeftClick and LeftRelease events, and game_daemon.script just displays the menu after the player holds the mouse button for a certain period of time.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

revvin

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 36
    • View Profile
Re: Horizontal Scaling?
« Reply #20 on: March 02, 2005, 04:07:47 PM »

Ok thanks Mnemonic.

I have got my artist splitting the scene into two now - so instead of panning across a different perspective - it'll just change scene.

The effect we want to achieve where he gets small as he walks to the right - we will have to fake by forcing the character along a tight path that travels upwards. That should allow the standard Scene Scale to come fairly close to the desired effect.

Thanks for all your help,
Rev
Logged
Pages: 1 2 [All]
 

Page created in 0.079 seconds with 20 queries.