PDA

View Full Version : [OGL] glModels.distanceFrom help



Clutch
08-07-2015, 12:18 AM
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;
function glModel.distanceFrom(funcModel:glModel):extended;o verload;
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.
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?

yourule97
08-07-2015, 12:23 AM
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;
function glModel.distanceFrom(funcModel:glModel):extended;o verload;
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.
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?

Clutch
08-07-2015, 12:24 AM
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.
if (ogl.getModels(2524031219)[0].distanceFrom(WHEEL_MODEL_ID)) >2 then
writeln('true');
Same error.

yourule97
08-07-2015, 12:33 AM
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).

Obscurity
08-07-2015, 12:53 AM
^ What he said.

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

function glModel.distanceFrom(funcModel:glModel):extended;o verload;

function glModel.distanceFrom(funcTexture:glTexture):extend ed;overload;

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

Clutch
08-07-2015, 01:13 AM
Thanks

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.

Obscurity
08-07-2015, 03:02 AM
It calculates the distance between the two model coords. Having a distance of 2 would make them almost directly ontop of each other.

the bank
08-07-2015, 07:52 PM
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.

Olly
08-07-2015, 09:07 PM
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.

the bank
08-07-2015, 09:24 PM
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.

yourule97
08-07-2015, 09:29 PM
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."

Olly
08-07-2015, 09:34 PM
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)

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;

Clutch
08-07-2015, 09:37 PM
I'm just comparing it to a pascal class, it's pretty close minus the obvious constructors/destructors and sections (private, protected etc)

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.

Olly
08-07-2015, 09:45 PM
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

the bank
08-07-2015, 10:46 PM
I'm just comparing it to a pascal class, it's pretty close minus the obvious constructors/destructors and sections (private, protected etc)

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.


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.

slacky
08-08-2015, 07:33 PM
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 =)

the bank
08-08-2015, 07:41 PM
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...


I would argue they are structs.


-



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...?

slacky
08-08-2015, 07:59 PM
When did I refer to anything other than Lape...?

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.

Olly
08-08-2015, 08:11 PM
...

But....

http://i.imgur.com/qmiZ0dU.png

slacky
08-08-2015, 08:26 PM
But....

http://i.imgur.com/qmiZ0dU.png
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.

Olly
08-08-2015, 08:37 PM
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.