本文整理汇总了C#中Engine3D.Vector3d.Scale方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3d.Scale方法的具体用法?C# Vector3d.Scale怎么用?C# Vector3d.Scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine3D.Vector3d
的用法示例。
在下文中一共展示了Vector3d.Scale方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IntersectObjects
public static List<ISectData> IntersectObjects(Vector3d direction, Point3d origin, List<Object3d> objects, bool supports)
{
//List<ISectData> m_isectlst = new List<ISectData>();
try
{
if (!vecinit)
{
Initvecs();
}
m_isectlst.Clear();
direction.Normalize();
direction.Scale(10000.0f);
IOendp.Set(origin);
IOendp.x += direction.x;
IOendp.y += direction.y;
IOendp.z += direction.z;
lock (lck)
{
foreach (Object3d obj in objects)
{
if (obj.tag == Object3d.OBJ_SUPPORT && !supports)
continue;
// try a less- costly sphere intersect here
if (IntersectSphere(origin, IOendp, ref IOintersect, obj.m_center, obj.m_radius))
{
foreach (Polygon p in obj.m_lstpolys)
{
//IOintersect = new Point3d();
// try a less- costly sphere intersect here
if (IntersectSphere(origin, IOendp, ref IOintersect, p.m_center, p.m_radius))
{
// if it intersects,
if (RTUtils.IntersectPoly(p, origin, IOendp, ref IOintersect))
{
m_isectlst.Add(new ISectData(obj, p, IOintersect, origin, direction));
}
}
}
}
}
}
ISectData gp = ISectGroundPlane(direction, origin);
if (gp != null)
{
m_isectlst.Add(gp);
}
m_isectlst.Sort();
}
catch (Exception ex)
{
DebugLogger.Instance().LogError(ex.Message);
}
return m_isectlst;
}
示例2: FindIntersection
/*
public class Config
{
int xres, yres;
// double
}
* */
public static bool FindIntersection(Vector3d direction, Point3d origin, ref Point3d intersect)
{
UVDLPApp.Instance().CalcScene();
//bool intersected = false;
// Point3d bpoint, tpoint;
// Point3d lowest = new Point3d(); // the lowest point of intersection on the z axis
direction.Normalize();
direction.Scale(100.0);
Point3d endp = new Point3d();
endp.Set(origin);
endp.x += direction.x;
endp.y += direction.y;
endp.z += direction.z;
/*
intersect = new Point3d();
intersect.x = 0.0d;
intersect.y = 0.0d;
intersect.z = 0.0d;
*/
//intersect the scene with a ray
// intersected = false;
foreach (Polygon p in UVDLPApp.Instance().Scene.m_lstpolys)
{
intersect = new Point3d();
// try a less- costly sphere intersect here
if (RTUtils.IntersectSphere(origin, endp, ref intersect, p.m_center, p.m_radius))
{
// if it intersects,
if (RTUtils.IntersectPoly(p, origin, endp, ref intersect))
{
return true;
/*
// and it's the lowest one
if (intersect.z <= lowest.z)
{
//save this point
intersected = true;
lowest.Set(intersect);
}
* */
}
}
}
return false;
}
示例3: ISectGroundPlane
private static ISectData ISectGroundPlane(Vector3d direction, Point3d origin)
{
ISectData isect = null;
direction.Normalize();
direction.Scale(10000.0f);
GPendp.Set(origin);
GPendp.x += direction.x;
GPendp.y += direction.y;
GPendp.z += direction.z;
// intersect with the imaginary groundplane object;
if (m_gp == null)
{
CreateGroundPlane();
}
if (IntersectSphere(origin, GPendp, ref GPintersect, m_gp.m_center, m_gp.m_radius))
{
foreach (Polygon p in m_gp.m_lstpolys)
{
//GPintersect = new Point3d();
// try a less- costly sphere intersect here
if (IntersectSphere(origin, GPendp, ref GPintersect, p.m_center, p.m_radius))
{
// if it intersects,
if (RTUtils.IntersectPoly(p, origin, GPendp, ref GPintersect))
{
isect = new ISectData(m_gp, p, GPintersect, origin, direction);
}
}
}
}
return isect;
}
示例4: glControl1_Click
/// <summary>
/// For now this is the editing mode for the currently selected support
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void glControl1_Click(object sender, EventArgs e)
{
// single click on GL Control
Object3d obj = UVDLPApp.Instance().SelectedObject;
if (obj == null) return;
if (ctrldown == false) return; // ctrl need to be held down
// this object is a support
if (obj.tag == Object3d.OBJ_SUPPORT)
{
Support sup = (Support)obj;// we can cast safely
// now we have to see if we clicked on an object
MouseEventArgs me = e as MouseEventArgs;
MouseButtons buttonPushed = me.Button;
int xPos = me.X;
int yPos = me.Y;
List<ISectData> isects = TestHitTest(xPos, yPos);
if (isects.Count == 0) return; // no intersections
ISectData isd1 =null;
foreach (ISectData isd in isects)
{
// find the closest object we clicked
if (isd.obj.tag == Object3d.OBJ_NORMAL)
{
isd1 = isd; // save it
break;
}
}
if (isd1 == null) return; // no object intersection
isd1.poly.CalcNormal();
m_isectnormal.x = isd1.poly.m_normal.x;
m_isectnormal.y = isd1.poly.m_normal.y;
m_isectnormal.z = isd1.poly.m_normal.z;
// ok, we've got the normal, we know where we've intersected
// my best guess is that we should move the support 5mm in the direction of the camera
// the tip of the support should touch the intersection point
// let's start with scaling the height...
//sup.ScaleToHeight(isd1.intersect.z);
//m_camera.m_eye
Engine3D.Vector3d towardseye = new Engine3D.Vector3d();
towardseye = m_isectnormal;// -m_camera.m_eye;
towardseye.Normalize(); // make the unit length of 1
towardseye.Scale(4.0f); // scale to 5 mm
sup.MoveFromTip(isd1.intersect, towardseye);
UpdateView();
//sup.
}
}
示例5: DrawISect
// draw the intersection of the current mouse point into the scene
private void DrawISect()
{
// draw some lines
GL.LineWidth(2);
GL.Color3(Color.Red);
GL.Begin(PrimitiveType.Lines);
GL.Vertex3(m_ix - 5, m_iy, m_iz);
GL.Vertex3(m_ix + 5, m_iy, m_iz);
GL.End();
GL.Begin(PrimitiveType.Lines);
GL.Vertex3(m_ix, m_iy - 5, m_iz);
GL.Vertex3(m_ix, m_iy + 5, m_iz);
GL.End();
//
Point3d spnt = new Point3d();
Point3d epnt = new Point3d();
spnt.x = m_ix;
spnt.y = m_iy;
spnt.z = m_iz;
Engine3D.Vector3d tvec = new Engine3D.Vector3d();
tvec.x = m_isectnormal.x;
tvec.y = m_isectnormal.y;
tvec.z = m_isectnormal.z;
tvec.Scale(5.0f);
epnt.x = spnt.x + tvec.x;
epnt.y = spnt.y + tvec.y;
epnt.z = spnt.z + tvec.z;
GL.LineWidth(2);
GL.Color3(Color.Red);
GL.Begin(PrimitiveType.Lines);
GL.Vertex3(spnt.x, spnt.y, spnt.z);
GL.Vertex3(epnt.x, epnt.y, epnt.z);
GL.End();
GL.LineWidth(1);
}
示例6: ISectObjSelPlane
private static ISectData ISectObjSelPlane(Vector3d direction, Point3d origin)
{
ISectData isect = null;
if (m_selplane == null)
return null;
direction.Normalize();
direction.Scale(10000.0f);
ObSelendp.Set(origin);
ObSelendp.x += direction.x;
ObSelendp.y += direction.y;
ObSelendp.z += direction.z;
// intersect with the imaginary object selection plane
if (IntersectSphere(origin, ObSelendp, ref ObSelintersect, m_selplane.m_center, m_selplane.m_radius))
{
foreach (Polygon p in m_selplane.m_lstpolys)
{
// try a less- costly sphere intersect here
if (IntersectSphere(origin, ObSelendp, ref ObSelintersect, p.m_center, p.m_radius))
{
// if it intersects,
if (RTUtils.IntersectPoly(p, origin, ObSelendp, ref ObSelintersect))
{
isect = new ISectData(m_selplane, p, ObSelendp, origin, direction);
}
}
}
}
return isect;
}