mcjFakeNests

Introduction 

The output of a very quickly made Daz Script that produces fake nests in obj format

as you can see there's a few hay strands that float ... so you'll have to fix or conceal this




here is the Daz Script i used
Only use if if you know exactly what's going on here
notably : you have to manually change the file path for the output .obj file

// DAZ Studio version 4.9.2.70 filetype DAZ Script
var THETARGETFILEPATH = "i:/snowtrick/mcjHayBlade2c.obj";

function makeBlade( file, xc, zc, off, w, h, thick, ray, azim, altit )
{
	var xm = xc - 1;
	var zm = zc - 1;
	var xstep = 1 / xm;
	var zstep = 1 / zm;
	var xoff = off;
	var ox = Math.cos(azim) * ray;
	var oz = Math.sin(azim) * ray;
	var zz = -0.5;
	for( z = 0; z < zc; z++ )
	{
		xx = -0.5;
		randomx = Math.random();
		for( x = 0; x < xc; x++ )
		{
			var y = roof( x, xm );
			var xTaper = strait( z, zm );
			var coordX = randomx + ( xTaper * w * xx );
			var coordY = ( altit + y * thick );
			var coordZ = ( h * zz );
			var v = getAzimuted( coordX, coordZ, azim );
			file.writeLine( "v " + ( ox + v.x ) + " " + coordY + " " + ( oz + v.z ) );
			++xoff;
			file.writeLine( "vt " + x/xm + " " + z/zm );
			xx += xstep;
		}
		zz += zstep;
	}
	xoff = off;
	for( z = 0; z < zm; z++ )
	{
		for( x = 0; x < xm; x++ )
		{
			a = xoff;
			b = xoff + 1;
			c = b + xc;
			d = a + xc;
			file.writeLine( "f " + a + "/" + a + " " + b + "/" + b + " " + c + "/" + c + " " + d + "/" + d );
			++xoff;
		}
		xoff++;
	}
	return( c + 1 );
}

//==============================================================================
//
//==============================================================================
function getAzimuted( x, y, a )
{
	var r = Math.sqrt( x * x + y * y );
	var na = Math.atan2( y, x );
	na -= a;
	na += Math.PI / 2
	var nx = Math.sin( na ) * r;
	var nz = Math.cos( na ) * r;
	return( DzVec3( nx, 0, nz ) ); 
}

//==============================================================================
//
//==============================================================================
function roof( x, xm )
{
	var mid = x / xm;
	var nx = 2 * Math.abs( mid - 0.5 );
	return( 1 - nx ); 
}

//==============================================================================
//
//==============================================================================
function strait( x, xm )
{
	return( 1 ); 
}

//==============================================================================
// m a i n 
//==============================================================================

var file = new DzFile( THETARGETFILEPATH );
file.open( file.WriteOnly );
var idx = 1;
for( var i = 0; i < 1000; i++ )
{
	var ray = Math.random() * 10;
	var azim = Math.random() * 2 * Math.PI;
	var altit = ray / 5 + Math.random() * 2;
	//file, xc, zc, off, w, h, thick, ray, azim, altit
	idx = makeBlade( file, 4, 4, idx, .2, 10, .2, ray, azim, altit );
}
file.close();
ċ
mcjFiveFakeNests.zip
(2068k)
mCasual Jacques,
Dec 3, 2016, 8:34 PM
Comments