Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Make a flat hexagon plane?

Author
Message
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 22nd Jan 2014 14:24
I see that we have flat 2D plane squares....anyway to make a 2D hexagon shape with equal length sides?

Home is where my souped-up computer is...
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jan 2014 15:26
You could use tryangles . An easy way could be this:



Cheers.

I'm not a grumpy grandpa
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 22nd Jan 2014 15:46
I tried that....it's hard to keep a texture from looking skewed

Home is where my souped-up computer is...
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 22nd Jan 2014 16:08 Edited at: 22nd Jan 2014 16:32
Try this:


I'm not a grumpy grandpa
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 22nd Jan 2014 16:53 Edited at: 22nd Jan 2014 16:58
You could add triangle limbs to an object with the correct angles and proportions then save out as a mesh.

2-Triangle sample:



If you can't get your texture to look right your object may require UV mapping.

JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 23rd Jan 2014 14:16
I got the hexagon just right in size and shape. Now the texture is repeating on the 3 shapes. Here's the code:




so close, yet so FAR away-

Home is where my souped-up computer is...
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 23rd Jan 2014 15:04
@JoeOh

Here is your code with some extra-lines to texture object.



I'm not a grumpy grandpa
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 23rd Jan 2014 21:31
I snatched this code from a project I'm working on.


Hope it helps!

Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
JoeOh
17
Years of Service
User Offline
Joined: 25th Feb 2009
Location:
Posted: 24th Jan 2014 17:58
I finally got this into a reusable function



Yippie! Thanks all!

Home is where my souped-up computer is...
MonoCoder
20
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 27th Jan 2014 15:07 Edited at: 27th Jan 2014 19:15
Although you seem to have found your answer, I'd like to share a more generalised function that can build a hexagon, plus any n-sided regular polygon disc (innerRadius=0) or doughnut-shape (innerRadius>0).

Params
objId is the object to make.
innerRadius is the radius of the centre hole.
outerRadius is the radius at the outer edge.
numSides should be 3 or greater.
angularOffset spins the shape clockwise without disturbing the texture (ie. the texture is left-to-right along +ve x axis and bottom-to-top along +ve z axis). When angularOffset=0, The 0th vertex points from the centre along +ve x. When 90, it points along -ve z, etc.

note that when innerRadius=0, the function does not optimise-out the centre hole. It can be modified to do that though.
in comparison with your posted solution, this makes the shape lay flat on the floor rather than stand up. It also has the texture show correct looking down +ve z, whereas yours is correct looking down -ve z.

It requires IanM's Matrix1Utils plugin.

Edit: added angularWidth param, which allows you to dial back from a full circle (=360) to a sub-sector (<360). For example, 90 makes what looks like a right-angled track corner.

Here is the function:



And here's it in an example:





Login to post a reply

Server time is: 2026-07-07 11:20:54
Your offset time is: 2026-07-07 11:20:54