Draw Line?
by Richard_H · in Torque Game Engine · 01/07/2007 (6:08 pm) · 4 replies
Hi,
to help visualize the AI pathfinding in my game I would like to add a function that takes 6 integers (x1, y1, z1, x2, y2, z2) and possibly some rendering paramaters to draw a line from to in Torque world space (using OpenGL). I have basic C++ knowledge and am learning some simple OpenGL, yet I don't know where to begin. Any help will be apreciated.
to help visualize the AI pathfinding in my game I would like to add a function that takes 6 integers (x1, y1, z1, x2, y2, z2) and possibly some rendering paramaters to draw a line from
About the author
#2
01/07/2007 (10:40 pm)
Sorry, I probably should have mentioned that to actually render it, you will need a class that does rendering (eg. SceneObject). Or you can make a whatever you want and have it render only when the editor is open. Have a call from the renderScene function in world editor to your object(s). There are many other ways to get something to render, but maybe i should point you to fxrenderobject. Have fun
#3
I'll take a look at fxrenderobject. A big thing I was wondering was whether or not OpenGL acknoledged Torque world space. Also, what files would I have to include, and where should I put my new file?
01/08/2007 (3:17 am)
Thx for the help,I'll take a look at fxrenderobject. A big thing I was wondering was whether or not OpenGL acknoledged Torque world space. Also, what files would I have to include, and where should I put my new file?
#4
I'll take a look at fxrenderobject. A big thing I was wondering was whether or not OpenGL acknoledged Torque world space. Also, what files would I have to include, and where should I put my new file?
01/08/2007 (3:51 am)
Thx for the help,I'll take a look at fxrenderobject. A big thing I was wondering was whether or not OpenGL acknoledged Torque world space. Also, what files would I have to include, and where should I put my new file?
Torque 3D Owner Avid Gamer
Probably easier:
Looks best:
Vector<Point3F> mArray; // array of points the AI would be traveling. CameraSpline spline; for(U32 i = 0; i < mArray.size(); i++) { CameraSpline::Knot::Type type = CameraSpline::Knot::POSITION_ONLY; CameraSpline::Knot::Path path; path = CameraSpline::Knot::SPLINE; spline.push_back(new CameraSpline::Knot(mArray[i], QuatF(0,0,0,1), 1.0f, type, path)); } F32 t = 0.0f; S32 size = spline.size(); if (size <= 1) return; glBegin(GL_LINE_STRIP); while (t < size - 1) { CameraSpline::Knot k; spline.value(t, &k); t = spline.advanceDist(t, 2.0f); VectorF t1(k.mPosition); glVertex3f(t1.x, t1.y, t1.z + 1.0f); // display the path a little above the desired spot. } glEnd();Splines are easy to make in torque, and there are excellent examples already in place. The above code was taking from worldEditor.cc and simplified a bit.
hope i helped.