Пример #1
0
 private Model getChildModel()
 {
     if (base.animation >= 0 && base.animationDelay == 0)
     {
         int frameId2 = AnimationSequence.animations[base.animation].primaryFrames[base.currentAnimationFrame];
         int frameId1 = -1;
         if (base.queuedAnimationId >= 0 && base.queuedAnimationId != base.standAnimationId)
         {
             frameId1 = AnimationSequence.animations[base.queuedAnimationId].primaryFrames[base.queuedAnimationFrame];
         }
         return(npcDefinition.getChildModel(frameId1, frameId2,
                                            AnimationSequence.animations[base.animation].flowControl));
     }
     else
     {
         int frameId2 = -1;
         if (base.queuedAnimationId >= 0)
         {
             frameId2 = AnimationSequence.animations[base.queuedAnimationId].primaryFrames[base.queuedAnimationFrame];
         }
         return(npcDefinition.getChildModel(-1, frameId2, null));
     }
 }
Пример #2
0
        public Model getChildModel(int frameId2, int frameId1, int[] framesFrom2)
        {
            if (childrenIDs != null)
            {
                EntityDefinition childDefinition = getChildDefinition();
                if (childDefinition == null)
                {
                    return(null);
                }
                else
                {
                    return(childDefinition.getChildModel(frameId2, frameId1, framesFrom2));
                }
            }

            Model model = (Model)modelCache.get(id);

            if (model == null)
            {
                bool notCached = false;
                for (int m = 0; m < modelIds.Length; m++)
                {
                    if (!Model.isCached(modelIds[m]))
                    {
                        notCached = true;
                    }
                }

                if (notCached)
                {
                    return(null);
                }
                Model[] childModels = new Model[modelIds.Length];
                for (int m = 0; m < modelIds.Length; m++)
                {
                    childModels[m] = Model.getModel(modelIds[m]);
                }

                if (childModels.Length == 1)
                {
                    model = childModels[0];
                }
                else
                {
                    model = new Model(childModels.Length, childModels);
                }
                if (modifiedModelColours != null)
                {
                    for (int c = 0; c < modifiedModelColours.Length; c++)
                    {
                        model.recolour(modifiedModelColours[c], originalModelColours[c]);
                    }
                }

                model.createBones();
                model.applyLighting(64 + brightness, 850 + contrast, -30, -50, -30, true);
                modelCache.put(model, id);
            }

            Model childModel = Model.aModel_1621;

            childModel.replaceWithModel(model, Animation.isNullFrame(frameId1) & Animation.isNullFrame(frameId2));
            if (frameId1 != -1 && frameId2 != -1)
            {
                childModel.mixAnimationFrames(framesFrom2, frameId2, frameId1);
            }
            else if (frameId1 != -1)
            {
                childModel.applyTransformation(frameId1);
            }
            if (scaleXY != 128 || scaleZ != 128)
            {
                childModel.scaleT(scaleXY, scaleXY, scaleZ);
            }
            childModel.calculateDiagonals();
            childModel.triangleSkin = null;
            childModel.vertexSkin   = null;
            if (boundaryDimension == 1)
            {
                childModel.singleTile = true;
            }
            return(childModel);
        }
Пример #3
0
        private Model getAnimatedModel()
        {
            if (npcAppearance != null)
            {
                int frameId = -1;
                if (base.animation >= 0 && base.animationDelay == 0)
                {
                    frameId = AnimationSequence.animations[base.animation].primaryFrames[base.currentAnimationFrame];
                }
                else if (base.queuedAnimationId >= 0)
                {
                    frameId = AnimationSequence.animations[base.queuedAnimationId].primaryFrames[base.queuedAnimationFrame];
                }
                Model model = npcAppearance.getChildModel(-1, frameId, null);
                return(model);
            }

            long l  = appearanceOffset;
            int  k  = -1;
            int  i1 = -1;
            int  j1 = -1;
            int  k1 = -1;

            if (base.animation >= 0 && base.animationDelay == 0)
            {
                AnimationSequence animation = AnimationSequence.animations[base.animation];
                k = animation.primaryFrames[base.currentAnimationFrame];
                if (base.queuedAnimationId >= 0 && base.queuedAnimationId != base.standAnimationId)
                {
                    i1 = AnimationSequence.animations[base.queuedAnimationId].primaryFrames[base.queuedAnimationFrame];
                }
                if (animation.playerReplacementShield >= 0)
                {
                    j1 = animation.playerReplacementShield;
                    l += j1 - appearance[5] << 40;
                }

                if (animation.playerReplacementWeapon >= 0)
                {
                    k1 = animation.playerReplacementWeapon;
                    l += k1 - appearance[3] << 48;
                }
            }
            else if (base.queuedAnimationId >= 0)
            {
                k = AnimationSequence.animations[base.queuedAnimationId].primaryFrames[base.queuedAnimationFrame];
            }

            Model model_1 = (Model)mruNodes.get(l);

            if (model_1 == null)
            {
                bool flag = false;
                for (int i2 = 0; i2 < 12; i2++)
                {
                    int k2 = appearance[i2];
                    if (k1 >= 0 && i2 == 3)
                    {
                        k2 = k1;
                    }
                    if (j1 >= 0 && i2 == 5)
                    {
                        k2 = j1;
                    }
                    if (k2 >= 256 && k2 < 512 && !IdentityKit.cache[k2 - 256].bodyModelCached())
                    {
                        flag = true;
                    }
                    if (k2 >= 512 && !ItemDefinition.getDefinition(k2 - 512).equipModelCached(gender))
                    {
                        flag = true;
                    }
                }

                if (flag)
                {
                    if (aLong1697 != -1L)
                    {
                        model_1 = (Model)mruNodes.get(aLong1697);
                    }
                    if (model_1 == null)
                    {
                        return(null);
                    }
                }
            }

            if (model_1 == null)
            {
                Model[] models = new Model[12];
                int     j2     = 0;
                for (int l2 = 0; l2 < 12; l2++)
                {
                    int i3 = appearance[l2];
                    if (k1 >= 0 && l2 == 3)
                    {
                        i3 = k1;
                    }
                    if (j1 >= 0 && l2 == 5)
                    {
                        i3 = j1;
                    }
                    if (i3 >= 256 && i3 < 512)
                    {
                        Model model_3 = IdentityKit.cache[i3 - 256].getBodyModel();
                        if (model_3 != null)
                        {
                            models[j2++] = model_3;
                        }
                    }

                    if (i3 >= 512)
                    {
                        Model model_4 = ItemDefinition.getDefinition(i3 - 512).getEquippedModel(gender);
                        if (model_4 != null)
                        {
                            models[j2++] = model_4;
                        }
                    }
                }

                model_1 = new Model(j2, models);
                for (int part = 0; part < 5; part++)
                {
                    if (bodyPartColour[part] != 0)
                    {
                        model_1.recolour(ConstantData.GetAppearanceColor(part, 0),
                                         ConstantData.GetAppearanceColor(part, bodyPartColour[part]));
                        if (part == 1)
                        {
                            model_1.recolour(ConstantData.GetBeardColor(0), ConstantData.GetBeardColor(bodyPartColour[part]));
                        }
                    }
                }

                model_1.createBones();
                model_1.applyLighting(64, 850, -30, -50, -30, true);
                mruNodes.put(model_1, l);
                aLong1697 = l;
            }

            if (preventRotation)
            {
                return(model_1);
            }
            Model model_2 = Model.aModel_1621;

            model_2.replaceWithModel(model_1, Animation.isNullFrame(k) & Animation.isNullFrame(i1));
            if (k != -1 && i1 != -1)
            {
                model_2.mixAnimationFrames(AnimationSequence.animations[base.animation].flowControl, i1, k);
            }
            else if (k != -1)
            {
                model_2.applyTransformation(k);
            }
            model_2.calculateDiagonals();
            model_2.triangleSkin = null;
            model_2.vertexSkin   = null;
            return(model_2);
        }