void SkinController::OnFirstUpdate() { // Get access to the vertex buffer positions to store the blended targets. Visual* visual = reinterpret_cast<Visual*>(mObject); VertexBuffer* vbuffer = visual->GetVertexBuffer().get(); if (mNumVertices == static_cast<int>(vbuffer->GetNumElements())) { // Get the position data. VertexFormat vformat = vbuffer->GetFormat(); int const numAttributes = vformat.GetNumAttributes(); for (int i = 0; i < numAttributes; ++i) { VASemantic semantic; DFType type; unsigned int unit, offset; if (vformat.GetAttribute(i, semantic, type, unit, offset)) { if (semantic == VA_POSITION && (type == DF_R32G32B32_FLOAT || type == DF_R32G32B32A32_FLOAT)) { mPosition = vbuffer->GetData() + offset; mStride = vformat.GetVertexSize(); mCanUpdate = true; break; } } } } mCanUpdate = (mPosition != nullptr); }
Point MouseEventArgs::GetPosition(UIElement* relativeTo) { gm::matrix3f m = gm::matrix3f::getIdentity(); Visual* p = relativeTo; Visual* parent; while (parent = p->get_Parent()) { Transform* transform = p->get_Transform(); if (transform) { m *= transform->get_Matrix(); } p = parent; } return m.getInverse().transform(m_clientpos); /* Visual* visual = dynamic_cast<Visual*>(relativeTo); ASSERT(visual); return visual->WindowToElement(m_windowX, m_windowY); */ }
void Pdb::Explorer() { VectorMap<String, Value> prev = DataMap(explorer); explorer.Clear(); try { String x = ~expexp; if(!IsNull(x)) { CParser p(x); Val v = Exp(p); Vis(explorer, "=", prev, Visualise(v)); if(v.type >= 0 && v.ref == 0 && !v.rvalue) Explore(v, prev); if(v.ref > 0 && GetRVal(v).address) for(int i = 0; i < 20; i++) Vis(explorer, Format("[%d]", i), prev, Visualise(DeRef(Compute(v, RValue(i), '+')))); } } catch(CParser::Error e) { Visual v; v.Cat(e, LtRed); explorer.Add("", RawPickToValue(v)); } exback.Enable(exprev.GetCount()); exfw.Enable(exnext.GetCount()); }
bool SkinController::Update(double applicationTime) { if (!Controller::Update(applicationTime)) { return false; } if (mFirstUpdate) { mFirstUpdate = false; OnFirstUpdate(); } if (mCanUpdate) { // The skin vertices are calculated in the bone world coordinate system, // so the visual's world transform must be the identity. Visual* visual = reinterpret_cast<Visual*>(mObject); visual->worldTransform = Transform::IDENTITY; visual->worldTransformIsCurrent = true; // Compute the skin vertex locations. char* current = mPosition; for (int vertex = 0; vertex < mNumVertices; ++vertex) { Vector4<float> position{ 0.0f, 0.0f, 0.0f, 0.0f }; for (int bone = 0; bone < mNumBones; ++bone) { float weight = mWeights[vertex][bone]; if (weight != 0.0f) { Vector4<float> offset = mOffsets[vertex][bone]; #if defined (GTE_USE_MAT_VEC) Vector4<float> worldOffset = mBones[bone]->worldTransform * offset; #else Vector4<float> worldOffset = offset * mBones[bone]->worldTransform; #endif position += weight * worldOffset; } } Vector3<float>* target = reinterpret_cast<Vector3<float>*>(current); (*target)[0] = position[0]; (*target)[1] = position[1]; (*target)[2] = position[2]; current += mStride; } visual->UpdateModelBound(); visual->UpdateModelNormals(); mPostUpdate(visual->GetVertexBuffer()); return true; } return false; }
geometry UIElement::MakeVisibleGeometry(geometry clip) { m_visibleGeometryValid = true; //gm::RectF bounds = clip.GetBounds(); geometry clipThis = get_Clip(); if (clipThis != nullptr) { clip &= clipThis; } #ifdef _DEBUG gm::RectF bounds = clip.GetBounds(); #endif geometry geom = GetHitGeometry(); #ifdef _DEBUG gm::RectF bounds2 = geom.GetBounds(); #endif clip &= geom; #ifdef _DEBUG gm::RectF bounds3 = clip.GetBounds(); #endif size_t nchildren = GetChildrenCount(); for (size_t i = nchildren; i > 0; --i) { Visual* child = GetChild(i-1); geometry geom2 = child->MakeVisibleGeometry(clip); clip |= geom2; } UIElement* shadowTree = get_ShadowTree(); if (shadowTree) { geometry geom2 = shadowTree->MakeVisibleGeometry(clip); #ifdef _DEBUG gm::RectF bounds5 = geom2.GetBounds(); #endif clip |= geom2; } #ifdef _DEBUG gm::RectF bounds4 = clip.GetBounds(); #endif set_VisibleGeometry(clip); return clip; }
//---------------------------------------------------------------------------- bool MorphController::Update (double applicationTime) { // The key interpolation uses linear interpolation. To get higher-order // interpolation, you need to provide a more sophisticated key (Bezier // cubic or TCB spline, for example). if (!Controller::Update(applicationTime)) { return false; } // Get access to the vertex buffer to store the blended targets. Visual* visual = StaticCast<Visual>(mObject); assertion(visual->GetVertexBuffer()->GetNumElements() == mNumVertices, "Mismatch in number of vertices.\n"); VertexBufferAccessor vba(visual); // Set vertices to target[0]. APoint* baseTarget = mVertices[0]; int i; for (i = 0; i < mNumVertices; ++i) { vba.Position<Float3>(i) = baseTarget[i]; } // Look up the bounding keys. float ctrlTime = (float)GetControlTime(applicationTime); float normTime; int i0, i1; GetKeyInfo(ctrlTime, normTime, i0, i1); // Add the remaining components in the convex composition. float* weights0 = mWeights[i0]; float* weights1 = mWeights[i1]; for (i = 1; i < mNumTargets; ++i) { // Add in the delta-vertices of target[i]. float coeff = (1.0f-normTime)*weights0[i-1] + normTime*weights1[i-1]; AVector* target = (AVector*)mVertices[i]; for (int j = 0; j < mNumVertices; ++j) { APoint position = vba.Position<Float3>(j); position += coeff*target[j]; vba.Position<Float3>(j) = position; } } visual->UpdateModelSpace(Visual::GU_NORMALS); Renderer::UpdateAll(visual->GetVertexBuffer()); return true; }
void Pdb::AddThis(const VectorMap<String, Val>& m, adr_t address, const VectorMap<String, Value>& prev) { for(int i = 0; i < m.GetCount() && self.GetCount() < 2000; i++) { Val mv = m[i]; mv.address += address; Visual vis; try { vis = Visualise(mv); } catch(CParser::Error e) { vis.Cat(e, SColorDisabled); } Vis(self, m.GetKey(i), prev, vis); } }
//---------------------------------------------------------------------------- void Delaunay3D::ChangeTetraStatus (int index, const Float4& color, bool enableWire) { Visual* tetra = DynamicCast<Visual>(mScene->GetChild(1 + index)); assertion(tetra != 0, "Expecting a Visual object.\n"); VertexBufferAccessor vba(tetra); for (int i = 0; i < 4; ++i) { vba.Color<Float4>(0, i) = color; } mRenderer->Update(tetra->GetVertexBuffer()); VisualEffectInstance* instance = tetra->GetEffectInstance(); instance->GetEffect()->GetWireState(0, 0)->Enabled = enableWire; }
void Pdb::TryAuto(const String& exp, const VectorMap<String, Value>& prev) { if(autos.Find(exp) < 0) { Visual r; try { CParser p(exp); Val v = Exp(p); Visualise(r, v, 2); } catch(CParser::Error) { r.Clear(); } if(r.part.GetCount()) Vis(autos, exp, prev, r); } }
//---------------------------------------------------------------------------- void SMShadowEffect::Draw (Renderer* renderer, const VisibleSet& visibleSet) { const int numVisible = visibleSet.GetNumVisible(); for (int j = 0; j < numVisible; ++j) { // Replace the object's effect instance by the shadow-effect instance. Visual* visual = (Visual*)visibleSet.GetVisible(j); VisualEffectInstancePtr save = visual->GetEffectInstance(); visual->SetEffectInstance(mInstance); // Draw the object using the shadow effect. renderer->Draw(visual); // Restore the object's effect instance. visual->SetEffectInstance(save); } }
void Camera::Render(Context* context) { float aspect = 1.0f; cachedproj.SetPerspective(fov, aspect, 0.1f, 100.0f); cachedview = GetWorldTransform().Inverse(); Node* root = GetRoot(); for(Node* node = root; node; node=node->GetNext()) { if(node->HasFlag(Node::VISUAL)) { Visual* visual = static_cast<Visual*>(node); visual->Render(context, this); } else if(node->HasFlag(Node::LIGHT)) { // render a light shape } } }
UIElement* UIElement::HitTest(gm::PointF point) { int nchildren = (int)GetChildrenCount(); for (int i = nchildren-1; i >= 0; --i) { Visual* child = GetChild(i); ASSERT(child); UIElement* hitElement = child->HitTest_(point); if (hitElement != nullptr) { return hitElement; } } /* // TODO remove, done above? UIElement* shadowTree = get_ShadowTree(); if (shadowTree) { UIElement* hitElement = shadowTree->HitTest_(point); if (hitElement) { return hitElement; } } */ geometry hitGeometry = GetHitGeometry(); // geometry hitGeometry = get_VisibleGeometry(); // if (hitGeometry != nullptr) { if (hitGeometry.FillContains(point)) { return this; } } return nullptr; }
//---------------------------------------------------------------------------- bool SkinController::Update (double applicationTime) { if (!Controller::Update(applicationTime)) { return false; } // Get access to the vertex buffer to store the blended targets. Visual* visual = StaticCast<Visual>(mObject); assertion(mNumVertices == visual->GetVertexBuffer()->GetNumElements(), "Controller must have the same number of vertices as the buffer\n"); VertexBufferAccessor vba(visual); // The skin vertices are calculated in the bone world coordinate system, // so the visual's world transform must be the identity. visual->WorldTransform = Transform::IDENTITY; visual->WorldTransformIsCurrent = true; // Compute the skin vertex locations. for (int vertex = 0; vertex < mNumVertices; ++vertex) { APoint position = APoint::ORIGIN; for (int bone = 0; bone < mNumBones; ++bone) { float weight = mWeights[vertex][bone]; if (weight != 0.0f) { APoint offset = mOffsets[vertex][bone]; APoint worldOffset = mBones[bone]->WorldTransform*offset; position += weight*worldOffset; } } vba.Position<Float3>(vertex) = position; } visual->UpdateModelSpace(Visual::GU_NORMALS); Renderer::UpdateAll(visual->GetVertexBuffer()); return true; }
bool Pdb::Tip(const String& exp, CodeEditor::MouseTip& mt) { /* mt.display = &StdDisplay(); mt.value = exp; mt.sz = Size(100, 20); return true;*/ DR_LOG("Pdb::Tip"); Visual r; try { CParser p(exp); Val v = Exp(p); Visualise(r, v, 2); if(r.part.GetCount()) { mt.sz = r.GetSize() + Size(4, 4); mt.value = RawPickToValue(r); mt.display = &Single<VisualDisplay>(); DR_LOG("Pdb::Tip true"); return true; } } catch(CParser::Error) {} DR_LOG("Pdb::Tip false"); return false; }
void SetWindow(CoreWindow const & window) { Compositor compositor; ContainerVisual root = compositor.CreateContainerVisual(); m_target = compositor.CreateTargetForCurrentView(); m_target.Root(root); m_visuals = root.Children(); window.PointerPressed([&](auto const &, PointerEventArgs const & args) { Point point = args.CurrentPoint().Position(); if (args.KeyModifiers() == VirtualKeyModifiers::Control) { AddVisual(point); } else { SelectVisual(point); } }); window.PointerMoved([&](auto const &, PointerEventArgs const & args) { if (m_selected) { Point point = args.CurrentPoint().Position(); m_selected.Offset(Vector3 { point.X + m_offset.X, point.Y + m_offset.Y }); } }); window.PointerReleased([&](auto const &, auto const &) { m_selected = nullptr; }); }
bool parseVisual(Visual &vis, TiXmlElement *config) { vis.clear(); // Origin TiXmlElement *o = config->FirstChildElement("origin"); if (o) { if (!parsePose(vis.origin, o)) return false; } // Geometry TiXmlElement *geom = config->FirstChildElement("geometry"); vis.geometry = parseGeometry(geom); if (!vis.geometry) return false; const char *name_char = config->Attribute("name"); if (name_char) vis.name = name_char; // Material TiXmlElement *mat = config->FirstChildElement("material"); if (mat) { // get material name if (!mat->Attribute("name")) { logError("Visual material must contain a name attribute"); return false; } vis.material_name = mat->Attribute("name"); // try to parse material element in place resetPtr(vis.material,new Material()); if (!parseMaterial(*vis.material, mat, true)) { logDebug("urdfdom: material has only name, actual material definition may be in the model"); } } return true; }
/* PUBLIC STATIC FUNCTIONS */ VisualWavesControl *VisualWavesControl::load(std::string file) { XMLNode doc = XMLNode::openFileHelper(file.c_str(), XML_WAVES_CONTROL); float width = atof(doc.getAttribute(XML_WIDTH)); std::string visualName = doc.getAttribute(XML_VISUAL); WavesGlobalState *wgs = WavesGlobalState::getInstance(); assert(wgs != NULL); const std::vector<Visual *> factoryVisuals = wgs->getFactoryVisuals(); Visual *visual = NULL; for(unsigned int i = 0; i < factoryVisuals.size(); i++) { Visual *cmp = factoryVisuals[i]; assert(cmp != NULL); if(cmp->getName() == visualName) { visual = cmp->getInstance(); break; } } if(visual == NULL) { return NULL; } else { assert(visual != NULL); XMLNode positionNode = doc.getChildNode(XML_POSITION); float x = atof(positionNode.getAttribute(XML_X)); float y = atof(positionNode.getAttribute(XML_Y)); Point2f position(x, y); std::string nickname = doc.getAttribute(XML_NICKNAME); bool forOutput = (bool)atoi(doc.getAttribute(XML_FOR_OUTPUT)); // load tracks std::vector<Track *> tracks; unsigned int trackCount = doc.nChildNode(XML_TRACK); for(unsigned int i = 0; i < trackCount; i++) { XMLNode trackNode = doc.getChildNode(XML_TRACK, i); XMLNode trackPositionNode = trackNode.getChildNode(XML_POSITION); float tx = atof(trackPositionNode.getAttribute(XML_X)); float ty = atof(trackPositionNode.getAttribute(XML_Y)); Point2f position(tx, ty); float width = atof(trackNode.getAttribute(XML_WIDTH)); float height = atof(trackNode.getAttribute(XML_HEIGHT)); std::string parameterName = trackNode.getAttribute(XML_PARAMETER); Parameter *parameter = visual->getParameter(parameterName); Track *track = new Track(position, width, height, parameter); std::map<unsigned int, SplinePreset *> &splinePresets = wgs->getSplinePresets(); Track::TrackMode mode = (Track::TrackMode)atoi(trackNode.getAttribute(XML_MODE)); track->setMode(mode); // load presets for menu unsigned int numFFTPresets = trackNode.nChildNode(XML_FFT_PRESET); for(unsigned int j = 0; j < numFFTPresets; j++) { XMLNode fftPresetNode = trackNode.getChildNode(XML_FFT_PRESET, j); unsigned int pId = atoi(fftPresetNode.getAttribute(XML_ID)); track->addFFTPreset(pId); } unsigned int numtemporalPresets = trackNode.nChildNode(XML_TEMPORAL_PRESET); for(unsigned int j = 0; j < numtemporalPresets; j++) { XMLNode temporalPresetNode = trackNode.getChildNode(XML_TEMPORAL_PRESET, j); unsigned int pId = atoi(temporalPresetNode.getAttribute(XML_ID)); track->addTemporalPreset(pId); } // load current presets (if any) std::map<unsigned int, SplinePreset *> &loadedPresets = wgs->getSplinePresets(); std::map<unsigned int, SplinePreset *> &defaultPresets = wgs->getDefaultPresets(); bool hasTemporalCurrentPreset = (bool)trackNode.isAttributeSet(XML_TEMPORAL_PRESET); if(hasTemporalCurrentPreset) { unsigned int temporalCurrentPreset = atoi(trackNode.getAttribute(XML_TEMPORAL_PRESET)); SplinePreset *sp = NULL; if(loadedPresets.count(temporalCurrentPreset) > 0) { sp = loadedPresets[temporalCurrentPreset]; } else if(defaultPresets.count(temporalCurrentPreset) > 0) { sp = defaultPresets[temporalCurrentPreset]; } if(sp != NULL) { TemporalSplineControl &temporalSplineControl = track->getTemporalSplineControl(); temporalSplineControl.loadPreset(sp); } } bool hasFFTCurrentPreset = (bool)trackNode.isAttributeSet(XML_FFT_PRESET); if(hasFFTCurrentPreset) { unsigned int FFTCurrentPreset = atoi(trackNode.getAttribute(XML_FFT_PRESET)); SplinePreset *sp = NULL; if(loadedPresets.count(FFTCurrentPreset) > 0) { sp = loadedPresets[FFTCurrentPreset]; } else if(defaultPresets.count(FFTCurrentPreset) > 0) { sp = defaultPresets[FFTCurrentPreset]; } if(sp != NULL) { FFTSplineControl &FFTSplineControl = track->getFFTSplineControl(); FFTSplineControl.loadPreset(sp); } } tracks.push_back(track); } unsigned int loadedId = atoi(doc.getAttribute(XML_ID)); VisualWavesControl *v = new VisualWavesControl(position, width, visual, tracks, nickname, forOutput); v->setEnabled(false); v->setId(loadedId); return v; } }
/** * Renders the area and all its objects. * @param rm The resource manager to use to manage models and images. */ void Area::draw(Interface* interface) { #warning ['TODO']: Delete me.... ResourceManager* rm = interface->getResourceManager(); if(!rm) { return; } glEnable(GL_LIGHTING); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE); //glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); /* This was cut, attenuation never worked right for some reason... // Disable unused lights for(int i = 0; i < MAX_LIGHTS; i++) { glDisable(GL_LIGHT0 + i); } // Process lights int light = 0; // We want to skip the first light as its a global one... for(vector<Light*>::iterator iter = lights_.begin(); iter != lights_.end(); iter++) { if(light > MAX_LIGHTS) { break; } Light* pl = *iter; if(!pl) { ERROR("A Light that is Not a light..."); continue; } glEnable(GL_LIGHT0 + light); // Set light position float position[] = {pl->getX(), pl->getY(), pl->getX(), pl->getDirectional()}; glLightfv(GL_LIGHT0 + light, GL_POSITION, position); float argba[] = {pl->ambient.red, pl->ambient.green, pl->ambient.blue, pl->ambient.alpha}; glLightfv(GL_LIGHT0+light, GL_AMBIENT, argba); float drgba[] = {pl->diffuse.red, pl->diffuse.green, pl->diffuse.blue, pl->diffuse.alpha}; glLightfv(GL_LIGHT0+light, GL_DIFFUSE, drgba); float srgba[] = {pl->specular.red, pl->specular.green, pl->specular.blue, pl->specular.alpha}; glLightfv(GL_LIGHT0+light, GL_SPECULAR, srgba); float ergba[] = {pl->emission.red, pl->emission.green, pl->emission.blue, pl->emission.alpha}; glLightfv(GL_LIGHT0+light, GL_EMISSION, ergba); glLightf(GL_LIGHT0+light, GL_CONSTANT_ATTENUATION, pl->getConstantAttenuation()); glLightf(GL_LIGHT0+light, GL_LINEAR_ATTENUATION, pl->getLinearAttenuation()); glLightf(GL_LIGHT0+light, GL_QUADRATIC_ATTENUATION, pl->getQuadraticAttenuation()); light++; }*/ glPushMatrix(); glTranslatef( TILEWIDTH * width_ / 2, 0.0f, TILEWIDTH * height_ / 2 ); for(int y = 0; y < height_; y++) { glPushMatrix(); for(int x = 0; x < width_; x++) { Tile* tile = getTile(x, y); if(tile) { if(interface->getEditMode() != MODE_NONE) { glEnable(GL_COLOR_MATERIAL); if(getSolid(x, y)) { glColor3f(1.0, 0.0, 0.0); } else { glColor3f(1.0, 1.0, 1.0); } tile->draw(interface); } else { tile->draw(interface); } } glTranslatef(-TILEWIDTH, 0.0f, 0.0f); } glPopMatrix(); glTranslatef(0.0f, 0.0f, -TILEWIDTH); } glPopMatrix(); // draw all the objects in the map for(vector<Contained*>::iterator iter = children_.begin(); iter != children_.end(); iter++) { Visual* object = dynamic_cast<Visual*>(*iter); if(object) { object->draw(interface); } } }
void UIElement::Render(ManagedRenderContext renderContext) { size_t nchildren = GetChildrenCount(); for (size_t i = 0; i < nchildren; ++i) { Visual* child = GetChild(i); child->Render_(renderContext); } if (!m_visualValid) { m_visualValid = true; if (m_visuals) { if (m_visuals->get_Children()) { m_visuals->get_Children()->m_items.clear(); } RetainedRenderContext rrc(GetRoot(), m_visuals); ManagedRetainedRenderContext retainedRenderContext(&rrc); RenderRetained(retainedRenderContext); } } if (m_visuals) { m_visuals->Render_(renderContext); } #if 0 UIElement* shadowTree = get_ShadowTree(); if (shadowTree == nullptr) { m_visuals = new GroupVisual; set_ShadowTree(m_visuals); shadowTree = m_visuals; m_visualValid = false; } if (!m_visualValid) { m_visualValid = true; if (m_visuals) { if (m_visuals->get_Children()) { m_visuals->get_Children()->m_items.clear(); } RetainedRenderContext rrc(GetRoot(), m_visuals); ManagedRetainedRenderContext retainedRenderContext(&rrc); RenderRetained(retainedRenderContext); } } shadowTree->Render_(renderContext); #endif }
void UIElement::OnComputedPropertyValueChanged(PropertyValue* pPropertyVal, bool handled) { if (pPropertyVal->m_dp == get_CursorProperty()) { IRootVisual* root = GetRoot(); if (root) { root->ElementSetMouseCursor(this); } } else if (pPropertyVal->m_dp == get_ShadowTreeProperty()) { if (!handled) { UIElement* shadowTree = get_ShadowTree(); if (shadowTree) { shadowTree->SetRoot(GetRoot()); shadowTree->set_ParentWindow(get_ParentWindow()); shadowTree->set_Parent(this); shadowTree->set_TemplatedOwner(this); InvalidateMeasure(); } } } else if (pPropertyVal->m_dp == get_ParentProperty()) { UIElement* parent = get_Parent(); if (parent) { SetTreeLevel(parent->get_TreeLevel()+1); parent->InvalidateArrange(); } else { set_TreeLevel(0); } } else if (pPropertyVal->m_dp == get_ParentWindowProperty()) { Window* parentwindow = get_ParentWindow(); UIElement* shadowTree = get_ShadowTree(); if (shadowTree) { shadowTree->set_ParentWindow(parentwindow); } size_t nchildren = GetChildrenCount(); for (size_t i = 0; i < nchildren; ++i) { Visual* child = GetChild(i); ASSERT(child); child->set_ParentWindow(parentwindow); } } else if (pPropertyVal->m_dp == get_TemplatedOwnerProperty()) { UIElement* owner = get_TemplatedOwner(); size_t nchildren = GetChildrenCount(); for (size_t i = 0; i < nchildren; ++i) { Visual* child = GetChild(i); ASSERT(child); child->set_TemplatedOwner(owner); } } else if (pPropertyVal->m_dp == get_WidthProperty()) { InvalidateMeasure(); /* float minWidth = get_MinWidth(); float width = get_Width(); if (width < minWidth) width = minWidth; set_ActualWidth(width); */ } else if (pPropertyVal->m_dp == get_HeightProperty()) { InvalidateMeasure(); /* float minHeight = get_MinHeight(); float height = get_Height(); if (height < minHeight) height = minHeight; set_ActualHeight(height); */ } else if (pPropertyVal->m_dp == get_ActualWidthProperty() || pPropertyVal->m_dp == get_ActualHeightProperty()) { #if 0 m_visibleGeometryValid = false; get_Parent(); m_measureValid = false; WindowVisual* w = dynamic_cast<WindowVisual*>(GetRoot()); if (w) { w->AddArrange(this, get_TreeLevel()); // w->m_arrangeList.push_back(this); } /* // Not here for (size_t i = 0; i < GetChildrenCount(); ++i) { Visual* child = GetChild(i); child->DoLayoutSize(); } */ #endif } baseClass::OnComputedPropertyValueChanged(pPropertyVal, handled); }
void TableView::handleEvent(System::Event* evt) { ASSERT(0); #if 0 sysstring type = evt->get_type(); if (evt->get_eventPhase() != System::CAPTURING_PHASE) { if (type == OLESTR("command")) { CommandInvokeEvent* cmdEvt = dynamic_cast<CommandInvokeEvent*>(evt); int ncolumn = cmdEvt->get_Command() - 100; Visual* column = m_list->m_treeHeader->m_columns[ncolumn]; column->put_Visibility(column->get_Visibility()==Collapsed? Visible: Collapsed); } else if (type == OLESTR("contextmenu")) { evt->stopPropagation(); MouseEvent* mouseEvt = dynamic_cast<MouseEvent*>(evt); OnContextMenu(mouseEvt); } else if (type == OLESTR("ItemStateChanging")) { evt->stopPropagation(); int index = *dynamic_cast<IntObject*>(dynamic_cast<TreeItem*>(evt->get_target())->m_itemData); Record pRecord = m_table[index]; CViewGroup* pMessage = new MailMessage; Field Subject = pRecord.get_Fields()[1]; Field Headers = pRecord.get_Fields()[3]; Field Content = pRecord.get_Fields()[4]; ScrollViewer* pScroller = new ScrollViewer; { TextEdit* textView = new TextEdit; textView->put_textDocument(new TextDocument()); textView->SetText( ConvertA2S((char*)Headers.GetData(), Headers.GetSize()) + OLESTR("\n") + ConvertA2S((char*)Content.GetData(), Content.GetSize())); pScroller->put_Content(textView); } pScroller->SetOwnerWindow(get_OwnerWindow()); // TODO remove pMessage->m_views.Add(pScroller); m_xmlDocumentWorkspace.Create(m_Canvas, pMessage); for (int i = 0; i < pMessage->m_sheets.GetSize(); i++) { CViewSheet* pViewSheet = pMessage->m_sheets[i]; sysstring str; try { str = ConvertA2S((char*)Subject.GetData(), Subject.GetSize()); } catch(int) { str = OLESTR("(Error)"); } pViewSheet->m_tabElement->set_TextContent(str); } } } #endif }
//---------------------------------------------------------------------------- void PlanarShadowEffect::Draw (Renderer* renderer, const VisibleSet& visibleSet) { // Draw the potentially visible portions of the shadow caster. const int numVisible = visibleSet.GetNumVisible(); int j; for (j = 0; j < numVisible; ++j) { renderer->Draw((const Visual*)visibleSet.GetVisible(j)); } // Save the current global state overrides for restoration later. const DepthState* saveDState = renderer->GetOverrideDepthState(); const StencilState* saveSState = renderer->GetOverrideStencilState(); // Override the global state to support this effect. renderer->SetOverrideDepthState(mDepthState); renderer->SetOverrideStencilState(mStencilState); // Get the camera to store post-world transformations. Camera* camera = renderer->GetCamera(); for (int i = 0; i < mNumPlanes; ++i) { // Enable depth buffering. NOTE: The plane object should not have a // ZBufferState object that changes the current settings. mDepthState->Enabled = true; mDepthState->Writable = true; mDepthState->Compare = DepthState::CM_LEQUAL; // Enable the stencil buffer so that the shadow can be clipped by the // plane. The stencil values are set whenever the corresponding // plane pixels are visible. mStencilState->Enabled = true; mStencilState->Compare = StencilState::CM_ALWAYS; mStencilState->Reference = (unsigned int)(i + 1); mStencilState->OnFail = StencilState::OT_KEEP; // irrelevant mStencilState->OnZFail = StencilState::OT_KEEP; // invisible to 0 mStencilState->OnZPass = StencilState::OT_REPLACE; // visible to i+1 // Draw the plane. renderer->Draw(mPlanes[i]); // Blend the shadow color with the pixels drawn on the projection // plane. The blending equation is // (rf,gf,bf) = as*(rs,gs,bs) + (1-as)*(rd,gd,bd) // where (rf,gf,bf) is the final color to be written to the frame // buffer, (rs,gs,bs,as) is the shadow color, and (rd,gd,bd) is the // current color of the frame buffer. const AlphaState* saveAState = renderer->GetOverrideAlphaState(); renderer->SetOverrideAlphaState(mAlphaState); mAlphaState->BlendEnabled = true; mAlphaState->SrcBlend = AlphaState::SBM_SRC_ALPHA; mAlphaState->DstBlend = AlphaState::DBM_ONE_MINUS_SRC_ALPHA; mMaterial->Diffuse = mShadowColors[i]; // Disable the depth buffer reading so that no depth-buffer fighting // occurs. The drawing of pixels is controlled solely by the stencil // value. mDepthState->Enabled = false; // Only draw where the plane has been drawn. mStencilState->Enabled = true; mStencilState->Compare = StencilState::CM_EQUAL; mStencilState->Reference = (unsigned int)(i + 1); mStencilState->OnFail = StencilState::OT_KEEP; // invisible kept 0 mStencilState->OnZFail = StencilState::OT_KEEP; // irrelevant mStencilState->OnZPass = StencilState::OT_ZERO; // visible set to 0 // Get the projection matrix relative to the projector (light). HMatrix projection; if (!GetProjectionMatrix(i, projection)) { continue; } camera->SetPreViewMatrix(projection); // Draw the caster again, but temporarily use a material effect so // that the shadow color is blended onto the plane. TODO: This // drawing pass should use a VisibleSet relative to the projector so // that objects that are out of view (i.e. culled relative to the // camera and not in the camera's VisibleSet) can cast shadows. for (j = 0; j < numVisible; ++j) { Visual* visual = (Visual*)visibleSet.GetVisible(j); VisualEffectInstancePtr save = visual->GetEffectInstance(); visual->SetEffectInstance(mMaterialEffectInstance); renderer->Draw(visual); visual->SetEffectInstance(save); } camera->SetPreViewMatrix(HMatrix::IDENTITY); renderer->SetOverrideAlphaState(saveAState); } // Restore the global state that existed before this function call. renderer->SetOverrideStencilState(saveSState); renderer->SetOverrideDepthState(saveDState); }
void Raytracer::SetParams(Camera* camera, const char* path, int w, int h, AntiAlias aa) { //Timer timer; raycount = 0; mode = aa; width = w; height = h; visualnodes.Clear(); visualtransforms.Clear(); visualboxes.Clear(); lightnodes.Clear(); lighttransforms.Clear(); // go through the scene graph and cache stuff Node* root = camera->GetRoot(); for(Node* node = root; node; node=node->GetNext()) { if(node->HasFlag(Node::VISUAL)) { Visual* visual = static_cast<Visual*>(node); visualnodes.PushBack(visual); visualtransforms.PushBack(visual->GetWorldTransform()); visualboxes.PushBack(visual->GetWorldBox()); } else if(node->HasFlag(Node::LIGHT)) { Light* light = static_cast<Light*>(node); lightnodes.PushBack(light); lighttransforms.PushBack(light->GetWorldTransform()); } } if(mode == ADAPTIVE) { width++; height++; } else if(mode == SUPERSAMPLE2X) { width *= 2; height *= 2; } // calculate image plane stuff float d = 10; // distance from camera to plane (n'importe quoi...) float sj = 2 * d * math::Tan(math::ToRadians(camera->GetHorizontalFov() / 2)); // width of plane float sk = sj * ((float)height/(float)width); // height origin = camera->GetWorldTransform().GetTranslation(); vector3f dirz = camera->GetWorldTransform().GetDirection(); // forward vector vector3f diry = vector3f(0,1,0); // up vector vector3f dirx = Normalize(CrossProduct(dirz,diry)); // side vector p = origin + (d * dirz) - ((sj/2) * dirx) + ((sk/2) * diry); // upper-left pixel of image plane incrementx = (sj*(1.f/(width-1))*dirx); // one-pixel increment in x direction incrementy = (sk*(1.f/(height-1))*diry); // one-pixel increment in y direction delete[] buffer; buffer = new vector3f[width * height]; setparams = true; }