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 11029 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
Pages: [1] 2  All
 

Page created in 0.047 seconds with 19 queries.