Draw line with border, how to?

Hi,

I need to draw lines in my app., and these lines to have borders, that can have color and size. There is no such feature in JME3, so how can I achieve something like that?



I tried to draw two lines one over another, one with bigger width than the other one, but obviously this doesn’t work (I think you can guess why).



Please help.

Ty.

I suggest creating your own custom mesh, basically a quad with a border.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_meshes

normen said:
I suggest creating your own custom mesh, basically a quad with a border.
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:custom_meshes


How to construct the border?
If I understood correctly, I can do this like that:

|
|
|
|
|
|
|
|
|
|
|
|

And in such case there will be 5 quads. I don't imagine otherwise, can you? And if this will be a single mesh, how do I color each quad individually?

Ty.

Using vertex color. You can also simply model it in blender by extruding a plane and then color it, then import the model.

normen said:
Using vertex color. You can also simply model it in blender by extruding a plane and then color it, then import the model.


Vertex color will interpolate colors, will it not? I don't need something like that. Also, my line with border is created at runtime, at random, using random length and colors, so I can't create it in blender.

Something else?

you could create this “line” in blender with 3 meshes. And then just change the color of the top and bottom “mesh” (border) at runtime. Length isn’t an issue as you just need to scale it accordingly.

wezrule said:
you could create this "line" in blender with 3 meshes. And then just change the color of the top and bottom "mesh" (border) at runtime. Length isn't an issue as you just need to scale it accordingly.


Thank you for the reply,
but I don't think this is applicable to my case, because in the case of a line, it has two points, and this line is dynamic in my case, the points that form the line change at runtime, each one based on some rule, and after the changes, I update the points that form the line, is this clearer now?

I tried right now to do cross product two times, to obtain the vector that is orthogonal to the direction vector that forms the line, but this doesn't work, dunno why, the graphic result is not correct. (I did first time cross product of the direction vector that forms the line with the up vector (0, 1, 0), and after that result with the direction again, theoretically (I think), this must give me the vector that is orthogonal to the direction vector, and so subtract this unit vector many times I want and to create another line beside (this to be one side of the border), and add to obtain the other border side, but this doesn't work...)
xmight said:
Vertex color will interpolate colors, will it not?


Only if the meshes share the same vertices; duplicate vertices (same vertex data, different index), will prevent that problem. Couldn't tell you how to do this in Blender (I'm writing my vertex buffers 'manually'), but the links under "Managing objects in the 3d scene graph" here could get you started doing that: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3 (particularly "Custom Meshes")
tebriel said:
Only if the meshes share the same vertices; duplicate vertices (same vertex data, different index), will prevent that problem. Couldn't tell you how to do this in Blender (I'm writing my vertex buffers 'manually'), but the links under "Managing objects in the 3d scene graph" here could get you started doing that: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3 (particularly "Custom Meshes")


In blender u can use extrude to duplicate the selected vertexes, and if u don't move anything, then they will stay at the same position as the original ones.

my solution:

create a box instead of a line and apply the “line texture”.

1 Like