ploop
|
  |
| Joined: 01 Dec 2007 |
| Total Posts: 1601 |
|
|
| 21 Sep 2012 07:48 PM |
| Given three points, how do I make a trainge from them? I am lost. |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
| |
|
ploop
|
  |
| Joined: 01 Dec 2007 |
| Total Posts: 1601 |
|
|
| 21 Sep 2012 07:53 PM |
| How do I make a script make a perfect fit inside them? |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 21 Sep 2012 08:33 PM |
http://www.roblox.com/Triangle-Function-item?id=80063544
Very well commented so you should be able to follow the code. |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 21 Sep 2012 08:36 PM |
@Ray, I think he means 3 parts that connect to make a triangle...o.O |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2012 08:37 PM |
function Triangle(V1, V2, V3) local pos = {V1, V2, V3, V1} local mags = {(V1-V2).magnitude, (V2-V3).magnitude, (V3-V1).magnitude} for i = 1, 3 do local p = Instance.new("Part", workspace) p.Anchored = true p.Size = Vector3.new(1, 1, mags[i]) p.CFrame = CFrame.new(pos[i]:lerp(pos[i+1], 0.5), pos[i+1]) end end
Triangle( Vector3.new(1,1,1), Vector3.new(10,10,10), Vector3.new(7,8,2) ) |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 21 Sep 2012 09:40 PM |
| Why would you want an empty triangle? |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 21 Sep 2012 09:41 PM |
@Ray, idk... :c You also just put like... two wedges next to each other, it's neat how you define the 3 Vectors, but you could just like...take two wedges and do that... :c..... |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
| |
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 21 Sep 2012 09:45 PM |
@Ray From my post: two wedges From yours: two wedges ???? |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 21 Sep 2012 09:49 PM |
Are you not talking about my script...?
The reason my script uses 3 vertices to define the triangle is so that you can create terrain or other things with it. If I still had the link to my terrain generator on SDuke524 I'd show you... |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 21 Sep 2012 09:54 PM |
@Ray, Didn't spend a lot of time looking at it, might tomorrow |
|
|
| Report Abuse |
|
|
rayoma
|
  |
| Joined: 13 Nov 2009 |
| Total Posts: 1911 |
|
|
| 22 Sep 2012 12:05 AM |
To make it clearer to you how powerful the function is, I made this quick example mama
--colors a brick perdy colors function color(p) if p.Position.Y>50 then p.BrickColor=BrickColor.new("Camo"); elseif p.Position.Y>5 then p.BrickColor=BrickColor.new("Bright green"); else p.BrickColor=BrickColor.new("Cool yellow"); end end --sploch terrain generator local sploches=10;--number of sploches to be used local sploch_radius=15;--radius of one sploch local sploch_height=20;--max height of one sploch local xSize=50;--width local ySize=50;--length local map={};--the map of the terrain --default the map to 0's for y=-ySize/2,ySize/2 do map[y]={}; for x=-xSize/2,xSize/2 do map[y][x]=0; end end --for every sploch, build up the map in a hill at random spot for _=1,sploches do local c=Vector2.new(math.random(-xSize/2,xSize/2),math.random(-ySize/2,ySize/2));--center of sploch --for all of the surrounding points for x=c.x-sploch_radius,c.x+sploch_radius do for y=c.y-sploch_radius,c.y+sploch_radius do --is it in the map? if x<=xSize/2 and x>=-xSize/2 and y<=ySize/2 and y>=-ySize/2 then local v=Vector2.new(x,y);--the current node --build up point based on distance from map[y][x]=map[y][x]+( (v-c).magnitude<=sploch_radius and (1-(v-c).magnitude/sploch_radius)*sploch_height or 0 ); end end end end --build terrain based on points for x=-xSize/2,xSize/2 do Wait(); for y=-ySize/2,ySize/2 do if map[y+1] and map[y][x+1] then local t0=triangle( Vector3.new(x*10,map[y][x],y*10), Vector3.new((x+1)*10,map[y][x+1],y*10), Vector3.new(x*10,map[y+1][x],(y+1)*10) ); for _,v in pairs(t0:GetChildren()) do color(v); end t0.Parent=workspace; local t1=triangle( Vector3.new((x+1)*10,map[y+1][x+1],(y+1)*10), Vector3.new((x+1)*10,map[y][x+1],y*10), Vector3.new(x*10,map[y+1][x],(y+1)*10) ); for _,v in pairs(t1:GetChildren()) do color(v); end t1.Parent=workspace; end end end --water local b=Instance.new("Part",workspace); b.Anchored=true; b.CanCollide=true; b.BrickColor=BrickColor.new("Bright blue"); b.Transparency=0.5; b.Size=Vector3.new(xSize*10,0.2,ySize*10); b.CFrame=CFrame.new(0,3,0); |
|
|
| Report Abuse |
|
|