# Thread: [ogLib] The Model Positioning Problem

1. ## [ogLib] The Model Positioning Problem

The Model Positioning Problem

Introduction

A lot of complaints regarding ogLib, or OpenGL for that matter, pan around the issue of locating models. Sure, we can get the X and Y of a model, but some aren't exactly where they appear to be, or where ogLib thinks they are. Take the following example:

B is the actual position of the model. However, the real model appears to be higher, at A. Or, rather, the area that we'd interact with. This is part of the reason I made .adjustPosition(). However, adjusting the position manually wouldn't quite cut it. Sure, we could simply:
Simba Code:
ogl.getModels(gargoyleID)[0].adjustPosition(0,-100)
In this occasion, that'd work great. However, what about when the camera is adjusted as seen below:

Now the position would be incorrect by ~80px. This is where we run into our problem. However, with ogLib, you can get the height, or verticalDegrees, of the camera which can be used to adjust your offset!

For now, let's make a temporary variable for camera adjustment. We can see that at 0 degrees, we require an offset of -100px. However, at 52 degrees, we only require -20px, making a difference of 80px:
Simba Code:
verticalDegrees:=mainScreen.getVerticalDegrees();//~ -100px is the maximum offset.//~ When verticalDegrees is 52, we need to add 80px.//~ We need to get a percentage of 80px.//~ We need to remove that percentage from -100px.cameraAdjustment:=round(-100{px}+(52{degrees}-verticalDegrees)/52{degrees}*80{px});somePoint:=ogl.getModels(gargoyleID)[0].adjustPosition(0,cameraAdjustMent);

That would be the complicated way of doing it. You could just assume 0 degrees is an offset of 100px, while 90 degrees is an offset of 0px:
Simba Code:
verticalDegrees:=mainScreen.getVerticalDegrees();cameraAdjustment:=round((90{degrees}-verticalDegrees)/90{degrees}*-100{px});somePoint:=ogl.getModels(gargoyleID)[0].adjustPosition(0,cameraAdjustMent);

Or, if you felt like dealing with radians (credit to @Zyt3x):
Simba Code:
cameraAdjustment:=round((-1+sin(mainScreen.getVerticalRadians()))*90);

Hope this helps!
Last edited by Obscurity; 08-04-2015 at 12:28 AM.

2. Registered User
Join Date
Jun 2018
Posts
1
Mentioned
0 Post(s)
Quoted
1 Post(s)
It's a kind of nice info u have shared

3. Originally Posted by hiretablets
It's a kind of nice info u have shared