Value* wRect_cf(Value** arg_list, int count) { check_arg_count(wRect, 2, count); Box2 &rect = arg_list[0]->to_box2(); Point3 color = arg_list[1]->to_point3()/255.f; GraphicsWindow *gw = MAXScript_interface->GetActiveViewExp().getGW(); if (MaxSDK::Graphics::IsRetainedModeEnabled() && gw->querySupport(GW_SPT_NUM_LIGHTS) == 0) { return &undefined; } Point3* col = NULL; // new Point3[2]; IPoint3* pts = new IPoint3[2]; // col[0]=col[1]=color; pts[0]=IPoint3((int)(rect.left),0.f,0.f); pts[1]=IPoint3((int)(rect.right),0.f,0.f); gw->setColor(LINE_COLOR, color); for (int j = rect.top; j <= rect.bottom; j++) { pts[0].y=pts[1].y=j; gw->wPolyline(2, pts, col, FALSE, NULL); } delete [] pts; // delete [] col; return &ok; }
void GeometryButton::Display(TimeValue t, ViewExp *vpt, int flags) { if ( ! vpt || ! vpt->IsAlive() ) { // why are we here? DbgAssert(!_T("Doing Display() on invalid viewport!")); return; } //set the location before it's displayed. ResetLocation(vpt); if(vpt->IsActive()==TRUE &&vpt->GetHWnd()&&GetEnabled()==true) { MSTR st = GetLabel(); vpt->getGW()->setRndLimits(vpt->getGW()->getRndMode() & ~GW_Z_BUFFER); vpt->getGW()->setColor(TEXT_COLOR, mColor); vpt->getGW()->wText(&IPoint3(mLocation.x,mLocation.y, 0), st.data()); //draw it undrneath the viewport text! } }
void MeshExtraData::BuildMeshExtraData( Mesh * mesh, int map_channel ) { // UVW Normals setup Tab <Point3> norv; int i_tf, i_tv; SetNumRVerts( mesh->numVerts ); SetNumFaces( mesh->numFaces ); SetNumUVerts( mesh->getNumMapVerts(map_channel) ); faceSel.SetSize( mesh->numFaces ); faceSel.ClearAll(); norv.SetCount( mesh->numVerts ); for (i_tv=0; i_tv<mesh->numVerts; i_tv++) { norv[i_tv] = Point3(0,0,0); } UVVert *mv = mesh->mapVerts( map_channel ); TVFace *tf = mesh->mapFaces( map_channel ); for ( i_tf = 0; i_tf < mesh->numFaces; i_tf++ ) { float a0, a1, a2, dp, lenA, lenB; Point3 v0 = mv[tf[i_tf].getTVert(0)]; Point3 v1 = mv[tf[i_tf].getTVert(1)]; Point3 v2 = mv[tf[i_tf].getTVert(2)]; lenA = Length( v1 - v0 ); lenB = Length( v2 - v0 ); if ( lenA == 0.0f || lenB == 0.0f ) { a0 = 0.0f; } else { dp = DotProd((v1-v0)/lenA,(v2-v0)/lenB); if (dp>1.0f) dp = 1.0f; if (dp<-1.0) dp = -1.0f; a0 = acos(dp); } lenA = Length( v0 - v1 ); lenB = Length( v2 - v1 ); if ( lenA == 0.0f || lenB == 0.0f ) { a1 = 0.0f; } else { dp = DotProd((v0-v1)/lenA,(v2-v1)/lenB); if (dp>1.0f) dp = 1.0f; if (dp<-1.0) dp = -1.0f; a1 = acos(dp); } a2 = PI - ( a0 + a1 ); Point3 vetnorm = (v1-v0)^(v2-v0); norv[mesh->faces[i_tf].getVert(0)] += vetnorm * a0; norv[mesh->faces[i_tf].getVert(1)] += vetnorm * a1; norv[mesh->faces[i_tf].getVert(2)] += vetnorm * a2; SetFace(i_tf, IPoint3( int(mesh->faces[i_tf].getVert(0)), int(mesh->faces[i_tf].getVert(1)), int(mesh->faces[i_tf].getVert(2))) ); } for (i_tv=0; i_tv<mesh->numVerts; i_tv++) { Point3 vnormal = Normalize(norv[i_tv]); SetRvert(i_tv,vnormal); } // Build Face Selections for ( i_tf=0; i_tf<mesh->numFaces; i_tf++ ) { if ( mv[ tf[i_tf].t[0] ] == mv[ tf[i_tf].t[1] ] && mv[ tf[i_tf].t[1] ] == mv[ tf[i_tf].t[2] ] ) faceSel.Clear(i_tf); else faceSel.Set(i_tf); } if ( faceSel.NumberSet() == 0 ) noneSel = TRUE; else noneSel = FALSE; }