本文整理汇总了C++中Point3函数的典型用法代码示例。如果您正苦于以下问题:C++ Point3函数的具体用法?C++ Point3怎么用?C++ Point3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Point3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: proc
IPoint2 mSp0;
Point3 mP0;
public:
int proc( ViewExp *vpt,int msg, int point, int flags, IPoint2 m, Matrix3& mat );
void SetObj(LuminaireObject *obj) { mpObject = obj; }
};
static LuminaireObjectCreateCallBack gLuminaireCreateCB;
//===========================================================================
// LuminaireObject implementation
//===========================================================================
const TCHAR LuminaireObject::mInternalClassName[] = _T("LuminaireHelper");
const Box3 LuminaireObject::mDefBoxSize(Point3(-10, -10, 0), Point3(10, 10, 20));
//---------------------------------------------------------------------------
// Constructor/Destructor
LuminaireObject::LuminaireObject()
: mpBlock(NULL)
{
GetLuminaireDesc()->MakeAutoParamBlocks(this);
SetBox(const_cast<Box3&>(mDefBoxSize));
dumFlags &= ~MESH_VALID;
}
LuminaireObject::~LuminaireObject()
{
DeleteAllRefsFromMe();
示例2: pabs
static inline Point3 pabs(Point3 p) { return Point3(fabs(p.x),fabs(p.y),fabs(p.z)); }
示例3: TimeValue
void ExtrudeMod::BuildMeshFromShape(TimeValue t,ModContext &mc, ObjectState * os, Mesh &mesh, BOOL simple) {
BOOL texturing;
pblock->GetValue(PB_MAPPING, TimeValue(0), texturing, FOREVER);
BOOL genMatIDs;
pblock->GetValue(PB_GEN_MATIDS, TimeValue(0), genMatIDs, FOREVER);
BOOL useShapeIDs;
pblock->GetValue(PB_USE_SHAPEIDS, TimeValue(0), useShapeIDs, FOREVER);
BOOL smooth;
pblock->GetValue(PB_SMOOTH, TimeValue(0), smooth, FOREVER);
ShapeObject *shape = (ShapeObject *)os->obj;
float amount;
int levels,capStart,capEnd,capType;
pblock->GetValue(PB_AMOUNT,t,amount,FOREVER);
if(simple) {
levels = 1;
capStart = capEnd = FALSE;
}
else {
pblock->GetValue(PB_SEGS,t,levels,FOREVER);
if (levels<1) levels = 1;
pblock->GetValue(PB_CAPSTART,t,capStart,FOREVER);
pblock->GetValue(PB_CAPEND,t,capEnd,FOREVER);
}
pblock->GetValue(PB_CAPTYPE,t,capType,FOREVER);
LimitValue(amount, -1000000.0f, 1000000.0f);
// Get the basic dimension stuff
float zSize = (float)fabs(amount);
float baseZ = 0.0f;
if(amount < 0.0f)
baseZ = amount;
// Make the shape convert itself to a PolyShape -- This makes our mesh conversion MUCH easier!
PolyShape pShape;
shape->MakePolyShape(t, pShape);
ShapeHierarchy hier;
pShape.OrganizeCurves(t, &hier);
// Need to flip the reversed curves in the shape!
pShape.Reverse(hier.reverse);
int polys = pShape.numLines;
int levelVerts = 0, levelFaces = 0, levelTVerts = 0;
int verts = 0, faces = 0, tVerts = 0;
int poly, piece;
BOOL anyClosed = FALSE;
for(poly = 0; poly < polys; ++poly) {
PolyLine &line = pShape.lines[poly];
if(!line.numPts)
continue;
if(line.IsClosed()) {
anyClosed = TRUE;
levelTVerts++;
}
levelVerts += line.numPts;
levelTVerts += line.numPts;
levelFaces += (line.Segments() * 2);
}
int vertsPerLevel = levelVerts;
int numLevels = levels;
verts = levelVerts * (levels + 1);
tVerts = levelTVerts * (levels + 1);
faces = levelFaces * levels;
mesh.setNumVerts(verts);
mesh.setNumFaces(faces);
if(texturing) {
mesh.setNumTVerts(tVerts);
mesh.setNumTVFaces(faces);
}
// Create the vertices!
int vert = 0;
int tvertex = 0;
int level;
Point3 offset1, offset2;
for(poly = 0; poly < polys; ++poly) {
PolyLine &line = pShape.lines[poly];
if(!line.numPts)
continue;
if(texturing) {
//DebugPrint(_T("Texture Verts:\n"));
BOOL usePhysUVs = GetUsePhysicalScaleUVs();
int tp;
int texPts = line.numPts + (line.IsClosed() ? 1 : 0);
float *texPt = new float [texPts];
float lastPt = (float)(texPts - 1);
float cumLen = 0.0f;
float totLen = line.CurveLength();
Point3 prevPt = line.pts[0].p;
for(tp = 0; tp < texPts; ++tp) {
int ltp = tp % line.numPts;
if(tp == (texPts - 1))
//.........这里部分代码省略.........
示例4: return
bool Lighting::EvaluateLighting(LPDIRECT3DDEVICE9 Device, RenderMesh *RMesh, ShaderMat *Mat)
{
D3DLIGHT9 DLight;
D3DXVECTOR3 Pos,Dir;
RenderLight Light;
int i;
if(!Device || !RMesh || !m_Ready)
{
return(false);
}
m_Device = Device;
//
// Setup
//
// The force update is used when the scene is in an unknwon state - usual after a an undo of a light
if(m_forceUpdate)
GetLightsFromScene();
UpdateLights();
SetRenderStates();
// m_Lights.clear();
if(m_Lights.size())
{
for(i=0; i < m_Lights.size(); i++)
{
SetShader(m_Lights[i].m_Type,Mat);
SetMaterialConst(Mat);
SetShaderConst(i,&m_Lights[i],Mat);
RMesh->Render(m_Device);
}
}
else
{
m_Device->GetLight(0,&DLight);
Light.m_Dir = Point3(-DLight.Direction.x,
-DLight.Direction.y,
-DLight.Direction.z);
Light.m_Color.x = DLight.Diffuse.r;
Light.m_Color.y = DLight.Diffuse.g;
Light.m_Color.z = DLight.Diffuse.b;
Light.m_Pos.x = DLight.Position.x;
Light.m_Pos.y = DLight.Position.y;
Light.m_Pos.z = DLight.Position.z;
Light.m_InnerRange = 1.0f;
Light.m_OuterRange = 1.0f / (DLight.Range * 2.0f);
SetShader(LIGHT_DIR,Mat);
SetMaterialConst(Mat);
SetShaderConst(0,&Light,Mat);
RMesh->Render(m_Device);
}
return(true);
}
示例5: Point3
Point3 SContext::DP(void)
{
float d = (1.0f+DFACT)*(RayDiam())/(DFACT+(float)fabs(DotProd(Normal(),viewDir)));
return Point3(d,d,d);
}
示例6: Point3
Point3 UVtex::EvalNormalPerturb(ShadeContext& sc) {
return Point3(0,0,0);
}
示例7: DbgAssert
//The display function that is used to display the formation.
int FormationBhvr::Display(TimeValue t, ViewExp *vpt)
{
if ( ! vpt || ! vpt->IsAlive() )
{
// why are we here
DbgAssert(!_T("Doing Display() on invalid viewport!"));
return FALSE;
}
// setup
int i,j;
if(DisplayFormation(t)==FALSE) return FALSE;
if(GetFollowerCount(t)<=0) return FALSE;
if(GetFollowerMatrixCount(t)<=0) return FALSE;
INode *leaderNode;
leaderNode = GetLeader(t);
if(leaderNode==NULL) return FALSE;
//check tgo see if we have created a default sphere for drawing yet...
//if we haven't then create it..
if (numpts == 0)
GetSpherePoints(Point3(0.0f,0.0f,0.0f), 1.0, SpherePts);
GraphicsWindow *gw = vpt->getGW();
//set the identity matrix...
Matrix3 idMat;
idMat.IdentityMatrix();
gw->setTransform(idMat);
gw->setColor(LINE_COLOR,.815f,.976f,1.0f);
float scaleRadius = GetDisplayScale(t);
//set the drawing radius values based upon what the radius size is.
for (i=0; i<NUMAROUND * 3; i++) ScaledPts[i] = ((SpherePts[i] * scaleRadius));
//for each follower we need to increase the bounding box by it's
//world position location...
for(i =0;i<GetFollowerCount(t);i++)
{
INode *followerNode = GetFollower(t,i);
if(followerNode) //if we have a a node...
{
Matrix3 leaderMat = GetCurrentMatrix(leaderNode,t);
leaderMat.NoScale();
Matrix3 followerMat = GetFollowerMatrix(t,i);
Matrix3 worldSpace = followerMat *leaderMat;
for (j=0; j<NUMAROUND * 3; j++) CurPts[j] = worldSpace*ScaledPts[j]; //adding the center to the point positions
gw->polyline(NUMAROUND,&CurPts[0],NULL,NULL,TRUE,NULL);
gw->polyline(NUMAROUND,&CurPts[NUMAROUND],NULL,NULL,TRUE,NULL);
gw->polyline(NUMAROUND,&CurPts[NUMAROUND * 2],NULL,NULL,TRUE,NULL);
}
}
return TRUE;
}
示例8: sin
const Point3 TrigonometricCurve::operator()(const double u, Vector3 *dp_du,
Vector3 *d2p_du2) const
//
// returns ths position of the curve at the parameter `u` (0 <= `u`
// <= 1). If `dp_du` is not NULL, it will be set to the path
// derivative vector at `u`. If `d2p_du2` is not NULL, it will be set
// the the second path derivative vector.
//
// Note: the path derivatives are *not* normalized. If the components
// of the path had dimensions of length (i.e. the path was a
// position) and `u` had dimensions of time, the path derivatives
// `dp_du` and `d2p_du2` would be a velocity and an acceleration,
// respectively. If the caller wants a unit-length (dimensionless)
// vector, it is up to them to normalize a derivative upon its
// return.
//
{
//
// ASSIGNMENT (PA09)
//
// Enhance your previous (PA06) solution to set `*d2p_du2` to the
// (second) path derivative as per the function header. Use your
// knowledge of calculus to compute it.
//
// 15 lines in instructor solution (YMMV)
//
if (dp_du)
{
/*
* Derivative is -2PI * freq * mag * sin(2PI *( freq * u + phase))
*/
// Derivative
dp_du->u.g.x = -2 * M_PI * freq.u.g.x * mag.u.g.x * sin(2 * M_PI * (freq.u.g.x * u + phase.u.g.x));
dp_du->u.g.y = -2 * M_PI * freq.u.g.y * mag.u.g.y * sin(2 * M_PI * (freq.u.g.y * u + phase.u.g.y));
dp_du->u.g.z = -2 * M_PI * freq.u.g.z * mag.u.g.z * sin(2 * M_PI * (freq.u.g.z * u + phase.u.g.z));
}
if (d2p_du2)
{
/*
* Second derivative is -4PI^2 * freq^2 * max * cos(2PI * (freq * u + phase))
*/
dp_du->u.g.x = (-4 * (M_PI * M_PI) * (freq.u.g.x * freq.u.g.x) * mag.u.g.x) * cos(2 * M_PI * (freq.u.g.x * u + phase.u.g.x));
dp_du->u.g.y = (-4 * (M_PI * M_PI) * (freq.u.g.y * freq.u.g.y) * mag.u.g.y) * cos(2 * M_PI * (freq.u.g.y * u + phase.u.g.y));
dp_du->u.g.z = (-4 * (M_PI * M_PI) * (freq.u.g.z * freq.u.g.z) * mag.u.g.z) * cos(2 * M_PI * (freq.u.g.z * u + phase.u.g.z));
}
Vec3 angle = 2 * M_PI * (freq * u + phase);
double x = mag.u.g.x * cos(angle.u.g.x) + offset.u.g.x;
double y = mag.u.g.y * cos(angle.u.g.y) + offset.u.g.y;
double z = mag.u.g.z * cos(angle.u.g.z) + offset.u.g.z;
Point3 value = Point3(x, y, z);
return value;
}
示例9: __declspec
// Let the plug-in register itself for deferred loading
__declspec( dllexport ) ULONG CanAutoDefer()
{
return 1;
}
/* rand returns a number between 0 and 32767 */
/* number between 0 and 1 */
const float IntMax=32767.0f;
const float IntMax1=32768.0f;
const float HalfIntMax=16383.5f;
typedef float Matrix3By3[3][3];
typedef float Matrix4By3[4][3];
Point3 Zero=Point3(0.0f,0.0f,0.0f);
int FloatEQ0(float number)
{ return((FLOAT_EPSILON>=number)&&(number>=-FLOAT_EPSILON));}
int SmallerEQ0(float number)
{ return((SMALL_EPSILON>=number)&&(SMALL_EPSILON>=-FLOAT_EPSILON));}
int FGT0(Point3 p1)
{ return((fabs(p1[0])>SMALL_EPSILON)||(fabs(p1[1])>SMALL_EPSILON)||(fabs(p1[2])>SMALL_EPSILON));}
void Mult1X4(float *A,Matrix4By4 B,float *C)
{ C[0]=A[0]*B[0][0]+A[1]*B[1][0]+A[2]*B[2][0]+A[3]*B[3][0];
C[1]=A[0]*B[0][1]+A[1]*B[1][1]+A[2]*B[2][1]+A[3]*B[3][1];
C[2]=A[0]*B[0][2]+A[1]*B[1][2]+A[2]*B[2][2]+A[3]*B[3][2];
C[3]=A[0]*B[0][3]+A[1]*B[1][3]+A[2]*B[2][3]+A[3]*B[3][3];
示例10: pnorm
void UnwrapMod::fnAlignAndFit(int axis)
{
//get our selection
Box3 bounds;
bounds.Init();
//get the bounding box
Point3 pnorm(0.0f,0.0f,0.0f);
int ct = 0;
TimeValue t = GetCOREInterface()->GetTime();
for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
{
MeshTopoData *ld = mMeshTopoData[ldID];
Matrix3 tm = mMeshTopoData.GetNodeTM(t,ldID);
for (int k = 0; k < ld->GetNumberFaces(); k++)
{
if (ld->GetFaceSelected(k))
{
// Grap the three points, xformed
int pcount = 3;
// if (gfaces[k].flags & FLAG_QUAD) pcount = 4;
pcount = ld->GetFaceDegree(k);//gfaces[k]->count;
Point3 temp_point[4];
for (int j=0; j<pcount; j++)
{
int index = ld->GetFaceGeomVert(k,j);//gfaces[k]->t[j];
bounds += ld->GetGeomVert(index) *tm;//gverts.d[index].p;
if (j < 4)
temp_point[j] = ld->GetGeomVert(index);//gverts.d[index].p;
}
pnorm += VectorTransform(Normalize(temp_point[1]-temp_point[0]^temp_point[2]-temp_point[1]),tm);
ct++;
}
}
}
if (ct == 0) return;
theHold.Begin();
SuspendAnimate();
AnimateOff();
pnorm = pnorm / (float) ct;
Matrix3 tm(1);
//if just a primary axis set the tm;
Point3 center = bounds.Center();
// build the scale
Point3 scale(bounds.Width().x ,bounds.Width().y , bounds.Width().z);
if (scale.x == 0.0f) scale.x = 1.0f;
if (scale.y == 0.0f) scale.y = 1.0f;
if (scale.z == 0.0f) scale.z = 1.0f;
if (axis == 0) // x axi
{
tm.SetRow(0,Point3(0.0f,-scale.y,0.0f));
tm.SetRow(1,Point3(0.0f,0.0f,scale.z));
tm.SetRow(2,Point3(scale.x,0.0f,0.0f));
if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP) || (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
tm.SetRow(3,center);
else if (fnGetMapMode() == CYLINDRICALMAP)
{
center.x = bounds.pmin.x;
tm.SetRow(3,center);
}
Matrix3 ptm(1), id(1);
tm = tm ;
SetXFormPacket tmpck(tm,ptm);
tmControl->SetValue(t,&tmpck,TRUE,CTRL_RELATIVE);
}
else if (axis == 1) // y axi
{
tm.SetRow(0,Point3(scale.x,0.0f,0.0f));
tm.SetRow(1,Point3(0.0f,0.0f,scale.z));
tm.SetRow(2,Point3(0.0f,scale.y,0.0f));
if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP)|| (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
tm.SetRow(3,center);
else if (fnGetMapMode() == CYLINDRICALMAP)
{
center.y = bounds.pmin.y;
tm.SetRow(3,center);
}
Matrix3 ptm(1), id(1);
tm = tm;
SetXFormPacket tmpck(tm,ptm);
tmControl->SetValue(t,&tmpck,TRUE,CTRL_RELATIVE);
}
else if (axis == 2) //z axi
{
tm.SetRow(0,Point3(scale.x,0.0f,0.0f));
tm.SetRow(1,Point3(0.0f,scale.y,0.0f));
tm.SetRow(2,Point3(0.0f,0.0f,scale.z));
if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP)|| (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
//.........这里部分代码省略.........
示例11: ComputeSelectedFaceData
void UnwrapMod::DrawGizmo(TimeValue t, INode* inode,/*w4 ModContext *mc, */GraphicsWindow *gw)
{
ComputeSelectedFaceData();
Matrix3 vtm(1);
Interval iv;
if (inode)
vtm = inode->GetObjectTM(t,&iv);
Point3 a(-0.5f,-0.5f,0.0f),b(0.5f,-0.5f,0.0f),c(0.5f,0.5f,0.0f),d(-0.5f,0.5f,0.0f);
Matrix3 modmat, ntm = inode->GetObjectTM(t);
modmat = GetMapGizmoMatrix(t);
gw->setTransform(modmat);
if ( (fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP) )
{
Point3 line[5];
line[0] = a;
line[1] = b;
line[2] = c;
line[3] = d;
line[4] = line[0];
gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
gw->polyline(5, line, NULL, NULL, 0);
}
else if (fnGetMapMode() == CYLINDRICALMAP)
{
//draw the bottom circle
int segs = 32;
float angle = 0.0f;
float inc = 1.0f/(float)segs * 2 * PI;
Point3 prevVec;
gw->startSegments();
Point3 pl[3];
gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
for (int i = 0; i < (segs+1); i++)
{
Matrix3 tm(1);
tm.RotateZ(angle);
Point3 vec (0.50f,0.0f,0.0f);
vec = vec * tm;
if ( i >= 1)
{
pl[0] = vec;
pl[1] = prevVec;
gw->segment(pl,1);
pl[0].z = 1.0f;
pl[1].z = 1.0f;
gw->segment(pl,1);
if (((i%4) == 0) && (i != segs))
{
pl[0] = vec;
pl[1] = vec;
pl[1].z = 1.0f;
gw->segment(pl,1);
}
}
prevVec = vec;
angle += inc;
}
Color c(openEdgeColor);
gw->setColor(LINE_COLOR,c);
pl[0] = Point3(0.50f,0.0f,0.0f);
pl[1] = Point3(0.50f,0.0f,0.0f);
pl[1].z = 1.0f;
gw->segment(pl,1);
gw->endSegments();
}
else if (fnGetMapMode() == SPHERICALMAP)
{
//draw the bottom circle
int segs = 32;
float inc = 1.0f/(float)segs * 2 * PI;
gw->startSegments();
Point3 pl[3];
Color c(openEdgeColor);
gw->setColor(LINE_COLOR,GetUIColor(COLOR_SEL_GIZMOS));
pl[0] = Point3(0.0f,0.0f,.6f);
pl[1] = Point3(0.0f,0.0f,-.5f);
gw->segment(pl,1);
for (int j = 0; j < 3; j++)
//.........这里部分代码省略.........
示例12: SuspendAnimate
void UnwrapMod::fnGizmoReset()
{
theHold.Begin();
SuspendAnimate();
AnimateOff();
TimeValue t = GetCOREInterface()->GetTime();
//get our selection
Box3 bounds;
bounds.Init();
//get the bounding box
for(int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
{
MeshTopoData *ld = mMeshTopoData[ldID];
Matrix3 tm = mMeshTopoData.GetNodeTM(t,ldID);
for (int k = 0; k < ld->GetNumberFaces(); k++)//gfaces.Count(); k++)
{
if (ld->GetFaceSelected(k))
{
// Grap the three points, xformed
int pcount = 3;
// if (gfaces[k].flags & FLAG_QUAD) pcount = 4;
pcount = ld->GetFaceDegree(k);//gfaces[k]->count;
Point3 temp_point[4];
for (int j=0; j<pcount; j++)
{
int index = ld->GetFaceGeomVert(k,j);//gfaces[k]->t[j];
bounds += ld->GetGeomVert(index) * tm;//gverts.d[index].p;
}
}
}
}
Matrix3 tm(1);
//if just a primary axis set the tm;
Point3 center = bounds.Center();
// build the scale
Point3 scale(bounds.Width().x ,bounds.Width().y , bounds.Width().z);
if (scale.x == 0.0f) scale.x = 1.0f;
if (scale.y == 0.0f) scale.y = 1.0f;
if (scale.z == 0.0f) scale.z = 1.0f;
float scl = scale.x;
if (scale.y > scl) scl = scale.y;
if (scale.z > scl) scl = scale.z;
scale.x = scl;
scale.y = scl;
scale.z = scl;
tm.SetRow(0,Point3(scale.x,0.0f,0.0f));
tm.SetRow(1,Point3(0.0f,scale.y,0.0f));
tm.SetRow(2,Point3(0.0f,0.0f,scale.z));
if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP)|| (fnGetMapMode() == SPHERICALMAP))
tm.SetRow(3,center);
else if (fnGetMapMode() == CYLINDRICALMAP)
{
center.z = bounds.pmin.z;
tm.SetRow(3,center);
}
Matrix3 ptm(1), id(1);
tm = tm ;
SetXFormPacket tmpck(tm,ptm);
tmControl->SetValue(t,&tmpck,TRUE,CTRL_RELATIVE);
ResumeAnimate();
if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == CYLINDRICALMAP) || (fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == BOXMAP))
ApplyGizmo();
theHold.Accept(GetString(IDS_MAPPING_RESET));
fnGetGizmoTM();
if (ip) ip->RedrawViews(ip->GetTime());
}
示例13: ApplyGizmoPrivate
void UnwrapMod::ApplyGizmo()
{
if ((fnGetMapMode() == PLANARMAP) || (fnGetMapMode() == PELTMAP) ||
(fnGetMapMode() == SPHERICALMAP) || (fnGetMapMode() == CYLINDRICALMAP))
{
ApplyGizmoPrivate();
}
else
{
theHold.Begin();
//compute the center
//get our normal list
for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
{
MeshTopoData *ld = mMeshTopoData[ldID];
ld->HoldFaceSel();
}
for (int ldID = 0; ldID < mMeshTopoData.Count(); ldID++)
{
MeshTopoData *ld = mMeshTopoData[ldID];
ld->HoldFaceSel();
Tab<Point3> fnorms;
fnorms.SetCount(ld->GetNumberFaces());
for (int k=0; k< fnorms.Count(); k++)
fnorms[k] = Point3(0.0f,0.0f,0.0f);
//get our projection normal
Point3 projectionNorm(0.0f,0.0f,0.0f);
//build normals
for (int k = 0; k < fnorms.Count(); k++)
{
if (ld->GetFaceSelected(k))
{
// Grap the three points, xformed
int pcount = 3;
// if (gfaces[k].flags & FLAG_QUAD) pcount = 4;
pcount = ld->GetFaceDegree(k);//gfaces[k]->count;
Point3 temp_point[4];
for (int j=0; j<pcount; j++)
{
int index = ld->GetFaceGeomVert(k,j);//gfaces[k]->t[j];
if (j < 4)
temp_point[j] = ld->GetGeomVert(index);//gverts.d[index].p;
}
fnorms[k] = Normalize(temp_point[1]-temp_point[0]^temp_point[2]-temp_point[1]);
}
}
BitArray front,back,left,right,top,bottom;
front.SetSize(ld->GetNumberFaces());
front.ClearAll();
back = front;
left = front;
right = front;
top = front;
bottom = front;
Tab<Point3> norms;
Matrix3 gtm(1);
TimeValue t = 0;
if (ip) t = ip->GetTime();
if (tmControl)
tmControl->GetValue(t,>m,FOREVER,CTRL_RELATIVE);
norms.SetCount(6);
for (int i = 0; i < 3; i++)
{
Point3 v = gtm.GetRow(i);
norms[i*2] = Normalize(v);
norms[i*2+1] = norms[i*2] * -1.0f;
}
for (int k=0; k< ld->GetNumberFaces(); k++)
{
if (ld->GetFaceSelected(k))
{
int closestFace = -1;
float closestAngle = -10.0f;
for (int j = 0; j < 6; j++)
{
float dot = DotProd(norms[j],fnorms[k]);
if (dot > closestAngle)
{
closestAngle = dot;
closestFace = j;
}
}
if (closestFace == 0)
front.Set(k,TRUE);
else if (closestFace == 1)
back.Set(k,TRUE);
else if (closestFace == 2)
left.Set(k,TRUE);
//.........这里部分代码省略.........
示例14: BuildMesh
void LuminaireObject::BuildMesh()
{
mesh.setNumVerts(120);
mesh.setNumFaces(106);
// aszabo|Feb.10.03|Compute scale of mesh. DummyObject::box has been scaled,
// while our mDefBoxSize wasn't, but it was used to initialize the box.
float s = box.Max().x/mDefBoxSize.Max().x;
mesh.setVert(0, s*Point3(2.812824,-4.221277,0.000000));
mesh.setVert(1, s*Point3(-2.731174,-4.221277,0.000000));
mesh.setVert(2, s*Point3(-2.731174,-4.972452,0.000000));
mesh.setVert(3, s*Point3(2.812824,-4.972452,0.000000));
mesh.setVert(4, s*Point3(0.430951,-0.504076,0.000000));
mesh.setVert(5, s*Point3(0.373688,-0.540217,0.000000));
mesh.setVert(6, s*Point3(0.312884,-0.570737,0.000000));
mesh.setVert(7, s*Point3(0.248868,-0.595212,0.000000));
mesh.setVert(8, s*Point3(0.181967,-0.613220,0.000000));
mesh.setVert(9, s*Point3(0.112510,-0.624335,0.000000));
mesh.setVert(10, s*Point3(0.040825,-0.628134,0.000000));
mesh.setVert(11, s*Point3(-0.030860,-0.624335,0.000000));
mesh.setVert(12, s*Point3(-0.100318,-0.613220,0.000000));
mesh.setVert(13, s*Point3(-0.167219,-0.595213,0.000000));
mesh.setVert(14, s*Point3(-0.231235,-0.570737,0.000000));
mesh.setVert(15, s*Point3(-0.292039,-0.540217,0.000000));
mesh.setVert(16, s*Point3(-0.349302,-0.504076,0.000000));
mesh.setVert(17, s*Point3(-0.402695,-0.462737,0.000000));
mesh.setVert(18, s*Point3(-0.402695,-4.025318,0.000000));
mesh.setVert(19, s*Point3(0.484345,-4.025318,0.000000));
mesh.setVert(20, s*Point3(0.484345,-0.462738,0.000000));
mesh.setVert(21, s*Point3(0.373465,-4.025318,0.000000));
mesh.setVert(22, s*Point3(-0.291815,-4.025318,0.000000));
mesh.setVert(23, s*Point3(-0.291815,-4.221277,0.000000));
mesh.setVert(24, s*Point3(0.373465,-4.221277,0.000000));
mesh.setVert(25, s*Point3(4.419012,5.754055,0.000000));
mesh.setVert(26, s*Point3(2.964259,4.637785,0.000000));
mesh.setVert(27, s*Point3(3.340581,4.051188,0.000000));
mesh.setVert(28, s*Point3(3.598334,3.467271,0.000000));
mesh.setVert(29, s*Point3(3.784944,2.884963,0.000000));
mesh.setVert(30, s*Point3(3.947842,2.303191,0.000000));
mesh.setVert(31, s*Point3(4.134453,1.720884,0.000000));
mesh.setVert(32, s*Point3(4.392206,1.136967,0.000000));
mesh.setVert(33, s*Point3(4.768528,0.550370,0.000000));
mesh.setVert(34, s*Point3(7.900172,2.953366,0.000000));
mesh.setVert(35, s*Point3(7.430962,3.468688,0.000000));
mesh.setVert(36, s*Point3(6.933653,3.868786,0.000000));
mesh.setVert(37, s*Point3(6.419484,4.199750,0.000000));
mesh.setVert(38, s*Point3(5.899698,4.507671,0.000000));
mesh.setVert(39, s*Point3(5.385530,4.838635,0.000000));
mesh.setVert(40, s*Point3(4.888222,5.238734,0.000000));
mesh.setVert(41, s*Point3(2.805657,2.557596,0.000000));
mesh.setVert(42, s*Point3(2.664196,2.574949,0.000000));
mesh.setVert(43, s*Point3(2.533501,2.619650,0.000000));
mesh.setVert(44, s*Point3(2.416477,2.688673,0.000000));
mesh.setVert(45, s*Point3(2.316031,2.778996,0.000000));
mesh.setVert(46, s*Point3(2.235066,2.887594,0.000000));
mesh.setVert(47, s*Point3(2.176486,3.011443,0.000000));
mesh.setVert(48, s*Point3(2.143197,3.147520,0.000000));
mesh.setVert(49, s*Point3(-0.028124,0.736024,0.000000));
mesh.setVert(50, s*Point3(-0.018348,0.737188,0.000000));
mesh.setVert(51, s*Point3(-0.008572,0.738606,0.000000));
mesh.setVert(52, s*Point3(0.001220,0.740119,0.000000));
mesh.setVert(53, s*Point3(0.011041,0.741571,0.000000));
mesh.setVert(54, s*Point3(0.020906,0.742804,0.000000));
mesh.setVert(55, s*Point3(0.030829,0.743659,0.000000));
mesh.setVert(56, s*Point3(0.040825,0.743979,0.000000));
mesh.setVert(57, s*Point3(0.174745,0.730856,0.000000));
mesh.setVert(58, s*Point3(0.299803,0.693174,0.000000));
mesh.setVert(59, s*Point3(0.413514,0.633459,0.000000));
mesh.setVert(60, s*Point3(0.513398,0.554243,0.000000));
mesh.setVert(61, s*Point3(0.596971,0.458053,0.000000));
mesh.setVert(62, s*Point3(0.661752,0.347418,0.000000));
mesh.setVert(63, s*Point3(0.705257,0.224866,0.000000));
mesh.setVert(64, s*Point3(0.726882,0.057922,0.000000));
mesh.setVert(65, s*Point3(0.708744,0.215121,0.000000));
mesh.setVert(66, s*Point3(0.657090,0.359483,0.000000));
mesh.setVert(67, s*Point3(0.576055,0.486872,0.000000));
mesh.setVert(68, s*Point3(0.469775,0.593152,0.000000));
mesh.setVert(69, s*Point3(0.342386,0.674188,0.000000));
mesh.setVert(70, s*Point3(0.198024,0.725842,0.000000));
mesh.setVert(71, s*Point3(0.040825,0.743979,0.000000));
mesh.setVert(72, s*Point3(-0.116374,0.725842,0.000000));
mesh.setVert(73, s*Point3(-0.260736,0.674188,0.000000));
mesh.setVert(74, s*Point3(-0.388125,0.593152,0.000000));
mesh.setVert(75, s*Point3(-0.494405,0.486872,0.000000));
mesh.setVert(76, s*Point3(-0.575440,0.359483,0.000000));
mesh.setVert(77, s*Point3(-0.627095,0.215121,0.000000));
mesh.setVert(78, s*Point3(-0.645232,0.057922,0.000000));
mesh.setVert(79, s*Point3(-0.627095,-0.099276,0.000000));
mesh.setVert(80, s*Point3(-0.575440,-0.243638,0.000000));
mesh.setVert(81, s*Point3(-0.494405,-0.371027,0.000000));
mesh.setVert(82, s*Point3(-0.388125,-0.477308,0.000000));
mesh.setVert(83, s*Point3(-0.260736,-0.558343,0.000000));
mesh.setVert(84, s*Point3(-0.116374,-0.609997,0.000000));
mesh.setVert(85, s*Point3(0.040825,-0.628134,0.000000));
mesh.setVert(86, s*Point3(0.198024,-0.609997,0.000000));
mesh.setVert(87, s*Point3(0.342386,-0.558343,0.000000));
mesh.setVert(88, s*Point3(0.469775,-0.477308,0.000000));
mesh.setVert(89, s*Point3(0.576055,-0.371027,0.000000));
mesh.setVert(90, s*Point3(0.657090,-0.243638,0.000000));
//.........这里部分代码省略.........
示例15: processFile
void processFile(const char* input_filename, Config& config, GCodeExport& gcode, bool firstFile)
{
for(unsigned int n=1; n<16;n++)
gcode.setExtruderOffset(n, config.extruderOffset[n]);
double t = getTime();
log("Loading %s from disk...\n", input_filename);
SimpleModel* m = loadModel(input_filename, config.matrix);
if (!m)
{
log("Failed to load model: %s\n", input_filename);
return;
}
log("Loaded from disk in %5.3fs\n", timeElapsed(t));
log("Analyzing and optimizing model...\n");
OptimizedModel* om = new OptimizedModel(m, Point3(config.objectPosition.X, config.objectPosition.Y, -config.objectSink));
for(unsigned int v = 0; v < m->volumes.size(); v++)
{
log(" Face counts: %i -> %i %0.1f%%\n", (int)m->volumes[v].faces.size(), (int)om->volumes[v].faces.size(), float(om->volumes[v].faces.size()) / float(m->volumes[v].faces.size()) * 100);
log(" Vertex counts: %i -> %i %0.1f%%\n", (int)m->volumes[v].faces.size() * 3, (int)om->volumes[v].points.size(), float(om->volumes[v].points.size()) / float(m->volumes[v].faces.size() * 3) * 100);
}
delete m;
log("Optimize model %5.3fs \n", timeElapsed(t));
//om->saveDebugSTL("c:\\models\\output.stl");
log("Slicing model...\n");
vector<Slicer*> slicerList;
for(unsigned int volumeIdx=0; volumeIdx < om->volumes.size(); volumeIdx++)
{
slicerList.push_back(new Slicer(&om->volumes[volumeIdx], config.initialLayerThickness / 2, config.layerThickness, config.fixHorrible & FIX_HORRIBLE_KEEP_NONE_CLOSED, config.fixHorrible & FIX_HORRIBLE_EXTENSIVE_STITCHING));
//slicerList[volumeIdx]->dumpSegments("C:\\models\\output.html");
}
log("Sliced model in %5.3fs\n", timeElapsed(t));
SliceDataStorage storage;
if (config.supportAngle > -1)
{
fprintf(stdout,"Generating support map...\n");
generateSupportGrid(storage.support, om, config.initialLayerThickness / 2, config.layerThickness);
}
storage.modelSize = om->modelSize;
storage.modelMin = om->vMin;
storage.modelMax = om->vMax;
delete om;
log("Generating layer parts...\n");
for(unsigned int volumeIdx=0; volumeIdx < slicerList.size(); volumeIdx++)
{
storage.volumes.push_back(SliceVolumeStorage());
createLayerParts(storage.volumes[volumeIdx], slicerList[volumeIdx], config.fixHorrible & (FIX_HORRIBLE_UNION_ALL_TYPE_A | FIX_HORRIBLE_UNION_ALL_TYPE_B));
delete slicerList[volumeIdx];
}
//carveMultipleVolumes(storage.volumes);
generateMultipleVolumesOverlap(storage.volumes, config.multiVolumeOverlap);
log("Generated layer parts in %5.3fs\n", timeElapsed(t));
//dumpLayerparts(storage, "c:/models/output.html");
const unsigned int totalLayers = storage.volumes[0].layers.size();
for(unsigned int layerNr=0; layerNr<totalLayers; layerNr++)
{
for(unsigned int volumeIdx=0; volumeIdx<storage.volumes.size(); volumeIdx++)
{
generateInsets(&storage.volumes[volumeIdx].layers[layerNr], config.extrusionWidth, config.insetCount);
}
logProgress("inset",layerNr+1,totalLayers);
}
log("Generated inset in %5.3fs\n", timeElapsed(t));
//dumpLayerparts(storage, "c:/models/output.html");
for(unsigned int layerNr=0; layerNr<totalLayers; layerNr++)
{
for(unsigned int volumeIdx=0; volumeIdx<storage.volumes.size(); volumeIdx++)
{
generateSkins(layerNr, storage.volumes[volumeIdx], config.extrusionWidth, config.downSkinCount, config.upSkinCount, config.infillOverlap);
generateSparse(layerNr, storage.volumes[volumeIdx], config.extrusionWidth, config.downSkinCount, config.upSkinCount);
}
logProgress("skin",layerNr+1,totalLayers);
}
log("Generated up/down skin in %5.3fs\n", timeElapsed(t));
generateSkirt(storage, config.skirtDistance, config.extrusionWidth, config.skirtLineCount);
generateRaft(storage, config.raftMargin);
log("Generated skirt and raft in %5.3fs\n", timeElapsed(t));
for(unsigned int volumeIdx=0; volumeIdx<storage.volumes.size(); volumeIdx++)
{
for(unsigned int layerNr=0; layerNr<totalLayers; layerNr++)
{
for(unsigned int partNr=0; partNr<storage.volumes[volumeIdx].layers[layerNr].parts.size(); partNr++)
{
if (layerNr > 0)
storage.volumes[volumeIdx].layers[layerNr].parts[partNr].bridgeAngle = bridgeAngle(&storage.volumes[volumeIdx].layers[layerNr].parts[partNr], &storage.volumes[volumeIdx].layers[layerNr-1]);
else
storage.volumes[volumeIdx].layers[layerNr].parts[partNr].bridgeAngle = -1;
}
}
}
log("Stored volumes in %5.3fs\n", timeElapsed(t));
gcode.setRetractionSettings(config.retractionAmount, config.retractionSpeed, config.retractionAmountExtruderSwitch);
//.........这里部分代码省略.........