public override void InitIvy(RuntimeGrowthParameters growthParameters, IvyContainer ivyContainer, IvyParameters ivyParameters) { this.growthParameters = growthParameters; Init(null, ivyParameters); InitMeshBuilder(); AddFirstBranch(); }
private void SetUpMaxBranches(IvyContainer ivyContainer) { maxBranches = ivyParameters.maxBranchs; if (ivyContainer != null) { maxBranches = Mathf.Max(ivyParameters.maxBranchs, ivyContainer.branches.Count); } }
public void Initialize(IvyContainer ivyContainer, IvyParameters ivyParameters, GameObject ivyGO, RTMeshData[] leavesMeshesByChosenLeaf, Vector3 firstVertexVector) { lastBranchNumberAssigned = 0; this.branches = new List <RTBranchContainer>(ivyContainer.branches.Count); for (int i = 0; i < ivyContainer.branches.Count; i++) { RTBranchContainer rtBranch = new RTBranchContainer(ivyContainer.branches[i], ivyParameters, this, ivyGO, leavesMeshesByChosenLeaf); this.branches.Add(rtBranch); } this.firstVertexVector = firstVertexVector; }
protected override void Init(IvyContainer ivyContainer, IvyParameters ivyParameters) { base.Init(ivyContainer, ivyParameters); rtIvyGrowth = new RuntimeIvyGrowth(); rtIvyGrowth.Init(rtIvyContainer, ivyParameters, gameObject, leavesMeshesByChosenLeaf, GetMaxNumPoints(), GetMaxNumLeaves(), GetMaxNumVerticesPerLeaf()); for (int i = 0; i < 10; i++) { rtIvyGrowth.Step(); } this.currentLifetime = this.growthParameters.lifetime; }
/* public void InitIvy(RuntimeGrowthParameters growthParameters, IvyContainer ivyContainer, * IvyParameters ivyParameters) * { * this.growthParameters = growthParameters; * Init(ivyContainer, ivyParameters); * AddFirstBranch(); * } */ protected virtual void Init(IvyContainer ivyContainer, IvyParameters ivyParameters) { this.rtIvyContainer = new RTIvyContainer(); this.ivyParameters = new IvyParameters(); this.ivyParameters.CopyFrom(ivyParameters); CreateLeavesDict(); if (ivyContainer != null) { this.rtIvyContainer.Initialize(ivyContainer, ivyParameters, gameObject, leavesMeshesByChosenLeaf, ivyContainer.firstVertexVector); } else { this.rtIvyContainer.Initialize(); } SetUpMaxBranches(ivyContainer); activeBakedBranches = new List <RTBranchContainer>(maxBranches); activeBuildingBranches = new List <RTBranchContainer>(maxBranches); rtBuildingIvyContainer = new RTIvyContainer(); Vector3 firstVertexVector = ivyContainer == null?CalculateFirstVertexVector() : ivyContainer.firstVertexVector; rtBuildingIvyContainer.Initialize(firstVertexVector); lastIdxActiveBranch = -1; leafLengthCorrrectionFactor = 1; int submeshCount = ivyParameters.leavesPrefabs.Length + 1; this.processedMesh = new Mesh(); processedMesh.subMeshCount = submeshCount; mfProcessedMesh.sharedMesh = processedMesh; this.refreshProcessedMesh = false; this.backtrackingPoints = GetBacktrackingPoints(); if (this.bakedMesh == null) { this.bakedMesh = new Mesh(); this.bakedMesh.subMeshCount = submeshCount; } /* meshBuilder = new RTBakedMeshBuilder(rtIvyContainer, gameObject); * meshBuilder.InitializeMeshBuilder(ivyParameters, rtBuildingIvyContainer, rtIvyContainer, * gameObject, bakedMesh, meshRenderer, meshFilter, maxBranches, * processedMesh, growthParameters.growthSpeed, mrProcessedMesh, * backtrackingPoints, submeshByChoseLeaf, leavesMeshesDict, leavesMaterials.ToArray()); */ lastCopiedIndexPerBranch = new List <int>(maxBranches); leavesToCopyMesh = new List <LeafPoint>(50); srcPoints = new List <Vector3>(maxBranches); dstPoints = new List <Vector3>(maxBranches); growingFactorPerBranch = new List <float>(maxBranches); srcTotalLengthPerBranch = new List <float>(maxBranches); dstTotalLengthPerBranch = new List <float>(maxBranches); lengthPerBranch = new List <float>(maxBranches); for (int i = 0; i < maxBranches; i++) { srcPoints.Add(Vector3.zero); dstPoints.Add(Vector3.zero); growingFactorPerBranch.Add(0f); srcTotalLengthPerBranch.Add(0f); dstTotalLengthPerBranch.Add(0f); lastCopiedIndexPerBranch.Add(-1); lengthPerBranch.Add(0f); int branchPointsSize = GetMaxNumPoints(); int numLeaves = GetMaxNumLeaves(); RTBranchContainer branchContainer = new RTBranchContainer(branchPointsSize, numLeaves); activeBuildingBranches.Add(branchContainer); } }
public abstract void InitIvy(RuntimeGrowthParameters growthParameters, IvyContainer ivyContainer, IvyParameters ivyParameters);
public void InitIvyEditor(RuntimeGrowthParameters growthParameters, IvyContainer ivyContainer, IvyParameters ivyParameters) { this.growthParameters = growthParameters; Init(ivyContainer, ivyParameters); }
protected override void Init(IvyContainer ivyContainer, IvyParameters ivyParameters) { base.Init(ivyContainer, ivyParameters); CalculateLifetime(); }