Пример #1
0
    override protected NPVoxModel CreateProduct(NPVoxModel reuse = null)
    {
        if (Input == null)
        {
            return(NPVoxModel.NewInvalidInstance(reuse, "No Input Setup"));
        }

        NPVoxModel model = ((NPVoxIModelFactory)Input).GetProduct();

        // backwards compatibility
        if (TryToResolveConflicts == false)
        {
            TryToResolveConflicts = true;
            ResolveConflictMethod = NPVoxModelTransformationUtil.ResolveConflictMethodType.NONE;
        }

        // shift afftected area if the parent bounding box changed
        {
            NPVoxBox parentBounds = model.BoundingBox;
            if (!lastParentModelBounds.Equals(NPVoxBox.INVALID) && !lastParentModelBounds.Equals(parentBounds))
            {
                sbyte      deltaX = (sbyte)((parentBounds.Right - lastParentModelBounds.Right) / 2);
                sbyte      deltaY = (sbyte)((parentBounds.Up - lastParentModelBounds.Up) / 2);
                sbyte      deltaZ = (sbyte)((parentBounds.Forward - lastParentModelBounds.Forward) / 2);
                NPVoxCoord delta  = new NPVoxCoord(deltaX, deltaY, deltaZ);
                AffectedArea = new NPVoxBox(AffectedArea.LeftDownBack + delta, AffectedArea.RightUpForward + delta);
                // Debug.Log("Moving affected area by + " + deltaX + " " + deltaY + " " + deltaZ);
            }
            lastParentModelBounds = parentBounds;
        }

        return(NPVoxModelTransformationUtil.MatrixTransform(model, AffectedArea, Matrix, PivotOffset, ResolveConflictMethod, reuse));
    }
Пример #2
0
    override protected NPVoxModel CreateProduct(NPVoxModel reuse = null)
    {
        if (Input == null)
        {
            return(NPVoxModel.NewInvalidInstance(reuse, "No Input Setup"));
        }

        NPVoxBoneModel model = ((NPVoxIModelFactory)Input).GetProduct() as NPVoxBoneModel;

        if (model == null)
        {
            return(NPVoxModel.NewInvalidInstance(reuse, "Can only transform bone models"));
        }

        // hack to center pivot on selected bones
        if (regenerateName)
        {
            RecenterBonePivot(model);
        }

        RegenerateName(model);

        NPVoxBox affectedBox = GetAffectedBox();

        if (affectedBox.Equals(NPVoxBox.INVALID))
        {
            NPVoxModel newInstance = NPVoxModel.NewInstance(model, reuse);
            newInstance.CopyOver(model);
            newInstance.RecalculateNumVoxels(true);
            return(newInstance);
        }
        else
        {
            reuse = NPVoxModelTransformationUtil.MatrixTransform(model, affectedBox, boneMask, Matrix, PivotOffset, ResolveConflictMethod, reuse);
            reuse.RecalculateNumVoxels(true);
            return(reuse);
        }
    }