本文整理汇总了C++中Light::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ Light::GetType方法的具体用法?C++ Light::GetType怎么用?C++ Light::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Light
的用法示例。
在下文中一共展示了Light::GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetProjectionMatrix
//----------------------------------------------------------------------------
bool PlanarShadowEffect::GetProjectionMatrix (int i, HMatrix& projection)
{
// Compute the equation for the shadow plane in world coordinates.
APoint vertex[3];
mPlanes[i]->GetWorldTriangle(0, vertex);
HPlane worldPlane(vertex[0], vertex[1], vertex[2]);
// This is a conservative test to see whether a shadow should be cast.
// This can cause incorrect results if the caster is large and intersects
// the plane, but ordinarily we are not trying to cast shadows in such
// situations.
if (mShadowCaster->WorldBound.WhichSide(worldPlane) < 0)
{
// The shadow caster is on the far side of plane, so it cannot cast
// a shadow.
return false;
}
// Compute the projection matrix for the light source.
Light* projector = mProjectors[i];
AVector normal = worldPlane.GetNormal();
if (projector->GetType() == Light::LT_DIRECTIONAL)
{
float NdD = normal.Dot(projector->DVector);
if (NdD >= 0.0f)
{
// The projection must be onto the "positive side" of the plane.
return false;
}
projection.MakeObliqueProjection(vertex[0], normal,
projector->DVector);
}
else if (projector->GetType() == Light::LT_POINT
|| projector->GetType() == Light::LT_SPOT)
{
float NdE = projector->Position.Dot(normal);
if (NdE <= 0.0f)
{
// The projection must be onto the "positive side" of the plane.
return false;
}
projection.MakePerspectiveProjection(vertex[0], normal,
projector->Position);
}
else
{
assertion(false, "Light type not supported.\n");
return false;
}
return true;
}
示例2: Update
void EditorLightNode::Update(float32 timeElapsed)
{
Light * parent = (Light*)GetParent();
if(type != parent->GetType())
{
RemoveAllChildren();
type = parent->GetType();
SceneNode * lightDrawNode = scene->GetRootNode(GetSceneFile())->Clone();
AddNode(lightDrawNode);
SafeRelease(lightDrawNode);
}
}
示例3: setLight
void renderer::setLight(u32 index, Light & light)
{
switch (light.GetType()) {
case Light::POSITION: {
if (light.m_position.w == 0.0f)
light.m_position.w = 1.0f;
}
break;
case Light::SPOT: {
}
break;
case Light::DIRECTIONAL: {
if (light.m_position.w != 0.0f)
light.m_position.w = 0.0f;
}
break;
}
//
ew_glLightfv(GL_LIGHT0 + index, GL_POSITION, (const GLfloat *) light.m_position.GetDataPtr());
ew_glLightfv(GL_LIGHT0 + index, GL_AMBIENT, (const GLfloat *) light.m_ambient.GetDataPtr());
ew_glLightfv(GL_LIGHT0 + index, GL_DIFFUSE, (const GLfloat *) light.m_diffuse.GetDataPtr());
ew_glLightfv(GL_LIGHT0 + index, GL_SPECULAR, (const GLfloat *) light.m_specular.GetDataPtr());
// This part is untested
ew_glLightfv(GL_LIGHT0 + index, GL_SPOT_DIRECTION, (const GLfloat *) light.m_direction.GetDataPtr());
// ew_glLightf(GL_LIGHT0 + index, GL_SPOT_CUTOFF, light.m_spot_cutoff);
// ew_glLightf(GL_LIGHT0 + index, GL_SPOT_EXPONENT, light.m_spot_exponent);
//
ew_glLightf(GL_LIGHT0 + index, GL_CONSTANT_ATTENUATION, light.m_constant_attenuation);
ew_glLightf(GL_LIGHT0 + index, GL_LINEAR_ATTENUATION, light.m_linear_attenuation);
ew_glLightf(GL_LIGHT0 + index, GL_QUADRATIC_ATTENUATION, light.m_quadratic_attenuation);
}
示例4: UpdateWorldData
//----------------------------------------------------------------------------
void RawTerrainPage::UpdateWorldData (double applicationTime)
{
TriMesh::UpdateWorldData(applicationTime);
PX2::Light *light = 0;
for (int i=0; i<(int)mInfulencedLights.size(); i++)
{
Light *lit = mInfulencedLights[i];
if (lit->GetType() == Light::LT_DIRECTIONAL)
{
light = lit;
break;
}
}
if (light!=0 && light!=mDirLight)
{
mDirLight = light;
mMaterialInstance->SetPixelConstant(0, "gLightModelDirection",
new0 LightModelDVectorConstant(mDirLight));
mMaterialInstance->SetPixelConstant(0, "gLightColour",
new0 LightDiffuseConstant(mDirLight));
}
}
示例5: CullLights
void World::CullLights(VisibleCullResult & result, Camera * cam)
{
List<Light*>::Iterator whr = mLights.Begin();
List<Light*>::Iterator end = mLights.End();
while (whr != end)
{
// current it's false
Light * light = *whr;
if (!light->IsVisible())
continue;
switch (light->GetType())
{
case LT_DIRECTIONAL:
result.lights.PushBack(light);
break;
case LT_POINT:
case LT_SPOT:
{
Sphere sph = Sphere(light->GetPosition(), light->GetRange());
if (cam->IsVisible(sph))
result.lights.PushBack(light);
}
break;
}
++whr;
}
}
示例6: CreateEditMtlInstPerVertex
//----------------------------------------------------------------------------
void RawTerrainPage::CreateEditMtlInstPerVertex (EditTerrainMaterial *material,
Shine *shine)
{
PX2::Light *light = 0;
for (int i=0; i<(int)mInfulencedLights.size(); i++)
{
Light *lit = mInfulencedLights[i];
if (lit->GetType() == Light::LT_DIRECTIONAL)
{
light = lit;
break;
}
}
if (light == 0)
{
light = new0 Light(Light::LT_DIRECTIONAL);
light->Ambient = Float4(1.0f, 0.8f, 0.8f, 1.0f);
light->Diffuse = Float4(1.0f, 0.8f, 0.6f, 1.0f);
light->Intensity = 1.0f;
light->SetDirection(AVector(-1.0f, -1.0f, -1.0f));
}
mMtlInst = new0 MaterialInstance(material, 0);
mMtlInst->SetVertexConstant(0, "gPVWMatrix", new0 PVWMatrixConstant());
mMtlInst->SetVertexConstant(0, "gShineEmissive",
new0 ShineEmissiveConstant(shine));
mMtlInst->SetVertexConstant(0, "gShineAmbient",
new0 ShineAmbientConstant(shine));
mMtlInst->SetVertexConstant(0, "gShineDiffuse",
new0 ShineDiffuseConstant(shine));
mMtlInst->SetVertexConstant(0, "gLightModelDirection",
new0 LightModelDVectorConstant(light));
mMtlInst->SetVertexConstant(0, "gLightColour",
new0 LightDiffuseConstant(light));
mMtlInst->SetVertexConstant(0, "gLightAttenuation",
new0 LightAttenuationConstant(light));
mMtlInst->SetPixelConstant(0, "UVScale01", mUV01Float);
mMtlInst->SetPixelConstant(0, "UVScale23", mUV23Float);
mMtlInst->SetPixelConstant(0, "UVScale4", mUV4Float);
SetTexture0(mTextureDefaultFilename);
SetTextureAlpha(mTextureAlpha);
SetTexture1(mTextureDefaultFilename);
SetTexture2(mTextureDefaultFilename);
SetTexture3(mTextureDefaultFilename);
SetTexture4(mTextureDefaultFilename);
SetMaterialInstance(mMtlInst);
}
示例7: OnIntPropertyChanged
void LightPropertyControl::OnIntPropertyChanged(PropertyList *forList, const String &forKey, int newValue)
{
Light *light = GetLight(currentSceneNode);
if("Shadow samples" == forKey)
{
if(Light::TYPE_DIRECTIONAL == light->GetType())
{
currentSceneNode->GetCustomProperties()->SetInt32("editor.staticlight.shadowsamples", newValue);
}
}
NodesPropertyControl::OnIntPropertyChanged(forList, forKey, newValue);
}
示例8: OnFloatPropertyChanged
void LightPropertyControl::OnFloatPropertyChanged(PropertyList *forList, const String &forKey, float newValue)
{
Light *light = GetLight(currentSceneNode);
if("Intensity" == forKey)
{
currentSceneNode->GetCustomProperties()->SetFloat("editor.intensity", newValue);
}
else if("Shadow angle" == forKey)
{
if(Light::TYPE_DIRECTIONAL == light->GetType())
{
currentSceneNode->GetCustomProperties()->SetFloat("editor.staticlight.shadowangle", newValue);
}
}
else if("Shadow radius" == forKey)
{
if(Light::TYPE_POINT == light->GetType())
{
currentSceneNode->GetCustomProperties()->SetFloat("editor.staticlight.shadowradius", newValue);
}
}
else if("Falloff cutoff" == forKey)
{
currentSceneNode->GetCustomProperties()->SetFloat("editor.staticlight.falloffcutoff", newValue);
}
else if("Falloff exponent" == forKey)
{
currentSceneNode->GetCustomProperties()->SetFloat("editor.staticlight.falloffexponent", newValue);
}
else if("property.lightnode.intensity" == forKey)
{
light->SetIntensity(newValue);
}
NodesPropertyControl::OnFloatPropertyChanged(forList, forKey, newValue);
}
示例9: UpdateWorldData
//----------------------------------------------------------------------------
void RawTerrainPage::UpdateWorldData (double applicationTime)
{
TriMesh::UpdateWorldData(applicationTime);
PX2::Light *light = 0;
for (int i=0; i<(int)mInfulencedLights.size(); i++)
{
Light *lit = mInfulencedLights[i];
if (lit->GetType() == Light::LT_DIRECTIONAL)
{
light = lit;
break;
}
}
if (light!=0 && light!=mDirLight)
{
mDirLight = light;
mMtlInst->SetVertexConstant(0, "gLightColour",
new0 LightDiffuseConstant(mDirLight));
mMtlInst->SetVertexConstant(0, "gLightAttenuation",
new0 LightAttenuationConstant(mDirLight));
mMtlInst->SetVertexConstant(0, "gLightModelDirection",
new0 LightModelDVectorConstant(mDirLight));
for (int i=0; i<(int)mJunglers.size(); i++)
{
Jungler *jungler = mJunglers[i];
MaterialInstance *inst = jungler->GetMtlInst();
if (inst)
{
inst->SetVertexConstant(0, "gLightColour",
new0 LightDiffuseConstant(mDirLight));
inst->SetVertexConstant(0, "gLightAttenuation",
new0 LightAttenuationConstant(mDirLight));
inst->SetVertexConstant(0, "gLightModelDirection",
new0 LightModelDVectorConstant(mDirLight));
}
}
}
}
示例10: OnComboIndexChanged
void LightPropertyControl::OnComboIndexChanged(PropertyList *forList, const String &forKey, int32 newItemIndex, const String &newItemKey)
{
if("property.lightnode.type" == forKey)
{
Light *light = GetLight(currentSceneNode);
light->SetType((Light::eType)newItemIndex);
if(Light::TYPE_DIRECTIONAL == light->GetType())
{
if(propertyList->IsPropertyAvaliable("Shadow angle"))
{
currentSceneNode->GetCustomProperties()->SetFloat("editor.staticlight.shadowangle", propertyList->GetFloatPropertyValue("Shadow angle"));
}
if(propertyList->IsPropertyAvaliable("Shadow samples"))
{
currentSceneNode->GetCustomProperties()->SetInt32("editor.staticlight.shadowsamples", propertyList->GetIntPropertyValue("Shadow samples"));
}
}
}
NodesPropertyControl::OnComboIndexChanged(forList, forKey, newItemIndex, newItemKey);
}
示例11: ReadFrom
void LightPropertyControl::ReadFrom(Entity * sceneNode)
{
NodesPropertyControl::ReadFrom(sceneNode);
Light *light = GetLight(sceneNode);
DVASSERT(light);
propertyList->AddSection("property.lightnode.light", GetHeaderState("property.lightnode.light", true));
propertyList->AddComboProperty("property.lightnode.type", types);
propertyList->SetComboPropertyIndex("property.lightnode.type", light->GetType());
propertyList->AddColorProperty("property.lightnode.ambient.color");
propertyList->SetColorPropertyValue("property.lightnode.ambient.color", light->GetAmbientColor());
propertyList->AddColorProperty("property.lightnode.diffuse.color");
propertyList->SetColorPropertyValue("property.lightnode.diffuse.color", light->GetDiffuseColor());
propertyList->AddColorProperty("property.lightnode.specular.color");
propertyList->SetColorPropertyValue("property.lightnode.specular.color", light->GetSpecularColor());
propertyList->AddFloatProperty("property.lightnode.intensity");
propertyList->SetFloatPropertyValue("property.lightnode.intensity", light->GetIntensity());
//propertyList->AddFloatProperty("property.lightnode.material.shininess", light->GetShininess())
propertyList->AddSection("property.lightnode.staticlight", GetHeaderState("property.lightnode.staticlight", true));
propertyList->AddBoolProperty("property.staticlight.enable");
propertyList->SetBoolPropertyValue("property.staticlight.enable", sceneNode->GetCustomProperties()->GetBool("editor.staticlight.enable", true));
propertyList->AddBoolProperty("Cast shadows");
propertyList->SetBoolPropertyValue("Cast shadows", sceneNode->GetCustomProperties()->GetBool("editor.staticlight.castshadows", true));
propertyList->AddFloatProperty("Intensity");
propertyList->SetFloatPropertyValue("Intensity", sceneNode->GetCustomProperties()->GetFloat("editor.intensity", 1.f));
propertyList->AddFloatProperty("Falloff cutoff");
propertyList->SetFloatPropertyValue("Falloff cutoff", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.falloffcutoff", 1000.f));
propertyList->AddFloatProperty("Falloff exponent");
propertyList->SetFloatPropertyValue("Falloff exponent", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.falloffexponent", 1.f));
if(Light::TYPE_DIRECTIONAL == light->GetType())
{
propertyList->AddFloatProperty("Shadow angle");
propertyList->SetFloatPropertyValue("Shadow angle", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.shadowangle", 0.f));
propertyList->AddIntProperty("Shadow samples");
propertyList->SetIntPropertyValue("Shadow samples", sceneNode->GetCustomProperties()->GetInt32("editor.staticlight.shadowsamples", 1));
}
else if(Light::TYPE_POINT == light->GetType())
{
propertyList->AddFloatProperty("Shadow radius");
propertyList->SetFloatPropertyValue("Shadow radius", sceneNode->GetCustomProperties()->GetFloat("editor.staticlight.shadowradius", 0.f));
}
propertyList->AddSection("property.lightnode.dynamiclight", GetHeaderState("property.lightnode.dynamiclight", true));
propertyList->AddBoolProperty("property.dynamiclight.enable");
propertyList->SetBoolPropertyValue("property.dynamiclight.enable", sceneNode->GetCustomProperties()->GetBool("editor.dynamiclight.enable", true));
}
示例12: LoadFromText
void SceneManager::LoadFromText(const char *text)
{
TextParser parser;
parser.Parse(text);
TextParser::NODE *node = NULL;
if ((node = parser.GetNode("FILETYPE")) && node->values[0] == "SCENE")
{
TextParser::NODE *node_data = parser.GetNode("DATA");
if (node_data)
{
// Models
TextParser::NODE *node_models = node_data->FindChild("MODELS");
if (node_models)
{
for(size_t i=0;i<node_models->children.size();i++)
{
TextParser::NODE *child = node_models->children[i];
TextParser::NODE *node_filename = NULL;
if ( child->name == "MODEL" &&
(node_filename = child->FindChild("FILENAME")))
{ // MODEL
Model *model = new Model(node_filename->values[0].GetCharPtr());
TextParser::NODE *node_position = child->FindChild("POSITION");
if (node_position) model->SetPosition(node_position->ToFVector3());
TextParser::NODE *node_scale = child->FindChild("SCALE");
if (node_scale) model->SetScale(node_scale->ToFVector3());
TextParser::NODE *node_rotation = child->FindChild("ROTATION");
if (node_rotation) model->SetRotation(node_rotation->ToFVector3());
mModels.push_back(model);
}
}
}
// Lights
TextParser::NODE *node_lights = node_data->FindChild("LIGHTS");
if (node_lights)
{
for(size_t i=0;i<node_lights->children.size();i++)
{
Light *light = NULL;
TextParser::NODE *child = node_lights->children[i];
TextParser::NODE *node_type = child->FindChild("TYPE");
if (node_type->values[0] == "Point")
{
light = new PointLight();
}
else if (node_type->values[0] == "Directional")
{
light = new DirectionalLight();
}
else if (node_type->values[0] == "Ambient")
{
light = new AmbientLight();
}
if (!light) continue;
TextParser::NODE *node_color = child->FindChild("COLOR");
if (node_color)
{
light->SetColor(node_color->ToFVector3());
}
TextParser::NODE *node_intensity = child->FindChild("INTENSITY");
if (node_intensity)
{
light->SetIntensity(node_intensity->values[0].ToFloat());
}
TextParser::NODE *node_pos = child->FindChild("POSITION");
if (node_pos && light->GetType() == Light::TYPE_POINT)
{
((PointLight*)light)->SetPosition(node_pos->ToFVector3());
}
TextParser::NODE *node_scl = child->FindChild("SCALE");
if (node_scl && light->GetType() == Light::TYPE_POINT)
{
((PointLight*)light)->SetScale(node_scl->ToFVector3());
}
switch(light->GetType())
{
case Light::TYPE_POINT:
{
TextParser::NODE *node_range = child->FindChild("RANGE");
if (node_range)
{
((PointLight*)light)->SetRange(node_range->values[0].ToFloat());
}
TextParser::NODE *node_exp = child->FindChild("EXPONENT");
if (node_exp)
{
((PointLight*)light)->SetExponent(node_exp->values[0].ToFloat());
}
} break;
}
AddLight(light);
}
}
}
}
}
示例13: GetVisibleLights
void World::GetVisibleLights(Node * node, List<Light*> & lights)
{
profile_code();
lights.Clear();
List<Light*>::Iterator iter;
List<Light*>::Iterator end;
iter = mLights.Begin();
end = mLights.End();
Light * light;
while (iter != end)
{
light = *iter;
if (light->IsVisible())
{
LIGHT_TYPE type = light->GetType();
if (type == LT_DIRECTIONAL)
{
lights.PushBack(light);
}
else if (type == LT_POINT)
{
const Sphere & sph = node->GetWorldBoundingSphere();
float len = Math::VecLength(light->GetPosition() - sph.center);
if (len - sph.radius < light->GetRange())
lights.PushBack(light);
}
else if (type == LT_SPOT)
{
Aabb aabb;
Vec3 ltf, lbf, rtf, rbf;
Vec3 ltb, lbb, rtb, rbb;
Vec3 lp;
float sq1, sq2, sq3, sq4;
float sq5, sq6, sq7, sq8;
float rsq;
Vec3 d1, d2, d3, d4;
Vec3 d5, d6, d7, d8;
Vec3 ld;
float dt1, dt2, dt3, dt4;
float dt5, dt6, dt7, dt8;
float mdt;
aabb = node->GetWorldAabb();
ltf = aabb.GetLeftTopFrontPoint();
lbf = aabb.GetLeftBottomFrontPoint();
rtf = aabb.GetRightTopFrontPoint();
rbf = aabb.GetRightBottomFrontPoint();
ltb = aabb.GetLeftTopBackPoint();
lbb = aabb.GetLeftBottomBackPoint();
rtb = aabb.GetRightTopBackPoint();
rbb = aabb.GetRightBottomBackPoint();
lp = light->GetPosition();
rsq = light->GetRange() * light->GetRange();
sq1 = Math::VecDistanceSq(lp, ltf);
sq2 = Math::VecDistanceSq(lp, lbf);
sq3 = Math::VecDistanceSq(lp, rtf);
sq4 = Math::VecDistanceSq(lp, rbf);
sq5 = Math::VecDistanceSq(lp, ltb);
sq6 = Math::VecDistanceSq(lp, lbb);
sq7 = Math::VecDistanceSq(lp, rtb);
sq8 = Math::VecDistanceSq(lp, rbb);
if (sq1 < rsq || sq2 < rsq || sq3 < rsq || sq4 < rsq ||
sq5 < rsq || sq6 < rsq || sq7 < rsq || sq8 < rsq)
{
ld = light->GetDirection();
mdt = light->GetOuter();
d1 = ltf - lp;
d2 = lbf - lp;
d3 = rtf - lp;
d4 = rbf - lp;
d5 = ltb - lp;
d6 = lbb - lp;
d7 = rtb - lp;
d8 = rbb - lp;
Math::VecNormalize(d1, d1);
Math::VecNormalize(d2, d2);
Math::VecNormalize(d3, d3);
Math::VecNormalize(d4, d4);
Math::VecNormalize(d5, d5);
Math::VecNormalize(d6, d6);
Math::VecNormalize(d7, d7);
Math::VecNormalize(d8, d8);
//.........这里部分代码省略.........
示例14: Render
//.........这里部分代码省略.........
{
RenderManager::ObjectToRender objectToRender;
objectToRender.uniqueIndex = obj->GetUniqueIndex();
objectToRender.transform = obj->GetComponent<Transform>();
objectToRender.meshRenderer = renderer;
objectToRender.renderPass = renderPass;
RenderManager::RenderObject( objectToRender );
}
if (guiTexture != NULL)
{
RenderManager::ObjectToRender objectToRender;
objectToRender.uniqueIndex = obj->GetUniqueIndex();
objectToRender.guiTexture = guiTexture;
RenderManager::RenderObject( objectToRender );
}
}
}
#if (ME3D_SHADING_MODE == ME3D_DEFERRED_SHADING)
if (viewport != NULL && viewport->HasEnableLights() && renderPass != RenderPass::PickingPass)
{
for (uint j = 0; j < m_layers[rank]->GetObjectsCount(); j++)
{
GameObject* obj = m_layers[rank]->GetObjectAt(j);
if (obj->IsFullyActive())
{
Light* lightComp = obj->GetComponent<Light>();
if (lightComp != NULL && lightComp->IsEnabled())
{
RenderManager::ActiveLight activeLight;
activeLight.light = lightComp;
activeLight.transform = obj->GetComponent<Transform>();
switch (lightComp->GetType())
{
case LightType::Directional:
RenderManager::DeferredDirectional(activeLight);
break;
case LightType::Point:
case LightType::Spot:
RenderManager::DeferredPointAndSpot(activeLight);
break;
}
}
}
}
}
#endif
#if (ME3D_SHADING_MODE == ME3D_DEFERRED_SHADING)
if (renderPass != RenderPass::PickingPass)
{
RenderManager::DeferredUnlit();
}
#endif
RenderManager::CollapseLayer(renderPass);
} // end for
// layer for gizmo
RenderManager::UseNewLayer(renderPass);
GizmoManager::RenderTools(renderPass);
#if (ME3D_SHADING_MODE == ME3D_DEFERRED_SHADING)
if (renderPass != RenderPass::PickingPass)
{
RenderManager::DeferredUnlit();
}
#endif
RenderManager::CollapseLayer(renderPass);
// layer for menu
RenderManager::UseNewLayer(renderPass);
MenuManager::Render(renderPass, viewportName);
#if (ME3D_SHADING_MODE == ME3D_DEFERRED_SHADING)
if (renderPass != RenderPass::PickingPass)
{
RenderManager::DeferredUnlit();
}
#endif
RenderManager::CollapseLayer(renderPass);
}
示例15: Process
void DebugRenderSystem::Process()
{
uint32 size = entities.size();
for(uint32 i = 0; i < size; ++i)
{
Entity * entity = entities[i];
DebugRenderComponent * debugRenderComponent = cast_if_equal<DebugRenderComponent*>(entity->GetComponent(Component::DEBUG_RENDER_COMPONENT));
TransformComponent * transformComponent = cast_if_equal<TransformComponent*>(entity->GetComponent(Component::TRANSFORM_COMPONENT));
//RenderComponent * renderComponent = cast_if_equal<RenderComponent*>(entity->GetComponent(Component::RENDER_COMPONENT));
Matrix4 worldTransform = /*(*transformComponent->GetWorldTransform()) * */camera->GetMatrix();
RenderManager::Instance()->SetMatrix(RenderManager::MATRIX_MODELVIEW, camera->GetMatrix());
AABBox3 debugBoundigBox = entity->GetWTMaximumBoundingBoxSlow();
uint32 debugFlags = debugRenderComponent->GetDebugFlags();
// Camera debug draw
if(debugFlags & DebugRenderComponent::DEBUG_DRAW_CAMERA)
{
CameraComponent * entityCameraComp = (CameraComponent *) entity->GetComponent(Component::CAMERA_COMPONENT);
if(NULL != entityCameraComp)
{
Camera* entityCamera = entityCameraComp->GetCamera();
if(NULL != entityCamera && camera != entityCamera)
{
Color camColor(0.0f, 1.0f, 0.0f, 1.0f);
Vector3 camPos = entityCamera->GetPosition();
//Vector3 camDirect = entityCamera->GetDirection();
AABBox3 camBox(camPos, 2.5f);
// If this is clip camera - show it as red camera
if (entityCamera == entity->GetScene()->GetClipCamera()) camColor = Color(1.0f, 0.0f, 0.0f, 1.0f);
RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR);
RenderManager::Instance()->SetState(RenderState::STATE_COLORMASK_ALL | RenderState::STATE_DEPTH_WRITE);
RenderManager::Instance()->SetColor(camColor);
RenderHelper::Instance()->DrawBox(camBox, 2.5f);
RenderManager::Instance()->SetState(RenderState::DEFAULT_3D_STATE);
RenderManager::Instance()->ResetColor();
debugBoundigBox = camBox;
}
}
}
// UserNode debug draw
if(debugFlags & DebugRenderComponent::DEBUG_DRAW_USERNODE)
{
if(NULL != entity->GetComponent(Component::USER_COMPONENT))
{
Color dcColor(0.0f, 0.0f, 1.0f, 1.0f);
AABBox3 dcBox(Vector3(), 1.0f);
Matrix4 prevMatrix = RenderManager::Instance()->GetMatrix(RenderManager::MATRIX_MODELVIEW);
Matrix4 finalMatrix = transformComponent->GetWorldTransform() * prevMatrix;
RenderManager::Instance()->SetMatrix(RenderManager::MATRIX_MODELVIEW, finalMatrix);
RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR);
RenderManager::Instance()->SetState(RenderState::STATE_COLORMASK_ALL | RenderState::STATE_DEPTH_WRITE | RenderState::STATE_DEPTH_TEST);
RenderManager::Instance()->SetColor(1.f, 1.f, 0, 1.0f);
RenderHelper::Instance()->DrawLine(Vector3(0, 0, 0), Vector3(1.f, 0, 0));
RenderManager::Instance()->SetColor(1.f, 0, 1.f, 1.0f);
RenderHelper::Instance()->DrawLine(Vector3(0, 0, 0), Vector3(0, 1.f, 0));
RenderManager::Instance()->SetColor(0, 1.f, 1.f, 1.0f);
RenderHelper::Instance()->DrawLine(Vector3(0, 0, 0), Vector3(0, 0, 1.f));
RenderManager::Instance()->SetColor(dcColor);
RenderHelper::Instance()->DrawBox(dcBox);
RenderManager::Instance()->SetState(RenderState::DEFAULT_3D_STATE);
RenderManager::Instance()->ResetColor();
RenderManager::Instance()->SetMatrix(RenderManager::MATRIX_MODELVIEW, prevMatrix);
dcBox.GetTransformedBox(transformComponent->GetWorldTransform(), debugBoundigBox);
}
}
// LightNode debug draw
if (debugFlags & DebugRenderComponent::DEBUG_DRAW_LIGHT_NODE)
{
LightComponent *lightComp = (LightComponent *) entity->GetComponent(Component::LIGHT_COMPONENT);
if(NULL != lightComp)
{
Light* light = lightComp->GetLightObject();
if(NULL != light)
{
Vector3 lPosition = light->GetPosition();
RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR);
RenderManager::Instance()->SetState(RenderState::STATE_COLORMASK_ALL | RenderState::STATE_DEPTH_WRITE);
RenderManager::Instance()->SetColor(1.0f, 1.0f, 0.0f, 1.0f);
switch (light->GetType())
//.........这里部分代码省略.........