Solved

OpenGL prob - for Mike Lischke

Posted on 2000-03-03
13
339 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now