|
|
Comments and Discussions
|
|
 |
|

|
I noticed that the fit command doesn't seem to work if you say use the cylindrical surfaces and rotate the surfaces on screen via the mouse and then you hit the fit button... The surface or the view scene is still off of the screen. How do you fix that issue?
Enjoyed this, love playing with the concepts which is also a great post...
|
|
|
|

|
I tried to use the bounding box and its projections for the fit algo. However the implementation is not fully correct. The best possible solution would be to use bounding spheres instead of bounding boxes which will give less accurate fits but more consistent throughout all rotations.
Regards
N. Sharjith
|
|
|
|

|
Oooo got it... I was just going to say that I just projected the opposite corners and checked those as well and then picked the worst case... and it seemed to fix that... Thanks! Great learning tool..!
|
|
|
|

|
Great, hope it is helpful to you! It would be great if you can share the patch that fixed it.
Regards
N. Sharjith
|
|
|
|

|
Since I used your wisdom on OpenGL and my trusty red book at my side, and an inquisitive nature and a LOT of Trial and error . I would be happy to post. For those less inclined, the area of the fit that does the grunt work of what Sharjith post is the code CGLView::FitView() ...
There he gets the Boundary box of all elements of the screen returned ... HOWEVER, it only tests for the front left bottom corner and the back right top corner... Looking at the simple case, rectangle the bottom left, top right corner are tested. if we rotate the rectangle 45 degrees CW the top-left (2) corner and bottom Right (1) corner CAN be off of the screen so in essence clips the other two othgonal corners.
2-------------- 3
| |
| |
0 ------------- 1
To resolve we need to test those other corners also, so the case where:
CViewBoundingBox B = m_pSelectElement->GetBoundingBox();
lx = B.XMax(); ly = B.YMax(); lz = B.ZMax();
sx = B.XMin(); sy = B.YMin(); sz = B.ZMin();
lx2 = B.XMax(); ly2 = B.YMin(); lz2 = B.ZMax();
sx2 = B.XMin(); sy2 = B.YMax(); sz2 = B.ZMin();
..
..
..
gluProject(lx, ly, lz, mvmatrix, projmatrix, viewport,
&mx, &my, &mz);
gluProject(sx, sy, sz, mvmatrix, projmatrix, viewport,
&cx, &cy, &cz);
gluProject(lx2, ly2, lz2, mvmatrix, projmatrix, viewport,
&mx2, &my2, &mz2);
gluProject(sx2, sy2, sz2, mvmatrix, projmatrix, viewport,
&cx2, &cy2, &cz2);
...
...
...
...
CRect rcRect;
m_pViewWnd->GetClientRect(&rcRect);
volRectTwo.SetRect(cx2,cy2,mx2,my2);
volRectTwo.NormalizeRect();
volRect.SetRect(cx,cy,mx,my);
volRect.NormalizeRect();
if( rcRect.Width()>rcRect.Height() )
{
if( volRectTwo.Height()>rcRect.Height() && volRectTwo.Height()>volRect.Height() )
volRect=volRectTwo;}
else
{
if( volRectTwo.Width()>rcRect.Width() && volRectTwo.Width()>volRect.Width() )
volRect=volRectTwo;}
Fit3d(volRect);
Sharijith is correct if you use a sphere it would be correct, the correct way is to get the center of the elements project to the near and far clip plane, create a normal vector and use the radius and the center point of the sphere to create your points for checking..create 3d points project those and check those to the client rect.
modified 15 Jun '12 - 10:59.
|
|
|
|

|
Thank you very much Ninpo! Using the Bounding box gives the most accurate fit in any projection view, exactly fitting the object into the screen. The sphere method is quick and dirty and will give inaccurate fits in many cases, though it makes sure that the object doesn't go out of the screen limits. Imagine a bounding sphere of a cylinder with 100 length and 10 diameter. The bounding sphere will be of 100 diameter and will fit the cylinder completely into the screen. However in a projection view showing the 10 diameter circular end of the cylinder, the fit will not be realistic. So the box method is the best. Thank you again for sharing the code, I will update the fix soon.
Regards
N. Sharjith
|
|
|
|

|
Excellent job Sharjith!!!
Thanks!!
|
|
|
|
|

|
1)
void CCadSurfDoc::OnCircles()
{
...
CGLFont *myFont = new CGLFont((LPCTSTR)str, P);
dContext->Display(myFont);
...
delete myFont;
...
} // !!!!!CRASH!!!!!
2)
void CCadSurfDoc::OnCircles()
{
...
CGLFont myFont((LPCTSTR)str, P);
dContext->Display(&myFont);
...
} // !!!! OK !!!!
3)
void CCadSurfDoc::OnCircles()
{
...
CGLFont XmyFont((LPCTSTR)str, P);
CGLFont myFont = (CGLFont*)XmyFont.Copy();
dContext->Display(myFont);
...
delete myFont;
...
} // !!!! OK !!!!
Why?
I LOVE CODING!
|
|
|
|

|
Not an answer to this though... but looks like you ported the project to one of the latest Visual Studios on which this strange behaviour happens. It worked fine on VS6. I think it is time to investigate, fix and upload the latest code built in latest VS. Linux version written in Qt3 doesn't seem to have this problem either.
Regards
N. Sharjith
|
|
|
|

|
Thanks!
I use MS VS.Net 2003.
I LOVE CODING!
modified 17 Apr '12 - 7:37.
|
|
|
|

|
In the file GLFont.h export the entire class to the dll instead of the individual public methods. To do so you need to take off the VKGRAPHIC_API that comes before all the public methods and add it before the class name. That is...
Change this...
class CGLFont : public CGLObject
{
public:
VKGRAPHIC_API CGLFont(const string&, const CPoint3D&, const char *tf = "MS Sans Serif", int ht = 16,
int wt = 0, DWORD it = 0, const TextAlign& = LEFT);
VKGRAPHIC_API virtual ~CGLFont();
VKGRAPHIC_API void DrawString();
VKGRAPHIC_API virtual CGLObject* Copy() const;
VKGRAPHIC_API virtual void DefineDisplay();
VKGRAPHIC_API virtual void Display(const GLDisplayMode& = GLWIREFRAME);
VKGRAPHIC_API virtual void Hilight(const GLDisplayMode&);
private:
...
}
to this...
class VKGRAPHIC_API CGLFont : public CGLObject
{
public:
CGLFont(const string&, const CPoint3D&, const char *tf = "MS Sans Serif", int ht = 16,
int wt = 0, DWORD it = 0, const TextAlign& = LEFT);
virtual ~CGLFont();
void DrawString();
virtual CGLObject* Copy() const;
virtual void DefineDisplay();
virtual void Display(const GLDisplayMode& = GLWIREFRAME);
virtual void Hilight(const GLDisplayMode&);
private:
...
}
And it should work fine with delete called legitimately on all myFont objects.
Regards
N. Sharjith
|
|
|
|

|
Thanks!
Now,it worked fine on VS2003.
I LOVE CODING!
|
|
|
|

|
thanks.
Now ,i am trying to use VKGeom,VKGraphic and CGLView to draw 3d curve without opengl basement,but i can't make it.my question is about:
1.Z Axis direction adjustment.
2.Z Axis deepth.
3.The Origin adjustment.
if anybody can do me a favour,contact me 396806883@qq.com,lookfar@163.com.thanks a lot.
|
|
|
|

|
Hello,
Can you please specify which curve are you trying to draw and what class are you trying to use? If you are trying to make a Bezier or B-Spline curve just create the control points and pass the list of control points to the constructor. I can tell you more if you can tell me what exactly is your question rather that just telling me what is it about.
Regards
N. Sharjith
|
|
|
|

|
thank for reply.
my curve is very simple,it's based on some lines,and not special kind.
I now meet a problem about axis rotating.I haved used the following variables:
'xRot,yRot,zRot' to adjust the direction of axis,but it's confused me much.my aim is like:X axis from left to right,Y axis is rotated by X -45℃,Z axis vertical down.
how do i use 'xRot,yRot,zRot' to make the axis's direction?
|
|
|
|

|
My friend, I am more than ready to help you but please explain which class and methods are you using. Your explanation doesn't give me an accurate picture of what you are trying to do and where you are getting stuck.
Regards
N. Sharjith
|
|
|
|

|
How do adjust the direction of the x,y,z Axis.Now three Axis lines are displayed in the center of window,How can i modify the angle between x and y Axis.
|
|
|
|

|
then save the curve.
it is hard exercise for me....
please help !!!
thank very much.
|
|
|
|

|
So even using someone else's code you are incapable of completing the exercise given by your teacher. How you expect to pass your course is a mystery.
|
|
|
|

|
I would like to operate this sofware but when I build, I get this error(I use Visual C++ 6):
Linking...
LINK : fatal error LNK1104: cannot open file "VKGeom.lib"
Error executing link.exe.
CadSurf.exe - 1 error(s), 0 warning(s)
Could anyone help me?
Guims37700
|
|
|
|

|
When I open the cadsurf project in Visual C++ 2005, it has one compilation error in materialDlg.cpp as follows:
cadsurf\materialdlg.cpp(39) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMaterialDlg::* )(UINT)' to 'BOOL (__thiscall CCmdTarget::* )(UINT)'
None of the functions with this name in scope match the target type
How to fix this problem?
Thanks for the nice work,
|
|
|
|

|
Stricter C++ adherence in (MFC) Visual Studio 2005 will not allow compilation unless many changes are made to the code. Please use Visual C++ 6 for building
Regds
N. Sharjith
|
|
|
|

|
When I open this program and click some shape icons, this program will be stop immediately,is anyone same to me???
|
|
|
|

|
I also can't run it !Why not someone give the answer?
|
|
|
|

|
Hi Sharjith
Have you ever experimented with OpenCasCade? Any comments on the same.
Nitin
|
|
|
|

|
I'm all alone to do my own CAD/CAM software, and I would appreciate some kind of help.
If you are interrested to work on this kind of project please contact me.
|
|
|
|

|
How to run 2 different(or same) OpenGL objects in one DialogBox?
IDC_STATIC1 is a first OpenGL objects Scene window.
IDC_STATIC2 is a second OpenGL objects Scene window.
IDC_STATIC1 and IDC_STATIC2 ,they are placed on IDD_DIALOG1.
code:
pclStatic = (CStatic *)GetDlgItem(IDC_OpenGL_Window);
pclGlView = new CGlView(pclStatic);
pclGlView->OnCreate();
pclGlView->InitGL();
pclGlView->DrawGLScene();
pclStatic1 = (CStatic *)GetDlgItem(IDC_OpenGL_Window);
pclGlView1 = new CGlView(pclStatic1);
pclGlView1->OnCreate();
pclGlView1->InitGL();
pclGlView1->DrawGLScene();
Will not involve both windows (IDC_STATIC2,IDC_STATIC1)
|
|
|
|
|

|
How to draw line3D or cycle 3D by Mouse
|
|
|
|

|
Hello,
To do the things more positively. Just started u r coding and ask if the problem.
|
|
|
|

|
If you start drawing something the program crash.
For example choosing the icon points cause the program to crash
in DefineDisplay at glDisable (GL_POINT_SMOOTH);
However it looks as a very good piece of code.
I'm looking forward for the full working version...
|
|
|
|
|

|
Hi,
Thanks for the feedback, the problem is probably with the graphics card u have. Please let me know your systems config.
Regards
N.Sharjith
|
|
|
|

|
It is still crashing.please upload the correct version soon
Thank you
|
|
|
|

|
Hi,
Please try running the pogram after recompiling by commenting out the code parts for displaying the fonts in all the geometry creation tasks in the CCadSurfDoc events.
The fonts give trouble on graphic cards with no OpenGL support and low vram. The culprit is probably wglFonts.
I recommend a graphics card with full OpenGL drivers loaded and a vram of atleast 32mb.
Regards
N.Sharjith
|
|
|
|

|
If you run the exe and drag a selection over the axes the program crashes.
|
|
|
|

|
Hi Jon,
Thankyou for the feedback. I think it is some thing related to the graphics card you have. I have come across the problems like selection not happening, crashing if fonts displayed etc. on other computers with no AGP cards or low level cards. The graphics card must have full OpenGL support and enough video memory. The project is updated now. You may download the fresh one. All the best!
Regards
N. Sharjith
|
|
|
|

|
That must be the largest screenshot ever in a CodeProject article. The source code downloads are huge, too. Are you seeking the award for biggest picture and files?
|
|
|
|

|
This is what happens when the .APS, .NCB, and .OPT files are included in the archive which is unnecessary since they are all regeneratable.
Sharjith : you should add the height and width attributes to the img tag so that the image is displayed at the correct size.
The Ten Commandments For C Programmers
|
|
|
|
|

|
And I bet the line with Windows Task Bar is conceptually necessary....
Ultimate all-in-one XP-Style UI multiplatform solution: Tooltips, XP Menus, Hyperlinks, Drawing Graphics and formatted documents, plus powerful binary resource reuse. All Free 100%, visit www.tooltips.net now. It can be used in VC++, C#, Java, VB, Delphi, Borland C++, Borland C++ Builder, as well as any COM-compatible platform.
|
|
|
|

|
Yeah, pressing the "Print" key is that much cooler than pressing "Alt" + "Print" keys together ...
|
|
|
|

|
If he WOULD have pressed the "Print" key only, he would have got the entire screen in the dump (which he obviously didn't).
I can't see what's wrong in doing a sufficiently large application dump in the article.
It gives you a better idea of what everything is all about...don't you think?
Lars Wadefalk
Siemens Laser Analytics
|
|
|
|

|
> If he WOULD have pressed the "Print" key only, he would have got the entire screen in the dump (which he obviously didn't).
He did so originally, but has updated his article since.
> I can't see what's wrong in doing a sufficiently large application dump in the article.
No? Who's interested in *your* computer's task bar and why should something that can be said with, say 640x480 pixels done so with a XGA or even UXGA image?
|
|
|
|
 |
|
|
General News Suggestion Question Bug Answer Joke Rant Admin
|
A basic demo of modeling curves and surfaces in OpenGL.
| Type | Article |
| Licence | CPOL |
| First Posted | 17 Feb 2003 |
| Views | 163,168 |
| Downloads | 11,803 |
| Bookmarked | 102 times |
|
|