//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeTrack::Rendering(const Instance& instance, Manager* manager) { const InstanceValues& instValues = instance.rendererValues.track; TrackRenderer* renderer = manager->GetTrackRenderer(); if( renderer != NULL ) { float t = (float)instance.m_LivingTime / (float)instance.m_LivedTime; int32_t time = instance.m_LivingTime; int32_t livedTime = instance.m_LivedTime; SetValues( m_instanceParameter.ColorLeft, m_currentGroupValues.ColorLeft, TrackColorLeft, time, livedTime ); SetValues( m_instanceParameter.ColorCenter, m_currentGroupValues.ColorCenter, TrackColorCenter, time, livedTime ); SetValues( m_instanceParameter.ColorRight, m_currentGroupValues.ColorRight, TrackColorRight, time, livedTime ); SetValues( m_instanceParameter.ColorLeftMiddle, m_currentGroupValues.ColorLeftMiddle, TrackColorLeftMiddle, time, livedTime ); SetValues( m_instanceParameter.ColorCenterMiddle, m_currentGroupValues.ColorCenterMiddle, TrackColorCenterMiddle, time, livedTime ); SetValues( m_instanceParameter.ColorRightMiddle, m_currentGroupValues.ColorRightMiddle, TrackColorRightMiddle, time, livedTime ); SetValues( m_instanceParameter.SizeFor, m_currentGroupValues.SizeFor, TrackSizeFor, t ); SetValues( m_instanceParameter.SizeMiddle, m_currentGroupValues.SizeMiddle, TrackSizeMiddle, t ); SetValues( m_instanceParameter.SizeBack, m_currentGroupValues.SizeBack, TrackSizeBack, t ); m_instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43(); renderer->Rendering( m_nodeParameter, m_instanceParameter, m_userData ); m_instanceParameter.InstanceIndex++; } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeRibbon::Rendering(const Instance& instance, Manager* manager) { const InstanceValues& instValues = instance.rendererValues.ribbon; RibbonRenderer* renderer = manager->GetRibbonRenderer(); if( renderer != NULL ) { instValues._color.setValueToArg( m_instanceParameter.AllColor ); m_instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43(); color color_l = instValues._color; color color_r = instValues._color; if( RibbonColor.type == RibbonColorParameter::Default ) { } else if( RibbonColor.type == RibbonColorParameter::Fixed ) { color_l = color::mul( color_l, RibbonColor.fixed.l ); color_r = color::mul( color_r, RibbonColor.fixed.r ); } float fadeAlpha = GetFadeAlpha( instance ); if( fadeAlpha != 1.0f ) { color_l.a = (uint8_t)(color_l.a * fadeAlpha); color_r.a = (uint8_t)(color_r.a * fadeAlpha); } color_l.setValueToArg( m_instanceParameter.Colors[0] ); color_r.setValueToArg( m_instanceParameter.Colors[1] ); if( RibbonPosition.type == RibbonPositionParameter::Default ) { m_instanceParameter.Positions[0] = -0.5f; m_instanceParameter.Positions[1] = 0.5f; } else if( RibbonPosition.type == RibbonPositionParameter::Fixed ) { m_instanceParameter.Positions[0] = RibbonPosition.fixed.l; m_instanceParameter.Positions[1] = RibbonPosition.fixed.r; } renderer->Rendering( m_nodeParameter, m_instanceParameter, m_userData ); m_instanceParameter.InstanceIndex++; } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeRing::Rendering(const Instance& instance, Manager* manager) { const InstanceValues& instValues = instance.rendererValues.ring; RingRenderer* renderer = manager->GetRingRenderer(); if( renderer != NULL ) { RingRenderer::NodeParameter nodeParameter; nodeParameter.EffectPointer = GetEffect(); nodeParameter.AlphaBlend = AlphaBlend; nodeParameter.TextureFilter = Texture.FilterType; nodeParameter.TextureWrap = Texture.WrapType; nodeParameter.ZTest = Texture.ZTest; nodeParameter.ZWrite = Texture.ZWrite; nodeParameter.Billboard = Billboard; nodeParameter.VertexCount = VertexCount; nodeParameter.ColorTextureIndex = RingTexture; RingRenderer::InstanceParameter instanceParameter; instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43(); instanceParameter.ViewingAngle = instValues.viewingAngle.current; instValues.outerLocation.current.setValueToArg( instanceParameter.OuterLocation ); instValues.innerLocation.current.setValueToArg( instanceParameter.InnerLocation ); instanceParameter.CenterRatio = instValues.centerRatio.current; instValues.outerColor.current.setValueToArg( instanceParameter.OuterColor ); instValues.centerColor.current.setValueToArg( instanceParameter.CenterColor ); instValues.innerColor.current.setValueToArg( instanceParameter.InnerColor ); float fadeAlpha = GetFadeAlpha( instance ); if( fadeAlpha != 1.0f ) { instanceParameter.OuterColor.A = (uint8_t)(instanceParameter.OuterColor.A * fadeAlpha); instanceParameter.CenterColor.A = (uint8_t)(instanceParameter.CenterColor.A * fadeAlpha); instanceParameter.InnerColor.A = (uint8_t)(instanceParameter.InnerColor.A * fadeAlpha); } instanceParameter.UV = instance.GetUV(); renderer->Rendering( nodeParameter, instanceParameter, m_userData ); } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeModel::Rendering(const Instance& instance, Manager* manager) { const InstanceValues& instValues = instance.rendererValues.model; ModelRenderer* renderer = manager->GetModelRenderer(); if( renderer != NULL ) { ModelRenderer::NodeParameter nodeParameter; nodeParameter.AlphaBlend = AlphaBlend; nodeParameter.TextureFilter = Texture.FilterType; nodeParameter.TextureWrap = Texture.WrapType; nodeParameter.ZTest = Texture.ZTest; nodeParameter.ZWrite = Texture.ZWrite; nodeParameter.EffectPointer = GetEffect(); nodeParameter.ModelIndex = ModelIndex; nodeParameter.ColorTextureIndex = Texture.ColorTextureIndex; nodeParameter.Culling = Culling; nodeParameter.Lighting = Lighting; nodeParameter.NormalTextureIndex = NormalTextureIndex; nodeParameter.Magnification = m_effect->GetMaginification(); nodeParameter.IsRightHand = manager->GetCoordinateSystem() == COORDINATE_SYSTEM_RH; ModelRenderer::InstanceParameter instanceParameter; instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43(); instanceParameter.UV = instance.GetUV(); instValues._color.setValueToArg( instanceParameter.AllColor ); float fadeAlpha = GetFadeAlpha( instance ); if( fadeAlpha != 1.0f ) { instanceParameter.AllColor.A = (uint8_t)(instanceParameter.AllColor.A * fadeAlpha); } renderer->Rendering( nodeParameter, instanceParameter, m_userData ); } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeImplemented::PlaySound_(Instance& instance, SoundTag tag, Manager* manager) { SoundPlayer* player = manager->GetSoundPlayer(); if( player == NULL ) { return; } if( Sound.WaveId >= 0 ) { SoundPlayer::InstanceParameter parameter; parameter.Data = m_effect->GetWave( Sound.WaveId ); parameter.Volume = Sound.Volume.getValue( *manager ); parameter.Pitch = Sound.Pitch.getValue( *manager ); parameter.Pan = Sound.Pan.getValue( *manager ); parameter.Mode3D = (Sound.PanType == ParameterSoundPanType_3D); Vector3D::Transform( parameter.Position, Vector3D(0.0f, 0.0f, 0.0f), instance.GetGlobalMatrix43() ); parameter.Distance = Sound.Distance; player->Play( tag, parameter ); } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeSprite::Rendering(const Instance& instance, Manager* manager) { const InstanceValues& instValues = instance.rendererValues.sprite; SpriteRenderer* renderer = manager->GetSpriteRenderer(); if( renderer != NULL ) { SpriteRenderer::NodeParameter nodeParameter; nodeParameter.AlphaBlend = AlphaBlend; nodeParameter.TextureFilter = Texture.FilterType; nodeParameter.TextureWrap = Texture.WrapType; nodeParameter.ZTest = Texture.ZTest; nodeParameter.ZWrite = Texture.ZWrite; nodeParameter.Billboard = Billboard; nodeParameter.ColorTextureIndex = SpriteTexture; nodeParameter.EffectPointer = GetEffect(); SpriteRenderer::InstanceParameter instanceParameter; instValues._color.setValueToArg( instanceParameter.AllColor ); instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43(); color color_ll = instValues._color; color color_lr = instValues._color; color color_ul = instValues._color; color color_ur = instValues._color; if( SpriteColor.type == SpriteColorParameter::Default ) { } else if( SpriteColor.type == SpriteColorParameter::Fixed ) { color_ll = color::mul( color_ll, SpriteColor.fixed.ll ); color_lr = color::mul( color_lr, SpriteColor.fixed.lr ); color_ul = color::mul( color_ul, SpriteColor.fixed.ul ); color_ur = color::mul( color_ur, SpriteColor.fixed.ur ); } float fadeAlpha = GetFadeAlpha( instance ); if( fadeAlpha != 1.0f ) { color_ll.a = (uint8_t)(color_ll.a * fadeAlpha); color_lr.a = (uint8_t)(color_lr.a * fadeAlpha); color_ul.a = (uint8_t)(color_ul.a * fadeAlpha); color_ur.a = (uint8_t)(color_ur.a * fadeAlpha); } color_ll.setValueToArg( instanceParameter.Colors[0] ); color_lr.setValueToArg( instanceParameter.Colors[1] ); color_ul.setValueToArg( instanceParameter.Colors[2] ); color_ur.setValueToArg( instanceParameter.Colors[3] ); if( SpritePosition.type == SpritePosition.Default ) { instanceParameter.Positions[0].X = -0.5f; instanceParameter.Positions[0].Y = -0.5f; instanceParameter.Positions[1].X = 0.5f; instanceParameter.Positions[1].Y = -0.5f; instanceParameter.Positions[2].X = -0.5f; instanceParameter.Positions[2].Y = 0.5f; instanceParameter.Positions[3].X = 0.5f; instanceParameter.Positions[3].Y = 0.5f; } else if( SpritePosition.type == SpritePosition.Fixed ) { SpritePosition.fixed.ll.setValueToArg( instanceParameter.Positions[0] ); SpritePosition.fixed.lr.setValueToArg( instanceParameter.Positions[1] ); SpritePosition.fixed.ul.setValueToArg( instanceParameter.Positions[2] ); SpritePosition.fixed.ur.setValueToArg( instanceParameter.Positions[3] ); } instanceParameter.UV = instance.GetUV(); renderer->Rendering( nodeParameter, instanceParameter, m_userData ); } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void ManagerImplemented::Flip() { if( !m_autoFlip ) { m_renderingSession.Enter(); } ExecuteEvents(); // DrawSet削除処理 GCDrawSet( false ); m_renderingDrawSets.clear(); m_renderingDrawSetMaps.clear(); /* カリング生成 */ if( cullingNext.SizeX != cullingCurrent.SizeX || cullingNext.SizeY != cullingCurrent.SizeY || cullingNext.SizeZ != cullingCurrent.SizeZ || cullingNext.LayerCount != cullingCurrent.LayerCount) { Culling3D::SafeRelease(m_cullingWorld); std::map<Handle,DrawSet>::iterator it = m_DrawSets.begin(); std::map<Handle,DrawSet>::iterator it_end = m_DrawSets.end(); while( it != it_end ) { DrawSet& ds = (*it).second; Culling3D::SafeRelease(ds.CullingObjectPointer); ++it; } m_cullingWorld = Culling3D::World::Create( cullingNext.SizeX, cullingNext.SizeY, cullingNext.SizeZ, cullingNext.LayerCount); cullingCurrent = cullingNext; } { std::map<Handle,DrawSet>::iterator it = m_DrawSets.begin(); std::map<Handle,DrawSet>::iterator it_end = m_DrawSets.end(); while( it != it_end ) { DrawSet& ds = (*it).second; EffectImplemented* effect = (EffectImplemented*)ds.ParameterPointer; if(ds.IsParameterChanged) { if(m_cullingWorld != NULL) { if(ds.CullingObjectPointer == NULL) { ds.CullingObjectPointer = Culling3D::Object::Create(); if(effect->Culling.Shape == CullingShape::Sphere) { ds.CullingObjectPointer->ChangeIntoSphere(0.0f); } if (effect->Culling.Shape == CullingShape::NoneShape) { ds.CullingObjectPointer->ChangeIntoAll(); } } InstanceContainer* pContainer = ds.InstanceContainerPointer; Instance* pInstance = pContainer->GetFirstGroup()->GetFirst(); Vector3D pos( ds.CullingObjectPointer->GetPosition().X, ds.CullingObjectPointer->GetPosition().Y, ds.CullingObjectPointer->GetPosition().Z); Matrix43 pos_; pos_.Translation(pos.X, pos.Y, pos.Z); Matrix43::Multiple(pos_, pos_, pInstance->m_GlobalMatrix43); if(ds.DoUseBaseMatrix) { Matrix43::Multiple(pos_, pos_, ds.BaseMatrix); } Culling3D::Vector3DF position; position.X = pos_.Value[3][0]; position.Y = pos_.Value[3][1]; position.Z = pos_.Value[3][2]; ds.CullingObjectPointer->SetPosition(position); if(effect->Culling.Shape == CullingShape::Sphere) { float radius = effect->Culling.Sphere.Radius; { Vector3D s; pInstance->GetGlobalMatrix43().GetScale(s); radius = radius * sqrt(s.X * s.X + s.Y * s.Y + s.Z * s.Z); } if(ds.DoUseBaseMatrix) { Vector3D s; ds.BaseMatrix.GetScale(s); radius = radius * sqrt(s.X * s.X + s.Y * s.Y + s.Z * s.Z); } ds.CullingObjectPointer->ChangeIntoSphere(radius); } m_cullingWorld->AddObject(ds.CullingObjectPointer); } (*it).second.IsParameterChanged = false; } m_renderingDrawSets.push_back( (*it).second ); m_renderingDrawSetMaps[(*it).first] = (*it).second; ++it; } if(m_cullingWorld != NULL) { for(size_t i = 0; i < m_renderingDrawSets.size(); i++) { m_renderingDrawSets[i].CullingObjectPointer->SetUserData(&(m_renderingDrawSets[i])); } } } m_culledObjects.clear(); m_culledObjectSets.clear(); m_culled = false; if( !m_autoFlip ) { m_renderingSession.Leave(); } }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeRing::Rendering(const Instance& instance, Manager* manager) { const InstanceValues& instValues = instance.rendererValues.ring; RingRenderer* renderer = manager->GetRingRenderer(); if( renderer != NULL ) { RingRenderer::NodeParameter nodeParameter; nodeParameter.EffectPointer = GetEffect(); nodeParameter.AlphaBlend = AlphaBlend; nodeParameter.TextureFilter = RendererCommon.FilterType; nodeParameter.TextureWrap = RendererCommon.WrapType; nodeParameter.ZTest = RendererCommon.ZTest; nodeParameter.ZWrite = RendererCommon.ZWrite; nodeParameter.Billboard = Billboard; nodeParameter.VertexCount = VertexCount; nodeParameter.ColorTextureIndex = RingTexture; nodeParameter.IsRightHand = manager->GetCoordinateSystem() == CoordinateSystem::RH; nodeParameter.Distortion = RendererCommon.Distortion; nodeParameter.DistortionIntensity = RendererCommon.DistortionIntensity; nodeParameter.DepthOffset = DepthValues.DepthOffset; nodeParameter.IsDepthOffsetScaledWithCamera = DepthValues.IsDepthOffsetScaledWithCamera; nodeParameter.IsDepthOffsetScaledWithParticleScale = DepthValues.IsDepthOffsetScaledWithParticleScale; color _outerColor; color _centerColor; color _innerColor; if (RendererCommon.ColorBindType == BindType::Always || RendererCommon.ColorBindType == BindType::WhenCreating) { _outerColor = color::mul(instValues.outerColor.original, instance.ColorParent); _centerColor = color::mul(instValues.centerColor.original, instance.ColorParent); _innerColor = color::mul(instValues.innerColor.original, instance.ColorParent); } else { _outerColor = instValues.outerColor.original; _centerColor = instValues.centerColor.original; _innerColor = instValues.innerColor.original; } RingRenderer::InstanceParameter instanceParameter; instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43(); instanceParameter.ViewingAngle = instValues.viewingAngle.current; instValues.outerLocation.current.setValueToArg( instanceParameter.OuterLocation ); instValues.innerLocation.current.setValueToArg( instanceParameter.InnerLocation ); instanceParameter.CenterRatio = instValues.centerRatio.current; _outerColor.setValueToArg( instanceParameter.OuterColor ); _centerColor.setValueToArg( instanceParameter.CenterColor ); _innerColor.setValueToArg( instanceParameter.InnerColor ); // Apply global color if (instance.m_pContainer->GetRootInstance()->IsGlobalColorSet) { Color::Mul(instanceParameter.OuterColor, instanceParameter.OuterColor, instance.m_pContainer->GetRootInstance()->GlobalColor); Color::Mul(instanceParameter.CenterColor, instanceParameter.CenterColor, instance.m_pContainer->GetRootInstance()->GlobalColor); Color::Mul(instanceParameter.InnerColor, instanceParameter.InnerColor, instance.m_pContainer->GetRootInstance()->GlobalColor); } instanceParameter.UV = instance.GetUV(); renderer->Rendering( nodeParameter, instanceParameter, m_userData ); } }