Пример #1
0
void DisplayFactory::updateDisplay(Bone *bone, DecorativeDisplay *decoDisplay, float dt, bool dirty)
{
    CS_RETURN_IF(!decoDisplay);

#if ENABLE_PHYSICS_DETECT
    if (dirty)
    {
        ColliderDetector *detector = decoDisplay->getColliderDetector();
        if (detector)
        {
            AffineTransform t = AffineTransformConcat(bone->nodeToArmatureTransform(), bone->getArmature()->getNodeToWorldTransform());
            detector->updateTransform(t);
        }
    }
#endif


    switch(decoDisplay->getDisplayData()->displayType)
    {
    case CS_DISPLAY_SPRITE:
        updateSpriteDisplay(bone, decoDisplay, dt, dirty);
        break;
    case CS_DISPLAY_PARTICLE:
        updateParticleDisplay(bone, decoDisplay, dt, dirty);
        break;
    case CS_DISPLAY_ARMATURE:
        updateArmatureDisplay(bone, decoDisplay, dt, dirty);
        break;
    default:
        break;
    }
}
void DisplayFactory::updateDisplay(Bone *bone, float dt, bool dirty)
{
    Node *display = bone->getDisplayRenderNode();
    CS_RETURN_IF(!display);

    switch(bone->getDisplayRenderNodeType())
    {
    case CS_DISPLAY_SPRITE:
        if (dirty)
        {
            static_cast<Skin*>(display)->updateArmatureTransform();
        }
        break;
    case CS_DISPLAY_PARTICLE:
        updateParticleDisplay(bone, display, dt);
        break;
    case CS_DISPLAY_ARMATURE:
        updateArmatureDisplay(bone, display, dt);
        break;
    default:
    {
        Mat4 transform = bone->getNodeToArmatureTransform();
        display->setAdditionalTransform(&transform);
    }
    break;
    }


#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
    if (dirty)
    {
        DecorativeDisplay *decoDisplay = bone->getDisplayManager()->getCurrentDecorativeDisplay();
        ColliderDetector *detector = decoDisplay->getColliderDetector();
        if (detector)
        {
            do
            {
#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
                CC_BREAK_IF(!detector->getBody());
#endif

                Mat4 displayTransform = display->getNodeToParentTransform();
                Vec2 anchorPoint =  display->getAnchorPointInPoints();
                anchorPoint = PointApplyTransform(anchorPoint, displayTransform);
                displayTransform.m[12] = anchorPoint.x;
                displayTransform.m[13] = anchorPoint.y;
                Mat4 t = TransformConcat( bone->getArmature()->getNodeToParentTransform(),displayTransform);
                detector->updateTransform(t);
            }
            while (0);
        }
    }
#endif
}
Пример #3
0
void CCDisplayFactory::updateDisplay(CCBone *bone, float dt, bool dirty)
{
    CCNode *display = bone->getDisplayRenderNode();
    CS_RETURN_IF(!display);

    switch(bone->getDisplayRenderNodeType())
    {
    case CS_DISPLAY_SPRITE:
        if (dirty)
        {
            (static_cast<CCSkin*>(display))->updateArmatureTransform();
        }
        break;
    case CS_DISPLAY_PARTICLE:
        updateParticleDisplay(bone, display, dt);
        break;
    case CS_DISPLAY_ARMATURE:
        updateArmatureDisplay(bone, display, dt);
        break;
    default:
        display->setAdditionalTransform(bone->nodeToArmatureTransform());
        break;
    }

#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT || ENABLE_PHYSICS_SAVE_CALCULATED_VERTEX
    if (dirty)
    {
        CCDecorativeDisplay *decoDisplay = bone->getDisplayManager()->getCurrentDecorativeDisplay();
        CCColliderDetector *detector = decoDisplay->getColliderDetector();
        if (detector)
        {
            do
            {
#if ENABLE_PHYSICS_BOX2D_DETECT
                CC_BREAK_IF(!detector->getBody());
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
                CC_BREAK_IF(!detector->getBody());
#endif

                CCAffineTransform displayTransform = display->nodeToParentTransform();
                CCPoint anchorPoint =  display->getAnchorPointInPoints();
                anchorPoint = CCPointApplyAffineTransform(anchorPoint, displayTransform);
                displayTransform.tx = anchorPoint.x;
                displayTransform.ty = anchorPoint.y;
                CCAffineTransform t = CCAffineTransformConcat(displayTransform, bone->getArmature()->nodeToParentTransform());
                detector->updateTransform(t);
            }
            while (0);
        }
    }
#endif
}
Пример #4
0
void CCDisplayFactory::updateDisplay(CCBone *bone, CCDecorativeDisplay *decoDisplay, float dt, bool dirty)
{
    CS_RETURN_IF(!decoDisplay);

#if ENABLE_PHYSICS_BOX2D_DETECT || ENABLE_PHYSICS_CHIPMUNK_DETECT
    if (dirty)
    {
        CCColliderDetector *detector = decoDisplay->getColliderDetector();
        if (detector)
        {
            do
            {
#if ENABLE_PHYSICS_BOX2D_DETECT
                CC_BREAK_IF(!detector->getBody());
#elif ENABLE_PHYSICS_CHIPMUNK_DETECT
                CC_BREAK_IF(!detector->getBody());
#endif
                CCNode *node = decoDisplay->getDisplay();
                CCAffineTransform displayTransform = node->nodeToParentTransform();
                CCPoint anchorPoint =  node->getAnchorPointInPoints();
                anchorPoint = CCPointApplyAffineTransform(anchorPoint, displayTransform);
                displayTransform.tx = anchorPoint.x;
                displayTransform.ty = anchorPoint.y;
                CCAffineTransform t = CCAffineTransformConcat(displayTransform, bone->getArmature()->nodeToParentTransform());
                detector->updateTransform(t);
            }
            while (0);
        }
    }
#endif

    CCNode *display = decoDisplay->getDisplay();

    switch(decoDisplay->getDisplayData()->displayType)
    {
    case CS_DISPLAY_SPRITE:
        updateSpriteDisplay(bone, display, dt, dirty);
        break;
    case CS_DISPLAY_PARTICLE:
        updateParticleDisplay(bone, display, dt, dirty);
        break;
    case CS_DISPLAY_ARMATURE:
        updateArmatureDisplay(bone, display, dt, dirty);
        break;
    default:
    {
        display->setAdditionalTransform(bone->nodeToArmatureTransform());
    }
    break;
    }
}