Drawing lines between 2 nodes
Drawing lines between 2 nodes
Hi all,
Im working on a molecular simulation and i need a way of drawing bonds between atoms in a material.
I am currently using the draw3Dline method but i was just wondering if anyone knows of a better way to accomplish this or should I stick with the draw3Dline?
One other thing i noticed is that if i have my first atom in a list of atoms at position (1,1,1) and try to draw a line from that atom to another the lines are shifted back to (0,0,0)... I have to subtract out the position of the first atom inorder to move the lines to their correct position. Can anyone tell me why this is?
Thanks a lot.
Im working on a molecular simulation and i need a way of drawing bonds between atoms in a material.
I am currently using the draw3Dline method but i was just wondering if anyone knows of a better way to accomplish this or should I stick with the draw3Dline?
One other thing i noticed is that if i have my first atom in a list of atoms at position (1,1,1) and try to draw a line from that atom to another the lines are shifted back to (0,0,0)... I have to subtract out the position of the first atom inorder to move the lines to their correct position. Can anyone tell me why this is?
Thanks a lot.
Re: Drawing lines between 2 nodes
I think it's the easiest way...cp51 wrote:I am currently using the draw3Dline method but i was just wondering if anyone knows of a better way to accomplish this or should I stick with the draw3Dline?
or maybe create a mesh, scale it as needed, place and rotate it...
A wild guess: you don't set the tranformation before you draw the lines...cp51 wrote:One other thing i noticed is that if i have my first atom in a list of atoms at position (1,1,1) and try to draw a line from that atom to another the lines are shifted back to (0,0,0)... I have to subtract out the position of the first atom inorder to move the lines to their correct position.
use this before you draw the lines:
Code: Select all
matrix4 tmat;
pVideoDriver->setTransform(ETS_WORLD, tmat);
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Using a manually rendered line mesh is probably far more efficient. Simply use the positions as vertex list and add each conincident vertex indices into the list (i.e. if node 5 and 8 are connected, add both 5 and 8 consecutively to the index list, assuming you start numbering at 0). Then call drawVertexPrimitiveList, which will draw all the lines in one call.
Yeah you definetly will need to do some optimisations in terms of rendering if you're drawing lots of links and lots of atoms.
In IrrAI i was drawing waypoints as cube scene nodes and an individual call to draw3DLine for every waypoint that was linked together. Fine for small numbers of waypoints but as they grew the performance drop was pretty big. Now i have a meshbuffer which i add cubes to for the waypoints and add the links in as arrows drawn from 3 triangles and it works much much better! If you need any help with it i can send you my class which draws my waypoint graph.
In IrrAI i was drawing waypoints as cube scene nodes and an individual call to draw3DLine for every waypoint that was linked together. Fine for small numbers of waypoints but as they grew the performance drop was pretty big. Now i have a meshbuffer which i add cubes to for the waypoints and add the links in as arrows drawn from 3 triangles and it works much much better! If you need any help with it i can send you my class which draws my waypoint graph.
yes, something like this I had in mind...JP wrote:In IrrAI i was drawing waypoints as cube scene nodes and an individual call to draw3DLine for every waypoint that was linked together. Fine for small numbers of waypoints but as they grew the performance drop was pretty big. Now i have a meshbuffer which i add cubes to for the waypoints and add the links in as arrows drawn from 3 triangles and it works much much better!
but isn't it strange, that drawing 3 triangles is more efficient than drawing 1 3dline !?!?!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Is it? I didn't know it was... But it's definetly better to batch up all ya draw calls!
Maybe 3D lines are actually drawn as triangles or something.... In DX they can have thickness (or is it OGL.. or both?) so that's certainly something more fancy going on than a simple 3D line from one point to another with 2 verts!
Maybe 3D lines are actually drawn as triangles or something.... In DX they can have thickness (or is it OGL.. or both?) so that's certainly something more fancy going on than a simple 3D line from one point to another with 2 verts!
Hey all,
thanks for all your help. Ive been away from the comp for a few days doing some studying so i havent gotten around to trying out your suggestions yet, but thanks a lot, youve all been most helpful. Ill let you know how it goes and if i have any trouble.
Btw, i have around 3500 atoms and about 100,000 lines i believe in my last version, so any optimization is very useful.
Thanks again,
-CP51
thanks for all your help. Ive been away from the comp for a few days doing some studying so i havent gotten around to trying out your suggestions yet, but thanks a lot, youve all been most helpful. Ill let you know how it goes and if i have any trouble.
Btw, i have around 3500 atoms and about 100,000 lines i believe in my last version, so any optimization is very useful.
Thanks again,
-CP51
nohumorstar wrote:When we use draw3DLine method to draw a line, can we change the line width?
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
In the help file, it says it supports some material's line thickness in some platform. I wonder what that is. What material is it?
If we cannot change the thickness, what is the get-around? Do we instead have to draw a cylinder and update its position, rotation and scale every time we want to draw it?
Thank you,
If we cannot change the thickness, what is the get-around? Do we instead have to draw a cylinder and update its position, rotation and scale every time we want to draw it?
Thank you,
-
- Posts: 368
- Joined: Tue Aug 21, 2007 1:43 am
- Location: The Middle of Nowhere
no, it's only for 2d lines !!!Dark_Kilauea wrote:Actually, you can change the line thickness, but you have to do it with SMaterial.Thickness;
f32 irr::video::SMaterial::Thickness
Thickness of non-3dimensional elements such as lines and points.
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
There's a bug report open about it. Does anyone fancy changing the D3D9 implementation to draw quads instead of lines?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way