void SpotLightMultiplierManipulator::UpdateShapes(TimeValue t, TSTR& toolTip) { GenLight* pLight = (GenLight*) mhTarget; Matrix3 tm; tm = mpINode->GetObjectTM(t); Point3 pt; b = GetTargetPoint(t, pt); if (!b) return; TSTR nodeName; nodeName = mpINode->GetName(); float den = FLength(tm.GetRow(2)); float targetDist = (den!=0) ? FLength(tm.GetTrans()-pt) / den : 0.0f; toolTip.printf("%s: %5.2f", "Multiplier", (double) pLight->GetIntensity(t)); SetGizmoScale(targetDist / 40.0); float dist = (targetDist / 2.0) * pLight->GetIntensity(t); ConeDistanceManipulator::UpdateShapes(Point3(0,0,0), Point3(0,0,-1), dist, pLight->GetFallsize(t), true); }
void SpotLightAttenuationManipulator::UpdateShapes(TimeValue t, TSTR& toolTip) { GenLight* pLight = (GenLight*) mhTarget; Matrix3 tm; tm = mpINode->GetObjectTM(t); Point3 pt; b = GetTargetPoint(t, pt); if (!b) return; float dist = pLight->GetAtten(t, mAttenuationType); TSTR nodeName; nodeName = mpINode->GetName(); float den = FLength(tm.GetRow(2)); float targetDist = (den!=0) ? FLength(tm.GetTrans()-pt) / den : 0.0f; toolTip.printf("%s: %5.2f", mAttenName.data(), (double) dist); SetGizmoScale(targetDist / 40.0); ConeDistanceManipulator::UpdateShapes(Point3(0,0,0), Point3(0,0,-1), dist, pLight->GetFallsize(t), false); }
void SpotLightFalloffManipulator::UpdateShapes(TimeValue t, TSTR& toolTip) { GenLight* pLight = (GenLight*) mhTarget; Matrix3 tm; tm = mpINode->GetObjectTM(t); Point3 pt; float dist; BOOL b = GetTargetPoint(t, pt); if (!b) { dist = pLight->GetTDist(t); } else { float den = FLength(tm.GetRow(2)); dist = (den!=0) ? FLength(tm.GetTrans()-pt) / den : 0.0f; } TSTR nodeName; nodeName = mpINode->GetName(); toolTip.printf("%s [Falloff: %5.2f]", nodeName.data(), (double) pLight->GetFallsize(t)); SetGizmoScale(dist / kRingScaleFactor); ConeAngleManipulator::SetValues(Point3(0,0,0), Point3(0,0,-1), dist, DegToRad(pLight->GetFallsize(t)), pLight->GetSpotShape() == RECT_LIGHT, pLight->GetAspect(t)); }
void SpotLightFalloffManipulator::UpdateShapes(TimeValue t, TSTR& toolTip) { GenLight* pLight = (GenLight*) mhTarget; Matrix3 tm; tm = mpINode->GetObjectTM(t); Point3 pt; b = GetTargetPoint(t, pt); if (!b) return; float den = FLength(tm.GetRow(2)); float dist = (den!=0) ? FLength(tm.GetTrans()-pt) / den : 0.0f; TSTR nodeName; nodeName = mpINode->GetName(); tm = Inverse(tm); toolTip.printf("Falloff: %5.2f", (double) pLight->GetFallsize(t)); SetGizmoScale(dist / kRingScaleFactor); ConeAngleManipulator::UpdateShapes(Point3(0,0,0), Point3(0,0,-1), dist, pLight->GetFallsize(t)); }
// From BaseObject int TapeHelpObject::DrawLine(TimeValue t, INode* inode, GraphicsWindow *gw, int drawing ) { Matrix3 tm = inode->GetObjectTM(t); gw->setTransform(tm); gw->clearHitCode(); Point3 pt,v[3]; if (GetTargetPoint(t,inode,pt)) { float den = Length(tm.GetRow(2)); float dist = (den!=0)?Length(tm.GetTrans()-pt)/den : 0.0f; if(!inode->IsFrozen() && !inode->Dependent() && drawing) gw->setColor( LINE_COLOR, GetUIColor(COLOR_TAPE_OBJ)); if (drawing) { if(specLenState) { GetLinePoints(t, v, GetLength(t) ); if(drawing == -1) v[1] = 0.9f * v[1]; } else { v[0] = Point3(0,0,0); if(drawing == -1) // hit-testing! Shorten the line so target can be picked v[1] = Point3(0.0f, 0.0f, -0.9f * dist); else v[1] = Point3(0.0f, 0.0f, -dist); } gw->polyline( 2, v, NULL, NULL, FALSE, NULL ); } } return gw->checkHitCode(); }
void TapeHelpObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box ) { if ( ! vpt || ! vpt->IsAlive() ) { box.Init(); return; } int i, nv; Matrix3 tm; float dtarg; Point3 pt; Point3 q[2]; GetMat(t,inode,*vpt,tm); nv = mesh.getNumVerts(); box.Init(); for (i=0; i<nv; i++) box += tm*mesh.getVert(i); if (GetTargetPoint(t,inode,pt)) { tm = inode->GetObjectTM(t); dtarg = Length(tm.GetTrans()-pt)/Length(tm.GetRow(2)); box += tm*Point3(float(0),float(0),-dtarg); } if(GetSpecLen()) { GetLinePoints(t, q, GetLength(t) ); box += tm * q[0]; box += tm * q[1]; } }
void TapeHelpObject::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box ) { if ( ! vpt || ! vpt->IsAlive() ) { box.Init(); return; } Matrix3 m = inode->GetObjectTM(t); Point3 pt; Point3 q[4]; float scaleFactor = vpt->NonScalingObjectSize()*vpt->GetVPWorldWidth(m.GetTrans())/(float)360.0; box = mesh.getBoundingBox(); box.Scale(scaleFactor); float d; if (GetTargetPoint(t,inode,pt)) { d = Length(m.GetTrans()-pt)/Length(inode->GetObjectTM(t).GetRow(2)); box += Point3(float(0),float(0),-d); } if(GetSpecLen()) { GetLinePoints(t, q, GetLength(t) ); box += q[0]; box += q[1]; } }
void ProtHelpObject::GetLocalBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box ) { if ( ! vpt || ! vpt->IsAlive() ) { box.Init(); return; } Matrix3 m = inode->GetObjectTM(t); Point3 pt; Point3 q[4]; float scaleFactor = vpt->NonScalingObjectSize()*vpt->GetVPWorldWidth(m.GetTrans())/360.0f; box = mesh.getBoundingBox(); box.Scale(scaleFactor); if (GetTargetPoint(0, t, &pt)) box += Inverse(m) * pt; if (GetTargetPoint(1, t, &pt)) box += Inverse(m) * pt; }
void ProtHelpObject::GetWorldBoundBox(TimeValue t, INode* inode, ViewExp* vpt, Box3& box ) { if ( ! vpt || ! vpt->IsAlive() ) { box.Init(); return; } int i, nv; Matrix3 tm; Point3 pt; GetMat(t,inode,*vpt,tm); nv = mesh.getNumVerts(); box.Init(); for (i=0; i<nv; i++) box += tm*mesh.getVert(i); if (GetTargetPoint(0, t, &pt)) box += pt; if (GetTargetPoint(1, t, &pt)) box += pt; }
int TapeHelpObject::Display(TimeValue t, INode* inode, ViewExp *vpt, int flags) { if ( ! vpt || ! vpt->IsAlive() ) { // why are we here DbgAssert(!_T("Invalid viewport!")); return FALSE; } Matrix3 m; GraphicsWindow *gw = vpt->getGW(); Material *mtl = gw->getMaterial(); GetMat(t,inode,*vpt,m); gw->setTransform(m); DWORD rlim = gw->getRndLimits(); gw->setRndLimits(GW_WIREFRAME|GW_EDGES_ONLY|GW_BACKCULL| (rlim&GW_Z_BUFFER) ); if (inode->Selected()) gw->setColor( LINE_COLOR, GetSelColor()); else if(!inode->IsFrozen() && !inode->Dependent()) gw->setColor( LINE_COLOR, GetUIColor(COLOR_TAPE_OBJ)); mesh.render( gw, mtl, NULL, COMP_ALL); DrawLine(t,inode,gw,1); gw->setRndLimits(rlim); if(editting && !specLenState) { Point3 pt(0,0,0); Matrix3 tm = inode->GetObjectTM(t); GetTargetPoint(t,inode,pt); float den = Length(tm.GetRow(2)); float dist = (den!=0)?Length(tm.GetTrans()-pt)/den : 0.0f; lengthSpin->SetValue( lastDist = dist, FALSE ); } if(editting) { m.NoTrans(); dirPt = m * Point3(0,0,1); float len = Length(dirPt); if(len != 0) dirPt *= 1.0f/len; UpdateUI(iObjParams->GetTime()); } return(0); }
void SpotLightMultiplierManipulator::SetDistance(float distance) { GenLight* pLight = (GenLight*) mhTarget; TimeValue t = GetCOREInterface()->GetTime(); Matrix3 tm; tm = mpINode->GetObjectTM(GetCOREInterface()->GetTime()); Point3 pt; b = GetTargetPoint(t, pt); if (!b) return; TSTR nodeName; nodeName = mpINode->GetName(); float den = FLength(tm.GetRow(2)); float targetDist = (den!=0) ? FLength(tm.GetTrans()-pt) / den : 0.0f; float mult = 2.0 * distance / targetDist; pLight->SetIntensity(t, mult); }
void TapeHelpObject::Snap(TimeValue t, INode* inode, SnapInfo *snap, IPoint2 *p, ViewExp *vpt) { if ( ! vpt || ! vpt->IsAlive() ) { // why are we here DbgAssert(!_T("Invalid viewport!")); return; } // Make sure the vertex priority is active and at least as important as the best snap so far if(snap->vertPriority > 0 && snap->vertPriority <= snap->priority) { Matrix3 tm = inode->GetObjectTM(t); GraphicsWindow *gw = vpt->getGW(); gw->setTransform(tm); Matrix3 invPlane = Inverse(snap->plane); Point2 fp = Point2((float)p->x, (float)p->y); IPoint3 screen3; Point2 screen2; // Get the two endpoints Point3 pt,v[2]; if (GetTargetPoint(t,inode,pt)) { float den = Length(tm.GetRow(2)); float dist = (den!=0)?Length(tm.GetTrans()-pt)/den : 0.0f; if(specLenState) GetLinePoints(t, v, GetLength(t) ); else { v[0] = Point3(0,0,0); v[1] = Point3(0.0f, 0.0f, -dist); } for(int i = 0; i < 2; ++i) { Point3 thePoint = v[i]; // If constrained to the plane, make sure this point is in it! if(snap->snapType == SNAP_2D || snap->flags & SNAP_IN_PLANE) { Point3 test = thePoint * tm * invPlane; if(fabs(test.z) > 0.0001) // Is it in the plane (within reason)? return; } gw->wTransPoint(&thePoint,&screen3); screen2.x = (float)screen3.x; screen2.y = (float)screen3.y; // Are we within the snap radius? int len = (int)Length(screen2 - fp); if(len <= snap->strength) { // Is this priority better than the best so far? if(snap->vertPriority < snap->priority) { snap->priority = snap->vertPriority; snap->bestWorld = thePoint * tm; snap->bestScreen = screen2; snap->bestDist = len; } else if(len < snap->bestDist) { snap->priority = snap->vertPriority; snap->bestWorld = thePoint * tm; snap->bestScreen = screen2; snap->bestDist = len; } } } } } }