本文整理汇总了C#中Ray.GetOrigin方法的典型用法代码示例。如果您正苦于以下问题:C# Ray.GetOrigin方法的具体用法?C# Ray.GetOrigin怎么用?C# Ray.GetOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ray
的用法示例。
在下文中一共展示了Ray.GetOrigin方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Intersect
/**
* Intersect
*
* @param ray
* @param pt
* @return boolean
*/
public override bool Intersect(Ray ray, IntersectPt pt)
{
double vd = Normal.Dot(ray.GetDirection());
double vo, t;
Vector origVec = new Vector(ray.GetOrigin().GetX(), ray.GetOrigin().GetY(), ray.GetOrigin().GetZ());
if(vd == 0.0f)
{
return (false);
}
vo = -Normal.Dot(origVec) - D;
t = vo / vd;
if(t < pt.GetThreshold())
{
return (false);
}
pt.GetIntersection().Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if(!Check(ray, pt))
{
return (false);
}
pt.SetT(t);
pt.SetIntersectObj(this);
if(GetObjID() == pt.GetOriginal())
{
pt.SetEnter(false);
}
else
{
pt.SetEnter(true);
}
GetCachePt().Set(ray.GetID(), pt);
return (true);
}
示例2: Intersect
/**
* Intersect
*
* @param ray
* @param pt
* @return boolean
*/
public override bool Intersect(Ray ray, IntersectPt pt)
{
Vector OC = new Vector();
double l2OC, tCA, t2HC;
OC.Sub(Origin, ray.GetOrigin());
l2OC = OC.SquaredLength();
tCA = OC.Dot(ray.GetDirection());
if(l2OC >= RadiusSquare && tCA <= 0)
{
return (false);
}
t2HC = RadiusSquare - l2OC + tCA * tCA;
if(t2HC < 0)
{
return (false);
}
if(l2OC <= RadiusSquare)
{
pt.SetT(tCA + (double)System.Math.Sqrt(t2HC));
if(pt.GetT() < pt.GetThreshold())
{
return (false);
}
pt.SetEnter(false);
pt.GetIntersection().Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, pt.GetT());
}
else
{
pt.SetT(tCA - (double)System.Math.Sqrt(t2HC));
pt.SetEnter(true);
if(pt.GetT() < pt.GetThreshold())
{
pt.SetT(tCA + (double)System.Math.Sqrt(t2HC));
pt.SetEnter(false);
}
pt.GetIntersection().Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, pt.GetT());
}
pt.SetIntersectObj(this);
GetCachePt().Set(ray.GetID(), pt);
return (true);
}
示例3: FindNearestIsect
/**
* FindNearestIsect
*
* @param octree
* @param ray
* @param originID
* @param level
* @param isectnode
* @return boolean
*/
public bool FindNearestIsect(OctNode octree, Ray ray, int originID, int level, OctNode isectnode)
{
Point testpt = new Point(ray.GetOrigin());
OctNode current;
ObjNode currentnode;
CacheIntersectPt isectptr;
IntersectPt test = new IntersectPt();
if(level == 0)
{
testpt.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, Threshold);
}
current = octree.FindTreeNode(testpt);
IntersectObj = null;
while(current != null)
{
currentnode = current.GetList();
while(currentnode != null)
{
bool found = false;
if(currentnode.GetObj().GetCachePt().GetID() == ray.GetID())
{
isectptr = currentnode.GetObj().GetCachePt();
if(current == current.FindTreeNode(isectptr.GetIntersection()))
{
if(IntersectObj == null)
{
SetIsectPt(isectptr);
isectnode.Copy(current);
}
else
{
if(isectptr.GetT() < t)
{
SetIsectPt(isectptr);
isectnode.Copy(current);
}
}
found = true;
}
}
if(!found)
{
test.SetOrigID(originID);
if(currentnode.GetObj().Intersect(ray, test))
{
if(current == current.FindTreeNode(test.GetIntersection()))
{
if(IntersectObj == null)
{
SetIsectPt(test);
isectnode.Copy(current);
}
else
{
if(test.GetT() < t)
{
SetIsectPt(test);
isectnode.Copy(current);
}
}
}
}
}
currentnode = currentnode.Next();
}
if(IntersectObj == null)
{
OctNode adjacent = current.Intersect(ray, testpt, Threshold);
if(adjacent == null)
{
current = null;
}
else
{
current = adjacent.FindTreeNode(testpt);
}
}
else
{
current = null;
}
}
if(IntersectObj == null)
{
return (false);
}
else
{
//.........这里部分代码省略.........
示例4: Intersect
/**
* Intersect
*
* @param ray
* @param intersect
* @param Threshold
* @return OctNode
*/
public OctNode Intersect(Ray ray, Point intersect, double Threshold)
{
Vector delta = new Vector(0.0f, 0.0f, 0.0f);
double current = 0.0f;
double t;
int[] facehits = new int[3];
facehits[0] = -1;
facehits[1] = -1;
facehits[2] = -1;
OctNode adjacent = null;
Face[] OFaces = this.OctFaces;
Face MAXXF = OFaces[MAXX];
Face MAXYF = OFaces[MAXY];
Face MAXZF = OFaces[MAXZ];
Face MINXF = OFaces[MINX];
Face MINYF = OFaces[MINY];
Face MINZF = OFaces[MINZ];
if(ray.GetDirection().GetX() != 0.0)
{
t = -(ray.GetOrigin().GetX() - OctFaces[MAXX].GetVert(0).GetX()) / ray.GetDirection().GetX();
if(t > Threshold && t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MAXX;
delta.SetX(Threshold);
}
}
t = -(ray.GetOrigin().GetX() - OctFaces[MINX].GetVert(0).GetX()) / ray.GetDirection().GetX();
if(t > Threshold && t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetY() <= MAXYF.GetVert(0).GetY()) && (intersect.GetY() >= MINYF.GetVert(0).GetY()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MINX;
delta.SetX(-Threshold);
}
}
}
if(ray.GetDirection().GetY() != 0.0)
{
t = -(ray.GetOrigin().GetY() - OctFaces[MAXY].GetVert(0).GetY()) / ray.GetDirection().GetY();
if(t > Threshold)
{
if(t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MAXY;
delta.Set(0.0f, Threshold, 0.0f);
}
}
else if(t == current)
{
facehits[1] = MAXY;
delta.SetY(Threshold);
}
}
t = -(ray.GetOrigin().GetY() - OctFaces[MINY].GetVert(0).GetY()) / ray.GetDirection().GetY();
if(t > Threshold)
{
if(t > current)
{
intersect.Combine(ray.GetOrigin(), ray.GetDirection(), 1.0f, t);
if((intersect.GetX() <= MAXXF.GetVert(0).GetX()) && (intersect.GetX() >= MINXF.GetVert(0).GetX()) &&
(intersect.GetZ() <= MAXZF.GetVert(0).GetZ()) && (intersect.GetZ() >= MINZF.GetVert(0).GetZ()))
{
current = t;
facehits[0] = MINY;
delta.Set(0.0f, -Threshold, 0.0f);
}
}
else if(t == current)
{
facehits[1] = MINY;
delta.SetY(-Threshold);
}
}
}
if(ray.GetDirection().GetZ() != 0.0)
{
t = -(ray.GetOrigin().GetZ() - OctFaces[MAXZ].GetVert(0).GetZ()) / ray.GetDirection().GetZ();
//.........这里部分代码省略.........
示例5: RenderScene
/**
* RenderScene
*/
public void RenderScene(Canvas canvas, int width, int section, int nsections)
{
Vector view = camera.GetViewDir();
Vector up = camera.GetOrthoUp();
Vector plane = new Vector();
Vector horIncr = new Vector();
Vector vertIncr = new Vector();
double ylen = camera.GetFocalDist() * (double)Math.Tan(0.5f * camera.GetFOV());
double xlen = ylen * canvas.GetWidth() / canvas.GetHeight();
Point upleft = new Point();
Point upright = new Point();
Point lowleft = new Point();
Point basepoint = new Point();
Point current;
Ray eyeRay = new Ray();
int ypixel, xpixel;
RayID = 1;
plane.Cross(view, up);
view.Scale(camera.GetFocalDist());
up.Scale(ylen);
plane.Scale(-xlen);
upleft.FindCorner(view, up, plane, camera.GetPosition());
plane.Negate();
upright.FindCorner(view, up, plane, camera.GetPosition());
up.Negate();
plane.Negate();
lowleft.FindCorner(view, up, plane, camera.GetPosition());
horIncr.Sub(upright, upleft);
horIncr.Scale(horIncr.Length() / ((double)canvas.GetWidth()));
vertIncr.Sub(lowleft, upleft);
vertIncr.Scale(vertIncr.Length() / ((double)canvas.GetHeight()));
basepoint.Set(upleft.GetX() + 0.5f * (horIncr.GetX() + vertIncr.GetX()), upleft.GetY() + 0.5f * (horIncr.GetY() + vertIncr.GetY()),
upleft.GetZ() + 0.5f * (horIncr.GetZ() + vertIncr.GetZ()));
eyeRay.SetOrigin(camera.GetPosition());
int xstart = section * width / nsections;
int xend = xstart + width / nsections;
Console.WriteLine("+" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());
for(ypixel = 0; ypixel < canvas.GetHeight(); ypixel++)
{
current = new Point(basepoint);
for(xpixel = 0; xpixel < canvas.GetWidth(); xpixel++)
{
if(xpixel >= xstart && xpixel < xend)
{
Color color = new Color(0.0f, 0.0f, 0.0f);
eyeRay.GetDirection().Sub(current, eyeRay.GetOrigin());
eyeRay.GetDirection().Normalize();
eyeRay.SetID(RayID);
this.RayID = this.RayID + 1;
Shade(octree, eyeRay, color, 1.0f, 0, 0);
canvas.Write(Brightness, xpixel, ypixel, color);
}
current.Add(horIncr);
}
basepoint.Add(vertIncr);
}
Console.WriteLine("-" + xstart + " to " + (xend - 1) + " by " + canvas.GetHeight());
}
示例6: FindLightBlock
/**
* FindLightBlock
*
* @param tree
* @param ray
* @param maxt
* @return boolean
*/
private bool FindLightBlock(OctNode tree, Ray ray, double maxt)
{
OctNode current = tree.FindTreeNode(ray.GetOrigin());
IntersectPt test = new IntersectPt();
Point testpt = new Point();
while(current != null)
{
ObjNode currentnode = current.GetList();
while(currentnode != null)
{
bool found = false;
if(currentnode.GetObj().GetCachePt().GetID() == ray.GetID())
{
found = true;
}
if(!found)
{
test.SetOrigID(0);
if(currentnode.GetObj().Intersect(ray, test))
{
if(test.GetT() < maxt)
{
return (true);
}
}
}
currentnode = currentnode.Next();
}
OctNode adjacent = current.Intersect(ray, testpt, test.GetThreshold());
if(adjacent == null)
{
current = null;
}
else
{
current = adjacent.FindTreeNode(testpt);
}
}
return (false);
}