void CX3DDirectionalLightNode::print(int indent) { FILE *fp = CX3DParser::getDebugLogFp(); char *nodeName = getNodeName(); if (nodeName) { float r, g, b; float x, y, z; CX3DParser::printIndent(indent); fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType())); CX3DParser::printIndent(indent+1); fprintf(fp, "ambientIntensity : (%f)\n", getAmbientIntensity()->getValue()); getColor()->getValue(r, g, b); CX3DParser::printIndent(indent+1); fprintf(fp, "color : (%f %f %f)\n", r, g, b); getDirection()->getValue(x, y, z); CX3DParser::printIndent(indent+1); fprintf(fp, "direction : (%f %f %f)\n", x, y, z); CX3DParser::printIndent(indent+1); fprintf(fp, "intensity : (%f)\n", getIntensity()->getValue()); CX3DParser::printIndent(indent+1); fprintf(fp, "on : %s\n", getOn()->getValue() ? "TRUE" : "FALSE"); CX3DParser::printIndent(indent+1); fprintf(fp, "global : %s\n", getGlobal()->getValue() ? "TRUE" : "FALSE"); } }
void KeyLightPropertyGroup::debugDump() const { qDebug() << " KeyLightPropertyGroup: ---------------------------------------------"; qDebug() << " color:" << getColor(); // << "," << getColor()[1] << "," << getColor()[2]; qDebug() << " intensity:" << getIntensity(); qDebug() << " direction:" << getDirection(); qDebug() << " ambientIntensity:" << getAmbientIntensity(); qDebug() << " ambientURL:" << getAmbientURL(); }
void PointLightNode::getAmbientColor(float value[]) { getColor(value); float intensity = getIntensity(); float ambientIntensity = getAmbientIntensity(); value[0] *= intensity * ambientIntensity; value[1] *= intensity * ambientIntensity; value[2] *= intensity * ambientIntensity; }
void PointLight::SetLight(X3DDrawContext* pDC) { // m_radius->m_value; D3DXMATRIX modelView = pDC->m_renderContext->modelViewMatrix(); D3DXVECTOR3 location(m_location->getValue()); D3DXVECTOR4 v; D3DXVec3Transform(&v, &location, &modelView); float ambientIntensity = getAmbientIntensity(); float intensity = getIntensity(); Vec3f color = getColor(); Vec3f attenuation = getAttenuation(); Graphics::Light light; light.m_type = 2; light.m_ambient = Vec4f(ambientIntensity, ambientIntensity, ambientIntensity, 1.0f); light.m_diffuse = Vec4f(color[0]*intensity, color[1]*intensity, color[2]*intensity, 1.0f); light.m_position = Vec4f(v.x, v.y, v.z, 1/*positional*/); light.m_constant_attenuation = attenuation[0]; light.m_linear_attenuation = attenuation[1]; light.m_quadratic_attenuation = attenuation[2]; pDC->m_renderContext->m_lights.push_back(light); ++pDC->m_renderContext->m_nLight; #if 0 pDC->m_pGraphics3D->PushMatrix(); // glTranslated(0, 0, 100); float light_position[4]; m_location->getValue(light_position); light_position[3] = 1; // positional float ambient[4] = {m_ambientIntensity->m_value, m_ambientIntensity->m_value, m_ambientIntensity->m_value, 1.0}; float diffuse_specular[4] = {m_color->m_value[0], m_color->m_value[1], m_color->m_value[2], m_intensity->m_value}; pDC->m_pGraphics3D->Enable(GL_LIGHT0+pDC->m_nLight); pDC->m_pGraphics3D->Lightfv(GL_LIGHT0+pDC->m_nLight, GL_POSITION, light_position); pDC->m_pGraphics3D->Lightfv(GL_LIGHT0+pDC->m_nLight, GL_AMBIENT, ambient); pDC->m_pGraphics3D->Lightfv(GL_LIGHT0+pDC->m_nLight, GL_DIFFUSE, diffuse_specular); // pDC->m_pGraphics3D->glLightfv(GL_LIGHT0+pDC->m_nLight, GL_SPECULAR , diffuse_specular); pDC->m_pGraphics3D->Lightf(GL_LIGHT0+pDC->m_nLight, GL_CONSTANT_ATTENUATION, m_attenuation->m_value[0]); pDC->m_pGraphics3D->Lightf(GL_LIGHT0+pDC->m_nLight, GL_LINEAR_ATTENUATION, m_attenuation->m_value[1]); pDC->m_pGraphics3D->Lightf(GL_LIGHT0+pDC->m_nLight, GL_QUADRATIC_ATTENUATION, m_attenuation->m_value[2]); pDC->m_pGraphics3D->PopMatrix(); #endif }
void PointLightNode::outputContext(ostream &printStream, const char *indentString) { SFColor *color = getColorField(); SFVec3f *attenuation = getAttenuationField(); SFVec3f *location = getLocationField(); SFBool *bon = getOnField(); printStream << indentString << "\t" << "on " << bon << endl; printStream << indentString << "\t" << "intensity " << getIntensity() << endl; printStream << indentString << "\t" << "ambientIntensity " << getAmbientIntensity() << endl; printStream << indentString << "\t" << "color " << color << endl; printStream << indentString << "\t" << "location " << location << endl; printStream << indentString << "\t" << "radius " << getRadius() << endl; printStream << indentString << "\t" << "attenuation " << attenuation << endl; }
void KeyLightPropertyGroup::appendSubclassData(OctreePacketData* packetData, EncodeBitstreamParams& params, EntityTreeElementExtraEncodeData* entityTreeElementExtraEncodeData, EntityPropertyFlags& requestedProperties, EntityPropertyFlags& propertyFlags, EntityPropertyFlags& propertiesDidntFit, int& propertyCount, OctreeElement::AppendState& appendState) const { bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, getColor()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, getIntensity()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, getAmbientIntensity()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, getDirection()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_URL, getAmbientURL()); }
bool KeyLightPropertyGroup::appendToEditPacket(OctreePacketData* packetData, EntityPropertyFlags& requestedProperties, EntityPropertyFlags& propertyFlags, EntityPropertyFlags& propertiesDidntFit, int& propertyCount, OctreeElement::AppendState& appendState) const { bool successPropertyFits = true; APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_COLOR, getColor()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_INTENSITY, getIntensity()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_INTENSITY, getAmbientIntensity()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_DIRECTION, getDirection()); APPEND_ENTITY_PROPERTY(PROP_KEYLIGHT_AMBIENT_URL, getAmbientURL()); return true; }