Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

OpenGL prob - for Mike Lischke

Posted on 2000-03-03
13
345 Views
Last Modified: 2011-10-03
Hi Mike,
Thanks for your help in with my object picking problem.  But I'm still having problems relating the mouse click to a certain object.  i.e. Create a house in 3d studio (Face, window, door ect.) load it in using the 3d viewer.  Then click the door and know that i've clicked the door.  I would like to show a message like "opening door" or something like that.

Any Thoughs?

Sorry about the amount of points on offer here, but I promise that I will give you about 500 as and when I get them.

Cheers
John.
0
Comment
Question by:WoodyJ3
  • 8
  • 5
13 Comments
 
LVL 10

Expert Comment

by:Lischke
ID: 2579506
Hi John,

I'm not sure if I understood your problem. What do you mean with "show a message..." Once you know that you clicked the door you can easily show a message box or set a label's caption. So what is your true problem?

Ciao, Mike
0
 

Author Comment

by:WoodyJ3
ID: 2579594
With the project I sent you, you put in some code that find the number of mesh hits under a mouse point.  The problem is I can't figure out how to translate that information back into the 3D studio database.  

:using the house example.
four objects in one 3D studio scene.
Window, HouseFace, Roof, Door.

If I click the window I know I have one hit under the mouse but I don't know what it was I clicked.  
I think I need to somehow query the objects list to find the window object and get its coordinates and compare them to the coordinates of the object I clicked on the screen.

Hope this makes sense.

Cheers
John.

0
 
LVL 10

Expert Comment

by:Lischke
ID: 2579625
Aaah, yes, now I got it. Well, I think it is quite easy to find the corresponding object. Recall where the values have been pushed onto the name stack (loaded, more precisly). Now look deeper. The values are actually the indices of the FLists list. This list contains your meshs so you can directly go into it with the value you got from the picking (at least if the picking code is still almost the same as I send it to you).

Ciao, Mike
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:WoodyJ3
ID: 2579660
Ok.  I'll have a look.

Any chance of an example?  If it takes time don't worry about it.

I'll let you know how it goes shortly.

Cheers
John.
0
 

Author Comment

by:WoodyJ3
ID: 2580113
Humm.  I'm getting some really strange results.  I'll send you the project shortly.

See if you can make anything from it.

Cheers
John.
0
 

Author Comment

by:WoodyJ3
ID: 2580333
Did you receive the project ok?
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2580357
Yep, received it and am just over it. It's quite a lot of work to find again all the stuff. The code is complex, you made your own changes and haven't looked at my code for a while now. Please let this be the last time...

Ciao, Mike
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2580658
Bad news, John. I spent a lot of time to work out what is wrong and found nothing. I still have one idea (rendering the scene from the view of the picking matrix) but I'm going to go home and I will be back on monday. Perhaps I have more luck (and still like to) finding out what's wrong. But it could well take several days next week.

Ciao, Mike
0
 

Author Comment

by:WoodyJ3
ID: 2586716
Adjusted points to 60
0
 

Author Comment

by:WoodyJ3
ID: 2586717
Yeah, sorry about this.  I promise this will be the last time.

I still promise the 500 points as and when I get them.  I just hope you have some luck with the problem.

I'm gonna spend all of today trying to figure it out.

I should be getting my Delphi Developers book on OpenGL tomorrow so hopefully that will help.

I look forward to hearing from you.

Thanks again.

John.
0
 

Author Comment

by:WoodyJ3
ID: 2586902
Problem Solved!!!!!

I started rendering the picking matrix as you suggested.  And found that the Y cooridante was the wrong way around.  So I converted it to openGL coordinates Top = Height, bottom = 0 and bingo!

This is a rough version so you've got to take into account the window frame hence the hardcodded - 22.

Do you want the points now or wait until I've got the full 500?

Code:


var
  Scale: Single;
  ConvertedY : Integer;
  HalfHeight : Integer;
begin
  ClearBuffersAndBackground;

  if FCameraChanged or FPicking then
  begin
       FCameraChanged := False;
       // set up projection
       glMatrixMode(GL_PROJECTION);
       glLoadIdentity;

    // Set up picking matrix
       If FPicking Then
    Begin

      HalfHeight := (Height Div 2);

      ConvertedY := (HalfHeight - FLastY) + HalfHeight;

      gluPickMatrix(FLastX, ConvertedY - 22, 3, 3, TVector4i(FViewport));
    End;


       ApplyPerspective(FViewport, Width, ClientHeight, FDPI);
  end;
0
 
LVL 10

Accepted Solution

by:
Lischke earned 60 total points
ID: 2586966
Hurra :-) I thought this could never be solved without huge effort. I was nearly to give it up. Well, I think what I gave you here was not worth 500 points, so I'd suggest that you give me the 60 points assigned here and forget about the other until the next big problem arises.

Ciao, Mike
0
 

Author Comment

by:WoodyJ3
ID: 2587494
Thanks for the help.  I'll let you know how I get on.  Now I know which object I'm clicking on it all looks pretty smooth.  

Cheers
John.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question