int TriPatchObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) { if ( ! vpt || ! vpt->IsAlive() ) { // why are we here DbgAssert(!_T("Invalid viewport!")); return FALSE; } Matrix3 tm; GraphicsWindow *gw = vpt->getGW(); gw->setTransform(inode->GetObjectTM(t)); UpdatePatchMesh(t); if(!MaxSDK::Graphics::IsRetainedModeEnabled()) { if(!(gw->getRndMode() & GW_BOX_MODE)) { PrepareMesh(t); Mesh& mesh = patch.GetMesh(); if(mesh.getNumVerts()) { mesh.render( gw, inode->Mtls(), (flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL | (inode->Selected()?COMP_OBJSELECTED:0), inode->NumMtls()); } } } patch.render( gw, inode->Mtls(), (flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL | (inode->Selected()?COMP_OBJSELECTED:0), inode->NumMtls()); return(0); }
int TriPatchObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) { Matrix3 tm; GraphicsWindow *gw = vpt->getGW(); gw->setTransform(inode->GetObjectTM(t)); UpdatePatchMesh(t); if(!(gw->getRndMode() & GW_BOX_MODE)) { PrepareMesh(t); Mesh& mesh = patch.GetMesh(); if(mesh.getNumVerts()) { mesh.render( gw, inode->Mtls(), (flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL | (inode->Selected()?COMP_OBJSELECTED:0), inode->NumMtls()); } } patch.render( gw, inode->Mtls(), (flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL | (inode->Selected()?COMP_OBJSELECTED:0), inode->NumMtls()); return(0); }
Value* getRndMode_cf(Value** arg_list, int count) { check_arg_count(getRndMode, 0, count); def_render_types(); one_typed_value_local(Array* result); GraphicsWindow *gw = MAXScript_interface->GetActiveViewExp().getGW(); if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0) { return &undefined; } DWORD mode = gw->getRndMode(); vl.result = new Array(3); for (int i=0; i < elements(renderTypes); i++) if ((renderTypes[i].id) & mode) vl.result->append(renderTypes[i].val); return_value (vl.result); // LAM - 5/18/01 - was return vl.result }
int TriObject::Display(TimeValue t, INode *inode, ViewExp* vpt, int flags) { if ( ! vpt || ! vpt->IsAlive() ) { // why are we here DbgAssert(!_T("Invalid viewport!")); return FALSE; } float *vsw = NULL; DWORD oldRndLimits, newRndLimits; Tab<VertColor> vertexSelColors; Tab<TVFace> vertexSelFaces; Matrix3 tm; GraphicsWindow *gw = vpt->getGW(); gw->setTransform(inode->GetObjectTM(t)); newRndLimits = oldRndLimits = gw->getRndLimits(); // CAL-11/16/01: Use soft selection colors when soft selection is turned on in sub-object mode. // The condition is satisfied if the display of vertex/edge/face/poly is requested and // the vertex selection weights are set. // CAL-12/02/01: Add one more checking to the condition to check if the display of soft // selection using wireframe or vertex color shading is requested. // CAL-11/16/01: (TODO) To imporvement the performance of this function, // vertexSelColors & vertexSelFaces tables can be cached (in Mesh) and used as long as // the vertex selection weights are not changed. bool dspSoftSelVert = ((gw->getRndMode()&GW_VERT_TICKS) || ((mesh.dispFlags&DISP_VERTTICKS) && (flags&DISP_SHOWSUBOBJECT))) && (mesh.dispFlags&DISP_SELVERTS); bool dspSoftSelEdFc = ((mesh.dispFlags&DISP_SELEDGES) || (mesh.dispFlags&DISP_SELFACES) || (mesh.dispFlags&DISP_SELPOLYS)) && (flags&DISP_SHOWSUBOBJECT); bool dspWireSoftSel = (oldRndLimits&GW_WIREFRAME) || ((oldRndLimits&GW_COLOR_VERTS) && (inode->GetVertexColorType() == nvct_soft_select)); if ((dspSoftSelVert || dspSoftSelEdFc) && dspWireSoftSel && (vsw = mesh.getVSelectionWeights())) { Point3 clr = GetUIColor(COLOR_VERT_TICKS); vertexSelColors.SetCount(mesh.getNumVerts()); vertexSelFaces.SetCount(mesh.getNumFaces()); // Create the array of colors, one per vertex: for (int i=0; i<mesh.getNumVerts(); i++) { // (Note we may want a different color - this gives the appropriate vertex-tick // color, which we may not want to use on faces. Fades from blue to red.) vertexSelColors[i] = (vsw[i]) ? SoftSelectionColor(vsw[i]) : clr; } // Copy over the face topology exactly to the map face topology: for (i=0; i<mesh.getNumFaces(); i++) { DWORD *pv = mesh.faces[i].v; vertexSelFaces[i].setTVerts(pv[0], pv[1], pv[2]); } // CAL-05/21/02: make sure there's data before accessing it. // Set the mesh to use these colors: mesh.setVCDisplayData (MESH_USE_EXT_CVARRAY, (vertexSelColors.Count() > 0) ? vertexSelColors.Addr(0) : NULL, (vertexSelFaces.Count() > 0) ? vertexSelFaces.Addr(0) : NULL); // Turn on vertex color mode if (oldRndLimits&GW_WIREFRAME) { newRndLimits |= GW_COLOR_VERTS; // turn on vertex colors newRndLimits &= ~GW_SHADE_CVERTS; // turn off vertex color shading newRndLimits |= GW_ILLUM; // turn on lit wire frame gw->setRndLimits(newRndLimits); } } else { switch (inode->GetVertexColorType()) { case nvct_color: if (mesh.curVCChan == 0) break; mesh.setVCDisplayData (0); break; case nvct_illumination: if (mesh.curVCChan == MAP_SHADING) break; mesh.setVCDisplayData (MAP_SHADING); break; case nvct_alpha: if (mesh.curVCChan == MAP_ALPHA) break; mesh.setVCDisplayData (MAP_ALPHA); break; //case nvct_color_plus_illum: // if (mesh.curVCChan == MESH_USE_EXT_CVARRAY) break; // Where do I cache the arrays I'll need to create from the color and illum arrays? // break; // CAL-06/15/03: add a new option to view map channel as vertex color. (FID #1926) case nvct_map_channel: if (mesh.curVCChan == inode->GetVertexColorMapChannel()) break; mesh.setVCDisplayData (inode->GetVertexColorMapChannel()); break; case nvct_soft_select: // Turn off vertex color if soft selection is not on. if (oldRndLimits&GW_COLOR_VERTS) { newRndLimits &= ~GW_COLOR_VERTS; gw->setRndLimits(newRndLimits); } break; } } mesh.render( gw, inode->Mtls(), (flags&USE_DAMAGE_RECT) ? &vpt->GetDammageRect() : NULL, COMP_ALL | ((flags&DISP_SHOWSUBOBJECT)?COMP_OBJSELECTED:0), inode->NumMtls(), (InterfaceServer*)this); // NS: 9/22/00 Added IXTCAccess argument for Vertex Shader support. // RB: The mesh flag COMP_OBJSELECTED is sort of misnamed. When this bit is set, sub object things (like ticks and selected faces) will be drawn. if ( vsw ) mesh.setVCDisplayData (MESH_USE_EXT_CVARRAY); if (newRndLimits != oldRndLimits) gw->setRndLimits(oldRndLimits); return(0); }