Drawing a Line
by Nathan Bell · in Torque X Platformer Kit · 09/05/2008 (8:49 pm) · 2 replies
I would like to render some lines in my game so I can get a visual representation of what the code is doing. The problem is I can't figure out how to do this inside the platformer framework. Has anyone managed to get this working? Any tips? Thanks!
#2
Note that I wasn't able to do this until I bought the Indy Pro version of TorqueX and looked at the source. I don't think there's any way to figure out how to do this with just the documentation.
10/10/2008 (9:03 am)
I accomplished this by creating a LinePrimitive class that inherits from TDSceneObject and mimics the behavior or the T2DPolygon class. Basically, I pass in a series of points to the Line class then fill the vertex buffer with the updated positions of the points each frame. You can then draw with the LineStrip primitive inside of the (overrided) Render method.Note that I wasn't able to do this until I bought the Indy Pro version of TorqueX and looked at the source. I don't think there's any way to figure out how to do this with just the documentation.
Torque Owner Vishal Bhanderi
public static T2DSceneObject DebugObject(String debugObjectString) { T2DSceneObject debugObject = null; T2DSceneObject debugString = TorqueObjectDatabase.Instance.FindObject<T2DSceneObject>(debugObjectString); if (debugString != null) { debugObject = (T2DSceneObject)debugString.Clone(); TorqueObjectDatabase.Instance.Register(debugObject); } else { Assert.Fatal(false, "There is no debug setup"); } return debugObject; }And then access the object by doing:
T2DSceneObject temp = CustomDebug.DebugDot("debugPoint"); temp.Position = new Vector2(x, y) + sceneObject.Position;you should be able to change the size of the object something like:
temp.Size = GetDistanceFrom(p1,p2);
and then the angle;
temp.angle = angleBetween(p1,p2);