?
Solved

OpenGL prob - for Mike Lischke

Posted on 2000-03-03
13
Medium Priority
?
351 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
[X]
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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 240 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

765 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