Solved

OpenGL prob - for Mike Lischke

Posted on 2000-03-03
13
342 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 287
creating manifest for my dll that called from activex 6 100
Simple Delphi Question 9 83
Tviruailstringtree sort multi columns on header click 1 54
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…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

867 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

18 Experts available now in Live!

Get 1:1 Help Now