To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.cad.devOpen lugnet.cad.dev in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 CAD / Development / 10097
10096  |  10098
Subject: 
Re: Rendering implementation details
Newsgroups: 
lugnet.cad.dev
Date: 
Tue, 25 Jan 2005 01:41:11 GMT
Viewed: 
2156 times
  
In lugnet.cad.dev, Mark Tarrabain wrote:
I was envisioning how an LDraw renderer would be implemented if it were
done with OpenGL, and I've arrived at some questions that I can't answer
for myself.

I'm particularly wondering about line type #5, the optional line.
According to the LDraw file format specification: "This draws a line
between the first two points, if the projections of the last two points
onto the screen are on the same side of an imaginary line through the
projections of the first two points onto the screen."   I understand
what this means, but I'm confused about certain details of
implementation that could, as near as I can see, be the cause of some
inefficiency.

For this line type, using OpenGL one thing I came up with was that one
would use gluProject on each vertex on both line segments to see where
they would fall on screen, examine the end points, and then decide
whether or not to draw them based on that, but I would imagine calling
gluProject 4 times for each optional line listed in a part definition
(especially since not all of them are necessarily even displayed!) would
adversely affect performance.   The only other way I could see it
working is to do _all_ the rendering in the application, and not rely on
something like opengl at all.  Again, I would imagine this to severely
impact performance.

Could anyone enlighten me as to how this could be done without making
serious compromises in efficiency?  Or am I completely out to lunch
about the performance impact of the concerns I've mentioned?

I'm not sure it's possible to implement for real without serious slowdowns.  It
might be possible to implement in a vertex program, but I haven't studied vertex
programs, so I really don't know.  (I'm pretty sure you can't throw out a vertex
from a vertex program, but you should be able to change the alpha to 0 so that
it then gets thrown out later in the pipe.)

LDView does something similar to what you suggest.  In fact, when Don Heyse
first added the type 5 code to LDView (copied/ported from his ldglite), he did
exactly what you suggest.  I later optimized it by doing the work of gluProject
myself, but only doing the minimal math needed to extract the two-dimensional
unscaled projected points.  You don't need the points to be in window space, so
you can skip the window space scaling that gluProject performs, and you don't
care about the Z value, so you can skip calculating it entirely.

This does work in LDView, and it is faster than using gluProject, but it's still
pretty slow.  Turning off type 5 lines usually speeds up rendering by a whole
lot.  On the other hand, even when they're on you can look at a reasonably large
model before things slow down too much, as long as you have a reasonably fast
computer.

For reference, here is the LDView code that I use instead of gluProject:

void TGLShape::transformPoint(TCVector& point, double* matrix, double* tx,
  double* ty)
{
double x = point[0];
double y = point[1];
double z = point[2];
double tw;

// x' = a*x + b*y + c*z + X
// y' = d*x + e*y + f*z + Y
tw = matrix[3]*x + matrix[7]*y + matrix[11]*z + matrix[15];
*tx = (matrix[0]*x + matrix[4]*y + matrix[8]*z + matrix[12]) / tw;
*ty = (matrix[1]*x + matrix[5]*y + matrix[9]*z + matrix[13]) / tw;
}

--Travis Cobbs



Message has 1 Reply:
  Re: Rendering implementation details
 
Okay.... having had a day to think about it and a night to sleep on it, I think I've figured out something.... But it would only work if the optional lines were incident to edges of polygons that are part of the object being drawn. I'm not sure if (...) (20 years ago, 25-Jan-05, to lugnet.cad.dev)

Message is in Reply To:
  Rendering implementation details
 
I was envisioning how an LDraw renderer would be implemented if it were done with OpenGL, and I've arrived at some questions that I can't answer for myself. I'm particularly wondering about line type #5, the optional line. According to the LDraw (...) (20 years ago, 24-Jan-05, to lugnet.cad.dev)

22 Messages in This Thread:







Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR