*

*
  • Home
  • About Us
  • Gallery
  • Forum
  • Recent Discussions
  • Categories
Welcome, Guest
Please Login or Register.    Lost Password?
Skyhighatry Forum
Developer's Corner
Anjin's Code Dumps

Rolling a Plane type Sculpt map into a Cylinder
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: Rolling a Plane type Sculpt map into a Cylinder
Forum Tools
  • Post New Topic
  • Pdf
  • Show latest posts
#34
Rolling a Plane type Sculpt map into a Cylinder 3 Years, 8 Months ago Karma: 0
So you made a nifty bas relief of some coolio stones. And now you want to use that in yer builds, but it would be handy to have one that's a bit rounder....

One way is to take the flat plane and roll it up into a cylinder.

This code snippit does this. The idea is to plot the values from the plane, around a circle, for each slice of the sculpt map.

This code assumes that the sculpt map is saved in PPM ASCII format. I am using AWK as its a clean protocode. So it should be usable in most any language.

This code takes the Z value, and encodes it into the X,Y values based on a simple sin/cos calculation. The Z value adjusts the Radius length used to calculate the point. This bends the height map around the curve!

Code:

#!/usr/local/bin/gawk -f
#
BEGIN {
        print "P3 256 256 255" ;
        PI = 3.1415926535897932384626433832795 ;
        DEG_TO_RAD = PI / 180 ;

        deg = ( 360 / 256 ) ;
        radius = ( 256 / PI ) / 2 ;
        dia = radius*2 ;

        while( getline tstr < "test.ppm" > 0 ) {
                tcnt = tcnt + 1 ;
                if( tcnt > 1 ) {
                        split( tstr, tary, " " ) ;
                        x = tary[1] ;
                        y = tary[2] ;
                        z = tary[3] / 20  ;
                        rads = ( deg * y ) * DEG_TO_RAD ;
                        r = radius + z ;
                        x = (r*sin(rads))+127.5 ;
                        y = (r*cos(rads))+127.5 ;
                        printf "%s %s %s\n",int(x)-1,int(y)-1,tary[1] ;

                        }
                }

        }

Anjin (Admin)
Admin
Posts: 27
graph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1
Skyhighatry Forum
Developer's Corner
Anjin's Code Dumps
Powered by Kunenaget the latest posts directly to your desktop
Main Menu
  • Home
  • News
  • Gallery
  • Forum
  • Links
  • Sitemap
Projects
  • Sculpt Studio
  • Skyhighatry Rockshop
  • Skyhighatry.com
Calendars
  • SL Grid Status
User Admin



  • Forgot your password?
  • Forgot your username?

Copyright © 2009 Skyhighatry Designs Creative Commons License
Skyhighatry.com by Elzbiet Meili is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
"Second LifeĀ® and the inSL logo are trademarks of Linden Research, Inc. Skyhighatry Designs is not affiliated with or sponsored by Linden Research.
Permissions beyond the scope of this license may be available at http://www.skyhighatry.com/.
All Rights Reserved.