public override void Voxelize(World world) { // HERE: Fill the world with your data // Use world.SetBlock(), etc. // Beaware of the Bounds of the root node, which can be set in the NodeGraph Editor. // NO modifications outside the bound. int index; for (index = 0; index < (spline.Count - 1); index++) { TestTree.FillCyclinder( world, block, spline[index].position, spline[index + 1].position, spline[index].radius, spline[index + 1].radius, spline[index].rotation * Vector3.up, spline[index + 1].rotation * Vector3.up ); //break; } }
public override void Express( World world, ref FractalRenderState state ) { ///////////////////// //树叶的情况 ///////////////////// float leaveRadius = 4.0f * startGrowRate / 24.0f; uint blk = branchBlock; if (branchType == BranchType.Leaves) { TestTree.FillLeaf(world, leafRenderingSetup, state.position + state.scale * centerPos, state.scale * Mathf.Min(growRate * 0.31f, 3.0f) * MathCore.RandomRange(random, 3.0f, 5.0f)); //Debug.Log(growRate); //Debug.Log("Using green branch as leaves"); } else { ///////////////////// //树枝的情况 ///////////////////// /* * 按圆柱表面坐标系上点的坐标给点标号。圆为横轴,高为纵轴。 * 顶点(x,y)坐标: * rad = x * (2f * Mathf.PI / circleFragments); * Vertex = (cos(rad) * radius, y * heightStep, sin(rad) * radius); * 顶点(x,y)法线: * rad = x * (2f * Mathf.PI / circleFragments); * Normal = (cos(rad), 0, sin(rad)) * 构成整个子结构的面: * for(x = 0; x < circleFragments - 1; x++) * for(y = 0; y < heightFragments - 1; y++) * Indices = ( x, y ) ( x + 1, y + 1 ) ( x + 1, y ); ( x, y ) ( x , y + 1 ) ( x + 1, y + 1 ) * * 不封口。反正也看不见( */ //绘制 int vert = 0, x, index; float rad, radiusReal; for (index = 0; index < (spline.Count - 1); index++) { TestTree.FillCyclinder( world, blk, (state.rotation * (state.scale * spline[index].position)) + state.position, (state.rotation * (state.scale * spline[index + 1].position)) + state.position, state.scale * spline[index].radius, state.scale * spline[index + 1].radius, state.rotation * (spline[index].rotationGlobal * Vector3.up), state.rotation * (spline[index + 1].rotationGlobal * Vector3.up) ); //break; } } //state.centerPos = Vector3.zero; //state.rotation = Quaternion.identity; }