UBBFriend: Email This Page to Someone!
  Flatland Forums
  Scripting
  Scaling: How do i do it

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Scaling: How do i do it
dan goober
Member
posted 05-02-2002 08:00 PM     Click Here to See the Profile for dan goober     Edit/Delete Message Reply w/Quote
How do i scale blocks?

really need help i've got a hummer so small you can step over it. could use scaling. Hint
Hint!

Oh, if you want the vehicles blockset its in: http://rhteam.home.att.net/3dml/vehicles.3dml

you all's
dan goober

xuriel
Member
posted 05-02-2002 08:18 PM     Click Here to See the Profile for xuriel     Edit/Delete Message Reply w/Quote
Here is an example. I hope the comments provide a good explanation of what is going on.

code:

<spot version="3.3">
<head>
<title name="Your spot title" />
<blockset href="http://blocksets.flatland.com/flatsets/basic.bset" />
<map style="double" dimensions="(21,21,3)" />
<sky />
<orb />
<ground />
</head>

<body>

<!-- THE BLOCK, TO BE SCALED -->
<create symbol=".#" block="full">
<param movable="yes" /> <!-- tell Rover this block is "scriptable" -->
<define>
<scale_x>4.0</scale_x> <!-- proportions by which the scale -->
<scale_y>4.0</scale_y> <!-- function will multiply the block -->
<scale_z>4.0</scale_z> <!-- vertices. -->
</define>
</create>

<define>
<function name="scaleblock" params="block">
/* Grab all of the block's vertices */
vertex_list = block.get_vertices();

/* Loop through vertices and scale */
for n = 0 to block.vertices {
vertex_list.set(
n,
block.vertex[n]:x * block.scale_x,
block.vertex[n]:y * block.scale_y,
block.vertex[n]:z * block.scale_z );
}

/* Scale the origin as well */
block.origin:x = block.origin:x * block.scale_x;
block.origin:y = block.origin:y * block.scale_y;
block.origin:z = block.origin:z * block.scale_z;

/* Scale the location of the block */
if (block.scale_x gt 1) {
block.location:x = block.location:x - block.origin:x;
}
if (block.scale_y gt 1) {
block.location:y = block.location:y - block.origin:y;
}
if (block.scale_z gt 1) {
block.location:z = block.location:z - block.origin:z;
}

/* Pop the new set of vertices */
block.set_vertices(vertex_list);
</function>
</define>

<!-- AT START, SCALE AND POSITION BLOCKS -->
<define>
<function name="start">
block = map.get_block(".#");
scaleblock(block);
block.location:y = 256;
</function>
</define>

<level number="1">
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .# .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..
</level>

<level number="2">
</level>

<level number="3">
</level>

<entrance location="(11,6,1)" name="default" angle="180.0" />

</body>
</spot>



[This message has been edited by xuriel (edited 06-16-2002).]

ReginaG
Member
posted 05-02-2002 10:36 PM     Click Here to See the Profile for ReginaG     Edit/Delete Message Reply w/Quote
thanks, xuriel. i've been wanting to know that, too. how much can you scale a block? i see the number is 4.0 (i think), and the spots only 3 levels. do those two paramenters need to corrolate in any way?

xuriel
Member
posted 05-02-2002 10:51 PM     Click Here to See the Profile for xuriel     Edit/Delete Message Reply w/Quote
The size of the map and the scale of your block only matter in how you plan on interacting with the block.

The way the script works now, the block vertices are scaled by the factor you supply in <scale_x>, <scale_y>, and <scale_z>. That's block vertices, and not the 256-cube space that (most) blocks occupy.

So a full block scaled by 2 would be 512 x 512 x 512, but half block scaled by 2 would be 512 x 512 x 256. That means to stand atop the scaled full cube, you'd have to build your spot at least 2 levels (512 pixels) high, while to stand atop the scaled half block, you'd have to build the spot only 1 (256 pixels) high.

The 3 level spot and cube x 4 I used in the spot are incidental; I pulled the code out an existing spot.

[This message has been edited by xuriel (edited 05-02-2002).]

ReginaG
Member
posted 05-03-2002 12:42 AM     Click Here to See the Profile for ReginaG     Edit/Delete Message Reply w/Quote
kewl, that's making perfect sense. with this kind of elementary info it makes it more possible for us to use other's scripts. thanks...

now about this two blocks occupying the same space: when does that apply? does it have to be scripted in? or does it mean when a block is part of a scripted action you can still build on the block spaces it covers (as in scaling), or it moves across (as in uni's elevator). cause i see with uni's elevator the moving block will go right thru another as if it's not there.

ReginaG
Member
posted 05-04-2002 11:43 AM     Click Here to See the Profile for ReginaG     Edit/Delete Message Reply w/Quote
xuriel, just wanted to let you know i've tried this scaling script and it's amazing! i answered my own q, partially, about 2 blocks on one space, by seeing that if a block is scaled beside say a floor block oriented on it's edge, it does move into the space the floor block would normally occupy if it wasn't oriented.

which opens a world of wonderful possibilites in using the floor blocks as walls. thanks, again!

i'm just wondering, since i'm essentially cutting and pasting this code, if there's anything i need to look out for in placing blocks like this? it just seems sooo unnatural.

xuriel
Member
posted 05-04-2002 12:24 PM     Click Here to See the Profile for xuriel     Edit/Delete Message Reply w/Quote
Some blocks may need adjustments after scaling, depending on how your using them.

For example, if you want a block to be flush with the ground on level 1 of your spot, you'll may need to set the block location like this:

code:

block.location:y = 0;

ReginaG
Member
posted 05-04-2002 08:05 PM     Click Here to See the Profile for ReginaG     Edit/Delete Message Reply w/Quote
thanks, xuriel. i'll keep that in mind.

dan goober
Member
posted 05-14-2002 01:41 PM     Click Here to See the Profile for dan goober     Edit/Delete Message Reply w/Quote
wow xuriel!

thanks a lot, man. i get it! kewl! btw, what about using scaling to make a block shrink or
grow? just an idea. so sorry about the long delay

yours
dan goober

All times are PT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | Go to Flatland...

(c) copyright 1998-9 Flatland Online, Inc.

Powered by: Ultimate Bulletin Board, Version 5.42
© Infopop Corporation (formerly Madrona Park, Inc.), 1998 - 1999.