Draw Line in Game Engine with Python ?

I read that this was not possible back in 2005 (searched first of course), but now with such substantial additions to the GE, has this been considered? I’m thinking of ways to animate a wire simulation without having to manipulate a mesh.

I guess if I did have all the points on the wire, I could position static cylinders between them, but that would require me to create all the needed cylinders before running the GE, correct? I’m looking for some kind of dynamic drawing if you get my point?

Any tips appreciated!

Regards,

swebal

I’m thinking of ways to animate a wire simulation without having to manipulate a mesh

you can use blender materials through the game menu and enable materials there then you go to the cube let’s say and from it’s materials you enable the wire mode .

Draw Line in Game Engine with Python ?

i remember that you can draw an overscreen overlaied rectangle and those basic shapes with py game too long before , but didn’t try it :frowning: … so you can make old styled green overlay like in TVs :slight_smile:

guess if I did have all the points on the wire, I could position static cylinders between them

do you want them pipes or lines , i mean do you want them 3d ?

I’m looking for some kind of dynamic drawing if you get my point?

yes the enable wire mode will be changing for each frame , not only for one frame :slight_smile:
sorry if i didn’t understand your question and didn’t answer it :frowning:

Hello,

The Blender Game engine dose not support 2d blit-ing of lines, pixels or text like other game engines.

To make a straight line, use a small plane, place the object center on the -y side of the plane, and scale it.

If you want to do this dynamicaly, scale the line to its biggest possible length on its +Y axis (s,y) , and snap a quick IPO keyframe by pressing I. go forward 101 frames, and scale it to nothing, and snap a second IPO keyframe.

Add a IPO brick to play the IPO animation, set to property…
Now make a property that the IPO brick will monitor… This is the property you will manipulate for the line length.

You might want to do the animation I mentioned in reverse, so that the biggest is 100, and 0 is nothing… might make it easier for comprehension later (100 is the line’s 100% and 0 is the line at 0%)

Not the greatest method in the world, but you can do what I mentioned without any python code.

when you add it to a scene, it will inherit the rotation of the object you add it from. Then just poke in the IPO for the length , and you will be all set :slight_smile:

hope that makes sense :slight_smile:

Bye the way,

If you turn the plane on edge, so that the plane is verticle on the Z axis, and use a material with wireframe… and set your camera to orthoscopic mode facing the -z axis, you will always draw lines that are exactly 1 pixel across.

orthoscopic
sorry , but is there difference between orthographic and orthoscopic ? or they are two sides of the same coin ? , … thanks

That is the problem with using too many 3D applications, I get the terminology mixed up.

Orthographic and orthoscopic are the same thing… basically 3d without perspective rules applied.

I think wings 3D, or Zbrush calls it orthoscopic… means the same thing though pretty much.

Actually, I will be showing other geometry with textures and transparency, the wire need only to be black and the drawing needs to be done in 3d (since those are the coordinates I’m going to calculate). Basically, I want a long chain of hinge constraints with something inbetween them (such as cylinders of just a plain black line). Best would be a line, since that would be much less to compute. Imagine a x-ray image of the cardiac arteries… or se images below.

http://www.fac.org.ar/scvc/llave/interven/cribier/cribiF4.jpg

In the above image, the wire is clearly visible, that’s what I want to drawLine() with.

The wire would be calculated as a bezier curve from the collision points as below:

(blue are hinge constraints, green are handles and red is computed curve (drawLine())

http://kawzon.se/wire.jpg

So, any ideas? Again, the camera will not be ortographic and there will be other geometry, so I’m thinking (worst case) I’ll have to pre-create a bunch of constraints and getLocation each frame, then place cylinders or textured planes in-between these points. This leads me to a new question: Is it possible to create NEW vertices within the GE, or do I have to pre-create these as well?

Thanks for all the input!!! :smiley:

I found an older python script tut for drawing a curve in the ge just a day or two ago, but Im not sure where its at?

Here it is: http://davidjarvis.ca/blender/tutorial-04.shtml

Nice tut, but really not what this thread is about. I was asking about drawing a line in the Blender Game Engine, without using meshes.

swebal,
GE doesn’t support adding manually (programaticaly) constructed 3d objects, lines or meshes. You have to prepare mesh, show it and update its vertices. Look at this video - graph is created from prepared mesh, but it shows randomly generated values.
.
Another option is to make your drawing in 2d image and then load it as texture to some bilboard.

Ok, thanks for the clarification. I’ll check out the video.

Regards,

swebal

Oh well, I didnt read the tut, just grabbed the url for later use, when/if need be.

Hmm, I read it again and am more confused. But couldnt you just use 1 unit planes, with the line/curve or cylinders. Then use a grid of empties and place the correct plane at the empty when needed?

the curve can be rotated to any direction you need, and using alpha planes means it could look more like your picture.

I probably just dont understand.

yeah but you cant have an infinite number of empties…is there any way to cheat and make a OpenGl script or somethin?

Is that supported through the blender/python API?

yeah there are OpenGl shaders, but i have no idea how they work

I know about the shaders, but can these be used to draw new objects? A shader is just a sort of modifier of an existing object rendering, correct?

Is this possible yet? To draw line in GE? Or no?

Use the Rasterizer.drawLine() function in2.4x. I don’t know about 2.5.

Yup, works even in 2.5!

i dont know how this guy did it, but it certainly is possible:


Check out that beautiful curved line! It’s dynamic as well :smiley: