Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Trading Journey
by 7th_zorro. 04/27/24 04:42
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, 1 invisible), 770 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Another Terrain Sewing Solution #53533
08/29/05 03:36
08/29/05 03:36
Joined: Jun 2005
Posts: 656
G
Grafton Offline OP
User
Grafton  Offline OP
User
G

Joined: Jun 2005
Posts: 656
Here is some code I have used to sew terrains together that works well.
One function sews top/bottom and the other sews left/right. The code is
pretty self explanatory. I used this on MDLs not HMPs, but I dont think
it makes a difference. I hope this helps someone

Code:
 

//two functions to sew seams together in MDL tiles
//models must not have the same file name or be duplicates!
//models must have the same number of verts along each side to be sewn
//the #1 vert is upper right in med, lower left in 3dsmax
//set the matrix variable in each sew function to the number of verts along a side.
//
//


function sew_top_to_bottom(ent1,ent2) // sew top of ent1 to the bottom of ent2
{
my = ent1;
you = ent2;

var matrix = 51; //<< set this to the amount of vertices along your models side
var vpos;
var vpos2;
var i=0;

while(i<matrix)
{
i+=1;
vec_for_mesh(vpos,my,i); //my top row
vec_for_mesh(vpos2,you,matrix*(matrix-1) + i);//your bottom row
vpos.z += (vpos2.z + you.z/you.scale_z) - (vpos.z + my.z/my.scale_z);
vpos.x += (vpos2.x + you.x/you.scale_x) - (vpos.x + my.x/my.scale_x);
vpos.y += (vpos2.y + you.y/you.scale_y) - (vpos.y + my.y/my.scale_y);
vec_to_mesh(vpos,my,i); //move my top row vert
}
}

//
function sew_left_to_right(ent1,ent2) // sew left of ent1 to the right of ent2
{
my = ent1;
you = ent2;

var matrix = 51; //<< set this to the amount of vertices along your models side
var vpos;
var vpos2;
var i=0;

while(i<matrix)
{
i+=1;
vec_for_mesh(vpos,my,matrix*i-(matrix-1)); //my left edge
vec_for_mesh(vpos2,you,matrix*i); //your right edge
vpos.z += (vpos2.z + you.z/you.scale_z) - (vpos.z + my.z/my.scale_z);
vpos.x += (vpos2.x + you.x/you.scale_x) - (vpos.x + my.x/my.scale_x);
vpos.y += (vpos2.y + you.y/you.scale_y) - (vpos.y + my.y/my.scale_y);
vec_to_mesh(vpos,my,matrix*i-(matrix-1)); //move my left edge vert
}
}

// Assuming there are nine entity tiles to be sewn together, named terrain1 to terrain9
// that are arranged 3x3 from left to right;
//
// 1 2 3
// 4 5 6
// 7 8 9
//
// we can sew them all together like this;
//


function init_terrain()
{
sew_top_to_bottom(terrain4,terrain1); //sew top of ent1 to bottom of ent2
sew_top_to_bottom(terrain5,terrain2);
sew_top_to_bottom(terrain6,terrain3);
sew_top_to_bottom(terrain7,terrain4);
sew_top_to_bottom(terrain8,terrain5);
sew_top_to_bottom(terrain9,terrain6);
//
sew_left_to_right(terrain2,terrain1); //sew left side of ent1 to right side of ent2
sew_left_to_right(terrain3,terrain2);
sew_left_to_right(terrain5,terrain4);
sew_left_to_right(terrain6,terrain5);
sew_left_to_right(terrain8,terrain7);
sew_left_to_right(terrain9,terrain8);
}




Not two, not one.
Re: Another Terrain Sewing Solution [Re: Grafton] #53534
06/19/07 04:56
06/19/07 04:56
Joined: Jun 2005
Posts: 656
G
Grafton Offline OP
User
Grafton  Offline OP
User
G

Joined: Jun 2005
Posts: 656
Still works with A7!


Not two, not one.
Re: Another Terrain Sewing Solution [Re: Grafton] #53535
06/19/07 05:46
06/19/07 05:46
Joined: Jul 2002
Posts: 5,181
Austria
Blattsalat Offline
Senior Expert
Blattsalat  Offline
Senior Expert

Joined: Jul 2002
Posts: 5,181
Austria
thanks a ton!
was about to write one today for myself. your mind reading skills came quite handy

thanks and i will try it asap
cheers


Models, Textures and Levels at:
http://www.blattsalat.com/
portfolio:
http://showcase.blattsalat.com/
Re: Another Terrain Sewing Solution [Re: Blattsalat] #53536
06/19/07 09:17
06/19/07 09:17
Joined: Aug 2005
Posts: 1,558
HK
V
vlau Offline
Serious User
vlau  Offline
Serious User
V

Joined: Aug 2005
Posts: 1,558
HK
Looks great! Will try it later.
Thanks for your contribution.

Re: Another Terrain Sewing Solution [Re: vlau] #53537
06/19/07 14:29
06/19/07 14:29
Joined: Feb 2006
Posts: 2,185
mpdeveloper_B Offline
Expert
mpdeveloper_B  Offline
Expert

Joined: Feb 2006
Posts: 2,185
familiar code there, but nice job


- aka Manslayer101
Re: Another Terrain Sewing Solution [Re: mpdeveloper_B] #53538
06/19/07 17:40
06/19/07 17:40
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Why not throw the "matrix" var out of the function and pass it as parameter instead?
That way the developer does not have to adjust the code for each terrain and he can use it in multiple levels with different terrains:
Code:

function sew_top_to_bottom(ent1,ent2,matrix) // sew top of ent1 to the bottom of ent2
{
my = ent1;
you = ent2;

var vpos;
var vpos2;
var i=0;

while(i < matrix)
{
i+=1;
vec_for_mesh(vpos,my,i); //my top row
vec_for_mesh(vpos2,you,matrix*(matrix-1) + i);//your bottom row
vpos.z += (vpos2.z + you.z/you.scale_z) - (vpos.z + my.z/my.scale_z);
vpos.x += (vpos2.x + you.x/you.scale_x) - (vpos.x + my.x/my.scale_x);
vpos.y += (vpos2.y + you.y/you.scale_y) - (vpos.y + my.y/my.scale_y);
vec_to_mesh(vpos,my,i); //move my top row vert
}
}

//
function sew_left_to_right(ent1,ent2,matrix) // sew left of ent1 to the right of ent2
{
my = ent1;
you = ent2;

var vpos;
var vpos2;
var i=0;

while(i < matrix)
{
i+=1;
vec_for_mesh(vpos,my,matrix*i-(matrix-1)); //my left edge
vec_for_mesh(vpos2,you,matrix*i); //your right edge
vpos.z += (vpos2.z + you.z/you.scale_z) - (vpos.z + my.z/my.scale_z);
vpos.x += (vpos2.x + you.x/you.scale_x) - (vpos.x + my.x/my.scale_x);
vpos.y += (vpos2.y + you.y/you.scale_y) - (vpos.y + my.y/my.scale_y);
vec_to_mesh(vpos,my,matrix*i-(matrix-1)); //move my left edge vert
}
}



Re: Another Terrain Sewing Solution [Re: mpdeveloper_B] #53539
06/19/07 20:19
06/19/07 20:19
Joined: Jun 2005
Posts: 656
G
Grafton Offline OP
User
Grafton  Offline OP
User
G

Joined: Jun 2005
Posts: 656
Quote:

familiar code there, but nice job




Thanks Manslayer, Why is it familiar? The post is two years old, so maybe
you've seen it before?

Great Idea Thunder, I should have done it that way! This was ripped from a
project I was working on at the time and was customized for it.


Not two, not one.
Re: Another Terrain Sewing Solution [Re: Grafton] #53540
06/25/07 11:24
06/25/07 11:24
Joined: Jul 2001
Posts: 4,801
netherlands
Realspawn Offline

Expert
Realspawn  Offline

Expert

Joined: Jul 2001
Posts: 4,801
netherlands
Since this code is still fully functional i added it to the wdl library


Find all my tutorials & Workshops at : www.rp-interactive.nl

Creativity starts in the brain
Re: Another Terrain Sewing Solution [Re: Realspawn] #53541
06/25/07 22:50
06/25/07 22:50
Joined: Jun 2005
Posts: 656
G
Grafton Offline OP
User
Grafton  Offline OP
User
G

Joined: Jun 2005
Posts: 656
Great! I Should have thought to ask you about that!


Not two, not one.
Re: Another Terrain Sewing Solution [Re: Grafton] #53542
02/29/08 12:45
02/29/08 12:45
Joined: Sep 2003
Posts: 265
Coupeville,Wa,USA
Y
Yu_Une Offline
Member
Yu_Une  Offline
Member
Y

Joined: Sep 2003
Posts: 265
Coupeville,Wa,USA
sweet I've looking high and low for, since my old pc died, unfortunately I can't afford 3DSMax but I do have Blender 3D which does have 3DS extentions.

Last edited by Yu_Une; 03/01/08 11:00.

Windows Vista Ultimate
AMD Phonomn III X2
Biostar T series TA790GX A3+
AMD Radeon HD 4830 in SLI mode
8Gb DDR2 ram

3D Game Studio Commercial upgrade Edition 6.60

Never give up on your dreams.

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1