public void AppendObject(IDrawableObject drawableObject) { if (!DrawableObjects.Contains(drawableObject)) { DrawableObjects.Add(drawableObject); } }
/// <summary> /// Fills a list with all the children of a node which are lights. /// </summary> /// <param name="node">Node which is to be recursively searched.</param> /// <param name="lights">List to be filled with the light nodes.</param> private void GetLightNodes(Node node, ref List <LightNode> lights) { //Verify if the node is an IDrawable. IDrawableObject drawable = node as IDrawableObject; //If the node is an IDrawable which is invisible we return because we don't want to add //it (or its children) to the list of lights. if (drawable != null && !drawable.Visible) { return; } //Here we know that the node is not an IDrawable or, if it is, it is also visible so we //check to see if it is a light. LightNode light = node as LightNode; //Only add the node if it is a light and it is on. if (light != null && light.IsOn) { //Add the node to the list with all the lights. lights.Add(light); } //Check all the children. foreach (Node n in node.Children) { GetLightNodes(n, ref lights); } }
/// <summary> /// Fills a list with all the children of a node which are drawable and visible. /// </summary> /// <param name="node">Node which is to be recursively searched.</param> /// <param name="drawables">List to be filled with the drawable nodes.</param> private void GetVisibleDrawableNodes(Node node, ref List <IDrawableObject> drawables) { //Verify if the node is an IDrawable. IDrawableObject drawable = node as IDrawableObject; //Add the node if it is drawable and visible. if (drawable != null && drawable.Visible) { //Add the node to the list of drawable nodes. drawables.Add(drawable); } //If the node is a drawable container we add all of the visible drawables in it. IDrawableContainer drawableContainer = node as IDrawableContainer; if (drawableContainer != null && drawableContainer.Visible) { drawables.AddRange(drawableContainer.VisibleDrawables); } //If the node is not a drawable or, if it is drawable and is visible, we check all its //children. if (drawable == null || drawable.Visible) { //Search the node's children. foreach (Node n in node.Children) { GetVisibleDrawableNodes(n, ref drawables); } } }
/// <summary> /// 描画するものを除く /// </summary> /// <param name="obj"></param> public void RemoveDrawableObject(IDrawableObject obj) { if (drawObjs == null) { return; } drawObjs.Remove(obj); }
/// <summary> /// 描画する物を設定 /// </summary> /// <param name="obj"></param> public void AddDrawableObject(IDrawableObject obj) { if (drawObjs == null) { drawObjs = new List <IDrawableObject>(); } drawObjs.Add(obj); }
public TestInfo(IDrawableObject drawableObject) { DrawableObject = drawableObject; //After the font class started to derive from the sprite class each font object we create calls a testinfo object which uses a font.So it leads to infinitive loop(stackoverflowexception) if (DrawableObject.GetType().Name != "Font") { Font = new Font(text: DrawableObject.GetType().Name); Font.SetLayerDepth(DrawableObject.LayerDepth + 0.1f); } }
/// <summary> /// Fills a list with all the children of a node which are shadow casters and whose /// CastShadows and Visible properties are true or whose CastShadowsWhenInvisible and /// CastShadows properties are true. /// </summary> /// <param name="node">Node which is to be recursively searched.</param> /// <param name="shadowCasters">List to be filled with the shadow casters.</param> private void GetShadowCasters(Node node, ref List <IDrawableObject> shadowCasters) { //Verify if the node is an IShadowCaster. IDrawableObject shadowCaster = node as IDrawableObject; //Add the node if it is a shadow caster and its Visible and CastShadows properties are //true or if it is a shadow caster and its Visible, CastShadows and //CastShadowsWhenInvisible properties are true. if (shadowCaster != null && shadowCaster.CastShadows) { if (shadowCaster.Visible || shadowCaster.CastShadowsWhenInvisible) { //Add the node to the list of shadow casters. shadowCasters.Add(shadowCaster); } } //If the node is a shadow caster container we add all of the shadow casters in it which //are active shadow casters and visible or whose CastShadowsWhenInvisible property is //true. IDrawableContainer shadowCasterContainer = node as IDrawableContainer; if (shadowCasterContainer != null && shadowCasterContainer.CastShadows && (shadowCasterContainer.Visible || shadowCasterContainer.CastShadowsWhenInvisible)) { //Chech each shadow caster in the container because some may be deactivated or //invisible (For the MeshNode the shadow caster properties always match the //container properties, but that need not be the case). foreach (IDrawableObject c in shadowCasterContainer.EnabledShadowCasters) { if (shadowCasterContainer.Visible || shadowCasterContainer.CastShadowsWhenInvisible) { shadowCasters.Add(c); } } } //Check the children. if (shadowCaster == null || (shadowCaster.CastShadows && (shadowCaster.Visible || shadowCaster.CastShadowsWhenInvisible))) { //Search the node's children. foreach (Node n in node.Children) { GetShadowCasters(n, ref shadowCasters); } } }
// *** IDrawableObject interface implementation *** public virtual IDrawableObject[] GetObjectsAt(float x, float y, TransformParams tr, ref float[] distArray) { Utils.ThrowException(tr == null ? new ArgumentNullException("tr") : null); float dist = 0; IDrawableObject drawableObject = GetObjectAt(x, y, tr, ref dist); if (drawableObject != null) { distArray = new float[] { dist }; return(new IDrawableObject[] { drawableObject }); } else { distArray = new float[] { }; return(new IDrawableObject[] { }); } }
private void WriteSymbol(IDrawableObject symbol) { foreach (var link in symbol.Links) { if (link.LinksType == Links.Line) { Graphics.DrawLine(Pen, (int)(Position.X + link.P1.X * SizeX), Position.Y + (int)(link.P1.Y * SizeY), Position.X + (int)(link.P2.X * SizeX), Position.Y + (int)(link.P2.Y * SizeY)); } else if (link.LinksType == Links.Bezier) { Graphics.DrawBezier(Pen, (int)(Position.X + link.P1.X * SizeX), Position.Y + (int)(link.P1.Y * SizeY), Position.X + (int)(link.P2.X * SizeX), Position.Y + (int)(link.P2.Y * SizeY), Position.X + (int)(link.P3.X * SizeX), Position.Y + (int)(link.P3.Y * SizeY), Position.X + (int)(link.P4.X * SizeX), Position.Y + (int)(link.P4.Y * SizeY)); } } }
public Actor(Entity entity, IDrawableObject drawing, float health) { if (entity != null && entity.Space != null) { throw new ArgumentException("This physics object already belongs to a space."); } PhysicsObject = entity; DrawingObject = drawing; OnKeypress += onKeypress; OnDeath += onDeath; Health = MaxHealth = health; if (PhysicsObject != null) { baseJoint = new WeldJoint(null, PhysicsObject); baseJoint.IsActive = true; PhysicsObject.CollisionInformation.CollisionRules.Group = staticObjects; PhysicsObject.Tag = this; } }
public void Add(IDrawableObject drawable, Material material) { if (Count >= Elements.Length) { Array.Resize(ref Elements, Elements.Length * 2); } var entry = Elements[Count]; if (entry != null) { entry.Drawable = drawable; entry.Material = material; Count++; return; } Elements[Count++] = new DrawingQueueEntry() { Drawable = drawable, Material = material, }; }
private List <Tuple <Vector4, Vector4, bool> > GetLinesToDraw(Matrix4x4 perspectiveMatrix, Vector4[] pointsLines, Matrix4x4 mv, IDrawableObject ob, List <Line> lineList, Matrix4x4 viewportMatrix) { var newPoints = pointsLines.Select(t => Vector4.Transform(t, mv)).ToList(); if (!(ob is Cursor3D)) { UpdateEdgesIntersectionPoints(newPoints, lineList); } for (int i = 0; i < newPoints.Count; i++) { newPoints[i] = Vector4.Transform(newPoints[i], perspectiveMatrix); newPoints[i] = newPoints[i] / newPoints[i].W; } List <Tuple <Vector4, Vector4, bool> > linesToDraw = new List <Tuple <Vector4, Vector4, bool> >(); foreach (var line in lineList) { var p1 = newPoints[line.Start]; var p2 = newPoints[line.End]; var minusOne = -1f - 1e-4f; var plusOne = 1f + 1e-4f; bool drawP1 = p1.X >= minusOne && p1.X <= plusOne && p1.Y >= minusOne && p1.Y <= plusOne && p1.Z >= minusOne && p1.Z <= 1; bool drawp2 = p2.X >= minusOne && p2.X <= plusOne && p2.Y >= minusOne && p2.Y <= plusOne && p2.Z >= minusOne && p2.Z <= 1; p1 = Vector4.Transform(p1, viewportMatrix); p2 = Vector4.Transform(p2, viewportMatrix); linesToDraw.Add(Tuple.Create(p1, p2, drawP1 & drawp2)); } return(linesToDraw); }
public IDrawableObject[] GetObjectsAt(float x, float y, TransformParams tr, ref float[] dist_array) { ArrayList <ObjectInfo> aux = new ArrayList <ObjectInfo>(); for (int i = m_drawable_objects.Count - 1; i >= 0; i--) { IDrawableObject[] objects_at_xy = m_drawable_objects[i].GetObjectsAt(x, y, tr, ref dist_array); for (int j = 0; j < objects_at_xy.Length; j++) { aux.Add(new ObjectInfo(aux.Count, dist_array[j], objects_at_xy[j])); } } aux.Sort(); IDrawableObject[] result = new IDrawableObject[aux.Count]; dist_array = new float[aux.Count]; int k = 0; foreach (ObjectInfo object_info in aux) { result[k] = object_info.DrawableObject; dist_array[k++] = object_info.Dist; } return(result); }
public ObjectInfo(int idx, float dist, IDrawableObject drawable_object) { Idx = idx; Dist = dist; DrawableObject = drawable_object; }
public void RemoveObject(IDrawableObject drawableObject) { DrawableObjects.Remove(drawableObject); }
public void InsertObject(IDrawableObject drawableObject, int index) { DrawableObjects.Insert(index, drawableObject); }