Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OpenGL prob - for Mike Lischke

Posted on 2000-03-03
13
Medium Priority
?
354 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

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!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

610 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