예제 #1
0
		private void SetOutputVisiblity(HEU_LoadBufferBase buffer)
		{
			bool bVisibility = !buffer._bInstanced;

			if (HEU_GeneratedOutput.HasLODGroup(buffer._generatedOutput))
			{
				foreach (HEU_GeneratedOutputData childOutput in buffer._generatedOutput._childOutputs)
				{
					HEU_GeneralUtility.SetGameObjectRenderVisiblity(childOutput._gameObject, bVisibility);
					HEU_GeneralUtility.SetGameObjectColliderState(childOutput._gameObject, bVisibility);
				}
			}
			else
			{
				HEU_GeneralUtility.SetGameObjectRenderVisiblity(buffer._generatedOutput._outputData._gameObject, bVisibility);
				HEU_GeneralUtility.SetGameObjectColliderState(buffer._generatedOutput._outputData._gameObject, bVisibility);
			}
		}
예제 #2
0
		private void GenerateInstancesFromNodeIDs(HEU_LoadBufferInstancer instancerBuffer, Dictionary<HAPI_NodeId, HEU_LoadBufferBase> idBuffersMap,
			Transform instanceRootTransform)
		{
			int numInstances = instancerBuffer._instanceNodeIDs.Length;
			for (int i = 0; i < numInstances; ++i)
			{
				HEU_LoadBufferBase sourceBuffer = null;
				if (!idBuffersMap.TryGetValue(instancerBuffer._instanceNodeIDs[i], out sourceBuffer) || sourceBuffer == null)
				{
					Debug.LogErrorFormat("Part with id {0} is missing. Unable to setup instancer!", instancerBuffer._instanceNodeIDs[i]);
					return;
				}

				// If the part we're instancing is itself an instancer, make sure it has generated its instances
				if (sourceBuffer._bInstanced && sourceBuffer._generatedOutput == null)
				{
					HEU_LoadBufferInstancer sourceBufferInstancer = instancerBuffer as HEU_LoadBufferInstancer;
					if (sourceBufferInstancer != null)
					{
						GenerateInstancer(sourceBufferInstancer, idBuffersMap);
					}
				}

				GameObject sourceGameObject = sourceBuffer._generatedOutput._outputData._gameObject;
				if (sourceGameObject == null)
				{
					Debug.LogErrorFormat("Output gameobject is null for source {0}. Unable to instance for {1}.", sourceBuffer._name, instancerBuffer._name);
					continue;
				}

				int numTransforms = instancerBuffer._instanceTransforms.Length;
				for (int j = 0; j < numTransforms; ++j)
				{
					CreateNewInstanceFromObject(sourceGameObject, (j + 1), instanceRootTransform, ref instancerBuffer._instanceTransforms[i],
						instancerBuffer._instancePrefixes, instancerBuffer._name);
				}
			}
		}
예제 #3
0
        private void GenerateInstancesFromNodeIDs(HAPI_NodeId cookNodeId, HEU_LoadBufferInstancer instancerBuffer, Dictionary <HAPI_NodeId, HEU_LoadBufferBase> idBuffersMap,
                                                  Transform instanceRootTransform)
        {
            // For single collision geo override
            GameObject singleCollisionGO = null;

            // For multi collision geo overrides, keep track of loaded objects
            Dictionary <string, GameObject> loadedCollisionObjectMap = new Dictionary <string, GameObject>();

            if (instancerBuffer._collisionAssetPaths != null && instancerBuffer._collisionAssetPaths.Length == 1)
            {
                // Single collision override
                if (!string.IsNullOrEmpty(instancerBuffer._collisionAssetPaths[0]))
                {
                    HEU_AssetDatabase.ImportAsset(instancerBuffer._collisionAssetPaths[0], HEU_AssetDatabase.HEU_ImportAssetOptions.Default);
                    singleCollisionGO = HEU_AssetDatabase.LoadAssetAtPath(instancerBuffer._collisionAssetPaths[0], typeof(GameObject)) as GameObject;
                }

                if (singleCollisionGO == null)
                {
                    // Continue on but log error
                    Debug.LogErrorFormat("Collision asset at path {0} not found for instance {1}.", instancerBuffer._collisionAssetPaths[0], instancerBuffer._name);
                }
            }

            int numInstances = instancerBuffer._instanceNodeIDs.Length;

            for (int i = 0; i < numInstances; ++i)
            {
                HEU_LoadBufferBase sourceBuffer = null;
                if (!idBuffersMap.TryGetValue(instancerBuffer._instanceNodeIDs[i], out sourceBuffer) || sourceBuffer == null)
                {
                    Debug.LogErrorFormat("Part with id {0} is missing. Unable to setup instancer!", instancerBuffer._instanceNodeIDs[i]);
                    return;
                }

                // If the part we're instancing is itself an instancer, make sure it has generated its instances
                if (sourceBuffer._bInstanced && sourceBuffer._generatedOutput == null)
                {
                    HEU_LoadBufferInstancer sourceBufferInstancer = instancerBuffer as HEU_LoadBufferInstancer;
                    if (sourceBufferInstancer != null)
                    {
                        GenerateInstancer(cookNodeId, sourceBufferInstancer, idBuffersMap);
                    }
                }

                GameObject sourceGameObject = sourceBuffer._generatedOutput._outputData._gameObject;
                if (sourceGameObject == null)
                {
                    Debug.LogErrorFormat("Output gameobject is null for source {0}. Unable to instance for {1}.", sourceBuffer._name, instancerBuffer._name);
                    continue;
                }

                GameObject collisionSrcGO = null;
                if (singleCollisionGO != null)
                {
                    // Single collision geo
                    collisionSrcGO = singleCollisionGO;
                }
                else if (instancerBuffer._collisionAssetPaths != null &&
                         (i < instancerBuffer._collisionAssetPaths.Length) &&
                         !string.IsNullOrEmpty(instancerBuffer._collisionAssetPaths[i]))
                {
                    // Mutliple collision geo (one per instance).
                    if (!loadedCollisionObjectMap.TryGetValue(instancerBuffer._collisionAssetPaths[i], out collisionSrcGO))
                    {
                        collisionSrcGO = HEU_AssetDatabase.LoadAssetAtPath(instancerBuffer._collisionAssetPaths[i], typeof(GameObject)) as GameObject;
                        if (collisionSrcGO == null)
                        {
                            Debug.LogErrorFormat("Unable to load collision asset at {0} for instancing!", instancerBuffer._collisionAssetPaths[i]);
                        }
                        else
                        {
                            loadedCollisionObjectMap.Add(instancerBuffer._collisionAssetPaths[i], collisionSrcGO);
                        }
                    }
                }

                int numTransforms = instancerBuffer._instanceTransforms.Length;
                for (int j = 0; j < numTransforms; ++j)
                {
                    CreateNewInstanceFromObject(sourceGameObject, (j + 1), instanceRootTransform, ref instancerBuffer._instanceTransforms[j],
                                                instancerBuffer._instancePrefixes, instancerBuffer._name, collisionSrcGO);
                }
            }
        }