Results 1 to 21 of 21

Thread: [OGL] glModels.distanceFrom help

  1. #1
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default [OGL] glModels.distanceFrom help

    Okay so I am trying to find the distance from one model to another to detect if a door is open. I found the following method;
    Simba Code:
    function glModel.distanceFrom(funcModel:glModel):extended;overload;
      begin result:=sqrt(pow(self.x-funcModel.x,2)+pow(self.y-funcModel.y,2));end;

    Issue is when I try to put it into play I get errors.
    Simba Code:
    writeln(ogl.getModels(2524031219)[0].distanceFrom(WHEEL_MODEL_ID));
    Error: Don't know which overloaded method to call with params (UInt32) at line 353
    Compiling failed.

    I've mixed and matched and tried everything that I've thought of and can't get it to work. Has anyone done this successfully and have an example I could look at or suggestions on things to try?

  2. #2
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    Okay so I am trying to find the distance from one model to another to detect if a door is open. I found the following method;
    Simba Code:
    function glModel.distanceFrom(funcModel:glModel):extended;overload;
      begin result:=sqrt(pow(self.x-funcModel.x,2)+pow(self.y-funcModel.y,2));end;

    Issue is when I try to put it into play I get errors.
    Simba Code:
    writeln(ogl.getModels(2524031219)[0].distanceFrom(WHEEL_MODEL_ID));
    Error: Don't know which overloaded method to call with params (UInt32) at line 353
    Compiling failed.

    I've mixed and matched and tried everything that I've thought of and can't get it to work. Has anyone done this successfully and have an example I could look at or suggestions on things to try?
    Wait, don't you have to convert the result into a string to print it out?

  3. #3
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by yourule97 View Post
    Wait, don't you have to convert the result into a string to print it out?
    I've never had to in the past it'll return true or false. If you do writeln(ogl.getModels(ID)) it'll write out the model + coords or something along those lines.

    I went ahead and checked regardless.
    Simba Code:
    if (ogl.getModels(2524031219)[0].distanceFrom(WHEEL_MODEL_ID)) >2 then
        writeln('true');
    Same error.
    Last edited by Clutch; 08-07-2015 at 12:29 AM.

  4. #4
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    I'm not familiar with ogL, so I have to ask, how are glModels passed? Are they integers as well?

    EDIT: I'm trying to read the source code for ogLib and while I am still confused it looks like a glModel consists of 4 different parameters. It looks like you are just passing a single unsigned integer. Could be completely wrong, but hopefully this helps (and sorry for posting if it doesn't haha).

  5. #5
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    ^ What he said.

    Simba Code:
    function glModel.distanceFrom(funcPoint:tPoint):int32;

    function glModel.distanceFrom(funcModel:glModel):extended;overload;

    function glModel.distanceFrom(funcTexture:glTexture):extended;overload;

    Where do you see...
    Simba Code:
    function glModel.distanceFrom(funcID:int32):int32;
    ...? .




    Skype: obscuritySRL@outlook.com

  6. #6
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Thanks

    Simba Code:
    if (ogl.getModels(2524031219)[0].distanceFrom(ogl.getModels(WHEEL_MODEL_ID)[0])) >2

    So I'm confused is the distanceFrom determinig pixels between point A and point B?
    Well did some testing, basically I have no idea what it's going off of. I get different results depending on camera angle whether I use >2 or even using >195.. Mind Blown.
    Last edited by Clutch; 08-07-2015 at 02:33 AM.

  7. #7
    Join Date
    Jun 2012
    Posts
    586
    Mentioned
    112 Post(s)
    Quoted
    296 Post(s)

    Default

    It calculates the distance between the two model coords. Having a distance of 2 would make them almost directly ontop of each other.




    Skype: obscuritySRL@outlook.com

  8. #8
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by yourule97 View Post
    EDIT: I'm trying to read the source code for ogLib and while I am still confused it looks like a glModel consists of 4 different parameters. It looks like you are just passing a single unsigned integer. Could be completely wrong, but hopefully this helps (and sorry for posting if it doesn't haha).
    Keep in mind Simba is not object oriented in any regard. AFAIK it can only make use of structs. There is no "constructor" like you would assume he is using.

  9. #9
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    Keep in mind Simba is not object oriented in any regard. AFAIK it can only make use of structs. There is no "constructor" like you would assume he is using.
    Lape's records are pretty much objects I would say.

  10. #10
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    Lape's records are pretty much objects I would say.
    I would argue they are structs.

    Both records and structs are immutable, and cannot be inherited.

    You could argue a struct is an object, however I would respond that an object by definition is both polymorphic and inheritable.

  11. #11
    Join Date
    Sep 2014
    Posts
    447
    Mentioned
    10 Post(s)
    Quoted
    203 Post(s)

    Default

    Oh yeah, I wasn't really thinking semantics when I posted that, I was just using terminology I was more familiar with. I probably coulda just said "you passed the wrong thing to the method."

  12. #12
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    I would argue they are structs.

    Both records and structs are immutable, and cannot be inherited.

    You could argue a struct is an object, however I would respond that an object by definition is both polymorphic and inheritable.
    I'm just comparing it to a pascal class, it's pretty close minus the obvious constructors/destructors and sections (private, protected etc)

    Simba Code:
    type
      TBar = record
        x: Integer;
     end;

    type
      TFoo = record(TBar)
        y: Integer;
     end;

    procedure TBar.Hello;
    begin
      Writeln('TBar');
    end;

    procedure TFoo.Hello; override;
    begin
      Writeln('TFoo');
      inherited;
    end;

    var
      f: TFoo;

    begin
      f.Hello;
    end;
    Last edited by Olly; 08-07-2015 at 09:36 PM.

  13. #13
    Join Date
    Mar 2015
    Posts
    438
    Mentioned
    21 Post(s)
    Quoted
    211 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    I'm just comparing it to a pascal class, it's pretty close minus the obvious constructors/destructors and sections (private, protected etc)

    Simba Code:
    type
      TBar = record
        x: Integer;
     end;

    type
      TFoo = record(TBar)
        y: Integer;
     end;

    procedure TBar.Hello;
    begin
      Writeln('TBar');
    end;

    procedure TFoo.Hello; override;
    begin
      Writeln('TFoo');
      inherited;
    end;

    var
      f: TFoo;

    begin
      f.Hello;
    end;
    Uncapable of joining in on your guys discussion as I'm oblivious to what a constructor/destructor is, but what is TBAR and TFOO? I've seen the reference fairly frequently it seems.

  14. #14
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by Clutch View Post
    Uncapable of joining in on your guys discussion as I'm oblivious to what a constructor/destructor is, but what is TBAR and TFOO? I've seen the reference fairly frequently it seems.
    https://en.wikipedia.org/wiki/Foobar

  15. #15
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    I'm just comparing it to a pascal class, it's pretty close minus the obvious constructors/destructors and sections (private, protected etc)

    Simba Code:
    type
      TBar = record
        x: Integer;
     end;

    type
      TFoo = record(TBar)
        y: Integer;
     end;

    procedure TBar.Hello;
    begin
      Writeln('TBar');
    end;

    procedure TFoo.Hello; override;
    begin
      Writeln('TFoo');
      inherited;
    end;

    var
      f: TFoo;

    begin
      f.Hello;
    end;
    Fair enough, but keep in mind a pascal class is by no means the same thing as a typical OOP class. In fact, a pascal class is just a pointer to a pascal object, and is still limited in factors such as polymorphism etc, beyond the other limitations you mentioned yourself.

    Quote Originally Posted by Clutch View Post
    Uncapable of joining in on your guys discussion as I'm oblivious to what a constructor/destructor is, but what is TBAR and TFOO? I've seen the reference fairly frequently it seems.
    A constructor builds an object (dynamically allocates memory at runtime) whereas a destructor destroys the object (freeing that memory). Foobar is like "lorem ipsum", its just a generic thing used for irrelevant object names in code samples. Its a place-holder name.

  16. #16
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    Fair enough, but keep in mind a pascal class is by no means the same thing as a typical OOP class. In fact, a pascal class is just a pointer to a pascal object, and is still limited in factors such as polymorphism etc, beyond the other limitations you mentioned yourself.
    This is a tad confusing to read, it would be a lot simpler if you'd say "lape" when you refer to Lape, "Object Pascal" when you refer to (established) Object Pascal variants, "Oxygene" if you refer to Oxygene, all in all keep it specific because variants of Pascal and Object Pascal vary quite a bit.

    PS: The pascal-language doesn't define classes at all, nor does Lape (Lape just have fancy structs).

    Anyway, I don't really wanna get involved in this conversation, I'm just mentioning this, because.. I can =)
    Last edited by slacky; 08-08-2015 at 07:37 PM.
    !No priv. messages please

  17. #17
    Join Date
    Dec 2010
    Posts
    483
    Mentioned
    30 Post(s)
    Quoted
    328 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    PS: The pascal-language doesn't define classes at all, nor does Lape (Lape just have fancy structs).
    This is the point I have been making all along...

    Quote Originally Posted by the bank View Post
    I would argue they are structs.

    -


    Quote Originally Posted by slacky View Post
    it would be a lot simpler if you'd say "lape" when you refer to Lape, "Object Pascal" when you refer to (established) Object Pascal variants, "Oxygene" if you refer to Oxygene, all in all keep it specific because variants of Pascal and Object Pascal vary quite a bit.
    When did I refer to anything other than Lape...?

  18. #18
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by the bank View Post
    When did I refer to anything other than Lape...?
    Quote Originally Posted by the bank
    pascal class is by no means the same thing as a typical OOP class. In fact, a pascal class is just a pointer to a pascal object
    You never said Lape, you kept on saying Pascal this, and Pascal that.. Lape is it's own language, derived from Pascal, and influenced by Object pascal.
    And THIS is why I made that post, just say Lape when you mean Lape in order to avoid any confusion.

    And as you are quoting a post mentioning "Pascal Class" in this context referring to a Object Pascal class shit really starts to get confusing.

    Ofc @Olly was the one who first started the whole confusion by saying "Pascal class", when he was referring the class-datatype in FPC. He should be banned for this.

    now.. let me eat my burger in peace.
    Last edited by slacky; 08-08-2015 at 08:24 PM.
    !No priv. messages please

  19. #19
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    ...
    But....


  20. #20
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by Olly View Post
    But....

    Leaking! My infractions, points and warnings should be between me and the moderators+. Another reason to ban you!
    Be careful what you say next, it might turn into another reason for you to be banned.
    !No priv. messages please

  21. #21
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    Leaking! My infractions, points and warnings should be between me and the moderators+. Another reason to ban you!
    Be careful what you say next, it might turn into another reason for you to be banned.
    Please do not speak to up to a higher rank than you, SSRL > SRL.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •