A Roblox Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

A Roblox Community

A community of Robloxians who want to learn to script and build on Roblox Studio.
 
HomeLatest imagesRegisterLog in
If you're a experienced coder make some tutorials! It would really help the site grow.
Make sure you read the rules(Which can be found by clicking here)
If you're a beginner at coding, try some tutorials.
We have many Moderators/Admins watching this site. Contact them with Questions.
Let us know what your favorite sport is. By clicking here to vote (Click here)
This site is becoming inactive. Lets make it active.
Log in
Username:
Password:
Log in automatically: 
:: I forgot my password
Top posters
blueymaddog
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
naknak
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
Supernapalm
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
m27frogy
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
slayer9365
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
myrco919
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
branefreez
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
ninga95
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
CloneTrooper787
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
raboy117
Terrain-Point Algorithm Vote_lcapTerrain-Point Algorithm Voting_barTerrain-Point Algorithm Vote_rcap 
Top posting users this month
No user
Latest topics
» Where to go from here.
Terrain-Point Algorithm EmptySeptember 14th 2020, 1:20 pm by MrNicNac

» Send me an Email
Terrain-Point Algorithm EmptySeptember 14th 2020, 1:16 pm by MrNicNac

» [v1.6.0.0] Lua Script Obfuscator [No Bytecode]
Terrain-Point Algorithm EmptyJuly 6th 2015, 7:38 pm by m27frogy

» New Site Possibly
Terrain-Point Algorithm EmptyJuly 6th 2015, 4:16 pm by m27frogy

» Ambassador!
Terrain-Point Algorithm EmptyApril 15th 2015, 11:40 pm by naknak

» Boop - Tag
Terrain-Point Algorithm EmptyApril 13th 2015, 9:46 pm by naknak

» Vip Class Script
Terrain-Point Algorithm EmptyApril 13th 2015, 4:54 pm by naknak

» Who's active?!
Terrain-Point Algorithm EmptyApril 13th 2015, 4:52 pm by naknak

» Genesis Point
Terrain-Point Algorithm EmptyJuly 17th 2014, 7:04 pm by branefreez

» Reward System
Terrain-Point Algorithm EmptyJuly 17th 2014, 5:41 am by m27frogy

» Script Request
Terrain-Point Algorithm EmptyJuly 10th 2014, 11:43 am by naknak

» local scripts?
Terrain-Point Algorithm EmptyJuly 10th 2014, 11:39 am by naknak

» Project: Reconstruction [Died]
Terrain-Point Algorithm EmptyJuly 10th 2014, 11:36 am by naknak

» Hi. I am new here
Terrain-Point Algorithm EmptyApril 26th 2014, 4:01 pm by altshiftkey

» What's your favorite sport?
Terrain-Point Algorithm EmptyJanuary 1st 2014, 2:13 pm by m27frogy

» FlashLight Script
Terrain-Point Algorithm EmptyJanuary 1st 2014, 2:11 pm by m27frogy

» Gun Making! [READ DESC]
Terrain-Point Algorithm EmptyJanuary 1st 2014, 2:10 pm by m27frogy

» Hi, I am new here!
Terrain-Point Algorithm EmptyNovember 26th 2013, 3:33 pm by Keanu73

» Improve Coding
Terrain-Point Algorithm EmptyOctober 26th 2013, 1:12 pm by pook03

» Simple Button
Terrain-Point Algorithm EmptySeptember 1st 2013, 6:19 pm by branefreez


 

 Terrain-Point Algorithm

Go down 
3 posters
AuthorMessage
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 6th 2011, 5:28 pm

Using the function below, how could I find a decent way to generates points, so that when the triangles are draw (using the points as vertices), it would create some terrain?

Code:
local ply = Instance.new("WedgePart")
ply.formFactor = "Custom"
ply.TopSurface = 0
ply.BottomSurface = 0
ply.Anchored = true
ply.Size = Vector3.new(0.2,7,7)

local msh = Instance.new("SpecialMesh")
msh.MeshType = 2
msh.Parent = ply

function ParaD(a, b, c)
   local dot = (b-a).x*(c-a).x + (b-a).y*(c-a).y + (b-a).z*(c-a).z
   return dot / (a-b).magnitude
end

function PerpD(a, b, c)
   local par = ParaD(a, b, c)
   return math.sqrt((c-a).magnitude^2 - par^2)
end

local _P0, _P1 = nil, nil

function DrawTriangle(vec1, vec2, vec3)
   local A, B, C = nil, nil, nil
   local p0, p1 = ply:clone(), ply:clone()
   _P0 = p0
   _P1 = p1
   local s1 = (vec1 - vec2).magnitude
         s2 = (vec2 - vec3).magnitude
         s3 = (vec3 - vec1).magnitude
   local smax = math.max(s1, s2, s3)
   if (vec1 - vec2).magnitude == smax then
      A = vec1
      B = vec2
      C = vec3
   elseif (vec2 - vec3).magnitude == smax then
      A = vec2
      B = vec3
      C = vec1   
   elseif (vec3 - vec1).magnitude == smax then
      A = vec3
      B = vec1
      C = vec2   
   end
   local perp = PerpD(A, B, C)
   local para = ParaD(A, B, C)
   local dif_para = (A-B).magnitude - para   
   local ambig = false
   p0.Mesh.Scale = Vector3.new(0.1, 1,1)
   p0.Size = Vector3.new(.2, perp, para)
   p0.CFrame = CFrame.new(B, A)
   local Top_Look = (p0.CFrame * CFrame.fromEulerAnglesXYZ(math.pi/2, 0, 0)).lookVector
   local Mid_Point = A + CFrame.new(A, B).lookVector * para
   local Needed_Look = CFrame.new(Mid_Point, C).lookVector
   local dot = Top_Look.x*Needed_Look.x + Top_Look.y*Needed_Look.y + Top_Look.z*Needed_Look.z
   p0.CFrame = p0.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, math.acos(dot))
   if ((p0.CFrame * CFrame.fromEulerAnglesXYZ(math.pi/2, 0, 0)).lookVector - Needed_Look).magnitude > 0.01 then
      p0.CFrame = p0.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, -2*math.acos(dot))
      ambig = true
   end
   p0.CFrame = p0.CFrame * CFrame.new(0, perp/2, -(dif_para + para/2))   
   p0.Parent = tmodel
   p0.Name = "P0"
   p1.Mesh.Scale = Vector3.new(0, 1,1)
   p1.Size = Vector3.new(.2, perp, dif_para)
   p1.CFrame = CFrame.new(B, A)  * CFrame.fromEulerAnglesXYZ(0, 0, math.acos(dot)) * CFrame.fromEulerAnglesXYZ(0, math.pi, 0)
   if ((p1.CFrame * CFrame.fromEulerAnglesXYZ(math.pi/2, 0, 0)).lookVector - Needed_Look).magnitude > 0.01 then
      p1.CFrame = p1.CFrame * CFrame.fromEulerAnglesXYZ(0, 0, 2*math.acos(dot))
      ambig = true
   end
   p1.CFrame = p1.CFrame * CFrame.new(0, perp/2, dif_para/2)
   p1.Parent = tmodel
   p1.Name = "P1"
   --p0.Mesh.Scale = p0.Mesh.Scale * 0.145714286
   --p1.Mesh.Scale = p1.Mesh.Scale * 0.145714286
end


Last edited by MrNicNac on March 7th 2011, 9:59 pm; edited 1 time in total
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 6th 2011, 10:03 pm

I'm not sure. How would you make a triangle in the first place with pieces?
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 7th 2011, 8:05 am

I already have them made. There is a function in the code to do so.
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 7th 2011, 10:15 am

Great, now you made me want to go mess with the triangle.
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 7th 2011, 10:25 am

It's quite entertaining, I've made a tool and a place that uses them together to build while online.
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 7th 2011, 10:28 am

So, what your trying to do is make the triangle big enough to fill the drawn triangle?
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 7th 2011, 10:29 am

No no, that is all done. I just want to generate points so I can draw the triangles to look like mountains or something.
Back to top Go down
naknak
Administrator
Administrator
naknak


Posts : 878
Join date : 2010-07-30

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 7th 2011, 10:32 am

I know somebody made something like that, just I don't think it was with triangles and it was just a randomized terrain.
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 7th 2011, 7:41 pm

A lot of people made random terrain, xLEGOx did a random terrain with triangles (the main way to make decent terrain).
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 8th 2011, 6:37 am

maybe have the points generate randomly as long as it's within a certain height to the lowest and highest points adjacent to the point.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 8th 2011, 6:39 am

I was thinking of making one of these map generators myself!
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 8th 2011, 8:17 am

Sorry, but that didn't make any sense at all.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 9th 2011, 6:21 am

every time you generate a point you make it generate at a random height in-between the lowest and highest points next to the point. make more sense?
Back to top Go down
Guest
Guest
avatar



Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 9th 2011, 12:24 pm

Yeah Blue's way is rather efficient. I use it in my terrain generator, although since mine is row-based rather than 2D-based, it isn't as good as it could be.
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 9th 2011, 7:40 pm

blueymaddog wrote:
every time you generate a point you make it generate at a random height in-between the lowest and highest points next to the point. make more sense?

You obviously don't understand an algorithm that should be used here. I figured it should be the Diamond-Square algorithm for random triangle-based terrain. I decided to ask the Scripters on Roblox. Interesting results are being turned up.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 10th 2011, 6:52 am

link to thread please, MNN?
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 10th 2011, 8:51 am

Here is the link.


Last edited by naknak on March 10th 2011, 11:30 pm; edited 1 time in total (Reason for editing : made it work.)
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 11th 2011, 6:39 am

lol, so your asking me how you should generate the points on the terrain generater and I give my suggestion. then you say that you should use the 'diamond-square' algorithm. :P
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 11th 2011, 8:03 am

An algorithm is a solution, your "algorithim" was no where near a solution to keep the terrain smooth and actually look like terrain.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 11th 2011, 5:38 pm

then get the average of all the point's positions and make it randomize roughly around the average. :P
Back to top Go down
MrNicNac
Expert Scripter
Expert Scripter
MrNicNac


Posts : 27
Join date : 2011-03-06
Age : 28

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 11th 2011, 6:29 pm

I already have a solution.
Back to top Go down
blueymaddog
Administrator
Administrator
blueymaddog


Posts : 1081
Join date : 2010-12-09
Age : 25

Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm EmptyMarch 14th 2011, 5:49 am

k.
Back to top Go down
Sponsored content





Terrain-Point Algorithm Empty
PostSubject: Re: Terrain-Point Algorithm   Terrain-Point Algorithm Empty

Back to top Go down
 
Terrain-Point Algorithm
Back to top 
Page 1 of 1
 Similar topics
-
» Genesis Point

Permissions in this forum:You cannot reply to topics in this forum
A Roblox Community :: Questions and Help :: Scripting-
Jump to: