Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
I need to draw a line from one point to another does anyone have any alternatives? ![]() |
||||
|
IDK what's your exact requirement but maybe you can use the ccbDrawcoloredRectangle() command to draw a line, you can try converting 3D position into 2D position and use it with the drawrectangle command if you want to have the line in 3D space, but I am not sure if it will work as 3D or not, you can give it a try, or maybe you can just use a plane mesh with a scale similar to that of a line. Use geometry (polygon editing) api commands to change the position of vertices of the plane to draw lines. |
||||
|
@carlosmbr here is the code to create a line in the editor there Coppercube but you do very little with it because it is invisible in the 'editor if it is not selected you can use it as a collider , in the game it is invisible. var meshnode = editorGetSelectedSceneNode(); |
||||
|
Thanks - @just_in_case, pmax. By answer. funny i thought the same as just_in_case. but the destination is webgl and the texture animator that I downloaded does not work there. I thought if you do that it won't work either. I'm trying to create a node following copper licht's tutorial. and put the points where I want it would be like the plane idea but I could move the vertex. |
||||
|
why not use 2d line? |
||||
|
@t, it still uses the same approach suggested by @just_in_case above. You still need to get the 3D positions of objects, and still have to convert them to 2D positions. and then draw the 2D line that will act as a 3D line. He also suggested that it can be done with polygon editing API, and @pmax has provided the code for it. So it is totally the preference of the developer, how he wants to implement something. It would have been much better if you have provided the code to the OP instead of showing an image. This is not something that hasn't been already done by others in the community. So if you want to help then help it by providing solutions, rather then flexing with the images. |
||||
|
If you need function for draw line (cuz coppercube hasn't own one) i created this one for own use (based on one of my previous answer about Pythagoras theorem), use it after transform 3d position into 2d. Not sure about perfomance
|
||||
|
Thank you very much - I thought it was very good. |
||||
|
wrote: Thank you very much - I thought it was very good. You can try to use my function library to draw lines, it is implemented using differential method, so it works very well, with smooth edges and more efficient drawing. I just ran a test and with 1000 draws my function took an average of 2417ms and the other draw function took an average of 2778ms. The one on the right side of the picture is the result drawn by my function, which has significantly better edges. You can find it here: https://ambiera.com/forum.php?t=... |
||||
|
For lines in 3D i use cylinder that i scale as needed and it looks and works very nicely -if you need huge amount of lines then this method can be too heavy. I put cylinder to a PointA then i rotate it towards PointB then i calculate distance and scale it as needed. Simple example+ action. https://drive.google.com/file/d/... |
|