Start adjusting camera setup to make use of high-precision space
Several more entity types still need to set up cameraRelativePosition on init. Space dust doesn't work yet.
This commit is contained in:
parent
631126494c
commit
e25d36e46c
@ -109,6 +109,7 @@ enum OOScanClass
|
||||
GLfloat no_draw_distance; // 10 km initially
|
||||
GLfloat collision_radius;
|
||||
HPVector position; // use high-precision vectors for global position
|
||||
Vector cameraRelativePosition;
|
||||
Quaternion orientation;
|
||||
|
||||
int zero_index;
|
||||
@ -200,6 +201,7 @@ enum OOScanClass
|
||||
- (void) setPosition:(HPVector)posn;
|
||||
- (void) setPositionX:(OOHPScalar)x y:(OOHPScalar)y z:(OOHPScalar)z;
|
||||
- (HPVector) position;
|
||||
- (Vector) cameraRelativePosition;
|
||||
// gets a low-position relative vector
|
||||
- (Vector) vectorTo:(Entity *)entity;
|
||||
|
||||
|
@ -598,6 +598,11 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
|
||||
return position;
|
||||
}
|
||||
|
||||
- (Vector) cameraRelativePosition
|
||||
{
|
||||
return cameraRelativePosition;
|
||||
}
|
||||
|
||||
|
||||
// Exposed to uniform bindings.
|
||||
// so needs to remain at OpenGL precision levels
|
||||
@ -615,6 +620,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
|
||||
- (void) setPosition:(HPVector) posn
|
||||
{
|
||||
position = posn;
|
||||
cameraRelativePosition = HPVectorToVector(HPvector_subtract(position,[PLAYER viewpointPosition]));
|
||||
}
|
||||
|
||||
|
||||
@ -888,17 +894,20 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
|
||||
{
|
||||
zero_distance = [[self owner] zeroDistance];
|
||||
cam_zero_distance = [[self owner] camZeroDistance];
|
||||
cameraRelativePosition = [[self owner] cameraRelativePosition];
|
||||
}
|
||||
else
|
||||
{
|
||||
zero_distance = HPdistance2(PLAYER->position, position);
|
||||
cam_zero_distance = HPdistance2([PLAYER viewpointPosition], position);
|
||||
cameraRelativePosition = HPVectorToVector(HPvector_subtract(position,[PLAYER viewpointPosition]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
zero_distance = HPmagnitude2(position);
|
||||
cam_zero_distance = zero_distance;
|
||||
cameraRelativePosition = HPVectorToVector(position);
|
||||
}
|
||||
|
||||
if ([self status] != STATUS_COCKPIT_DISPLAY)
|
||||
|
@ -45,7 +45,8 @@ enum
|
||||
{
|
||||
@private
|
||||
Vector _exhaustScale;
|
||||
GLfloat _vertices[34 * 3];
|
||||
OOHPScalar _vertices[34 * 3];
|
||||
GLfloat _glVertices[34 * 3];
|
||||
GLfloat _exhaustBaseColors[34 * 4];
|
||||
Frame _track[kExhaustFrameCount];
|
||||
OOTimeAbsolute _trackTime;
|
||||
|
@ -29,6 +29,7 @@ MA 02110-1301, USA.
|
||||
#import "ShipEntity.h"
|
||||
#import "Universe.h"
|
||||
#import "OOMacroOpenGL.h"
|
||||
#import "PlayerEntity.h"
|
||||
|
||||
#import "OOTexture.h"
|
||||
#import "OOGraphicsResetManager.h"
|
||||
@ -335,6 +336,23 @@ GLfloat pA[6] = { 0.01, 0.0, 2.0, 4.0, 6.0, 10.0 }; // phase adjustments
|
||||
|
||||
OOGL(glPopMatrix()); // restore absolute positioning
|
||||
OOGL(glPushMatrix()); // avoid stack underflow
|
||||
// GLTranslateOOVector(vector_flip([self cameraRelativePosition]));
|
||||
HPVector cam = [PLAYER viewpointPosition];
|
||||
for (unsigned n=0;n<34*3;n++)
|
||||
{
|
||||
switch (n%3)
|
||||
{
|
||||
case 0: // x coordinates
|
||||
_glVertices[n] = (GLfloat)(_vertices[n] - cam.x);
|
||||
break;
|
||||
case 1: // y coordinates
|
||||
_glVertices[n] = (GLfloat)(_vertices[n] - cam.y);
|
||||
break;
|
||||
case 2: // z coordinates
|
||||
_glVertices[n] = (GLfloat)(_vertices[n] - cam.z);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OOGL(glPushAttrib(GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT));
|
||||
|
||||
@ -349,7 +367,7 @@ GLfloat pA[6] = { 0.01, 0.0, 2.0, 4.0, 6.0, 10.0 }; // phase adjustments
|
||||
OOGL(glShadeModel(GL_SMOOTH));
|
||||
|
||||
OOGL(glEnableClientState(GL_COLOR_ARRAY));
|
||||
OOGL(glVertexPointer(3, GL_FLOAT, 0, _vertices));
|
||||
OOGL(glVertexPointer(3, GL_FLOAT, 0, _glVertices));
|
||||
OOGL(glColorPointer(4, GL_FLOAT, 0, _exhaustBaseColors));
|
||||
|
||||
double intpart, dphase = 1.0-modf((double)[UNIVERSE getTime]*2.5,&intpart);
|
||||
|
@ -65,12 +65,12 @@ static OOTexture *sShotTexture2 = nil;
|
||||
if (ship == srcEntity)
|
||||
{
|
||||
// main laser offset
|
||||
position = HPvector_add([ship position], vectorToHPVector(OOVectorMultiplyMatrix(offset, [ship drawRotationMatrix])));
|
||||
[self setPosition:HPvector_add([ship position], vectorToHPVector(OOVectorMultiplyMatrix(offset, [ship drawRotationMatrix])))];
|
||||
}
|
||||
else
|
||||
{
|
||||
// subentity laser
|
||||
position = [srcEntity absolutePositionForSubentityOffset:vectorToHPVector(middle)];
|
||||
[self setPosition:[srcEntity absolutePositionForSubentityOffset:vectorToHPVector(middle)]];
|
||||
}
|
||||
|
||||
Quaternion q = kIdentityQuaternion;
|
||||
|
@ -127,7 +127,8 @@ static OOTexture *sBlobTexture = nil;
|
||||
OOMatrix temp_matrix = OOMatrixLoadGLMatrix(GL_MODELVIEW_MATRIX);
|
||||
OOGL(glPopMatrix()); OOGL(glPushMatrix()); // restore zero!
|
||||
// HPVect: camera-relative
|
||||
GLTranslateOOVector(HPVectorToVector(abspos)); // move to absolute position
|
||||
HPVector relpos = HPvector_subtract(abspos,[PLAYER viewpointPosition]);
|
||||
GLTranslateOOVector(HPVectorToVector(relpos)); // move to camera-relative position
|
||||
|
||||
[self drawImmediate:immediate translucent:translucent];
|
||||
|
||||
|
@ -3817,6 +3817,7 @@ static const OOMatrix starboard_matrix =
|
||||
|
||||
- (BOOL) viewFrustumIntersectsSphereAt:(HPVector)position withRadius:(GLfloat)radius
|
||||
{
|
||||
return YES; // HPVect: temporarily, while rest of camera-relative is sorted out
|
||||
int p;
|
||||
for (p = 0; p < 6; p++)
|
||||
{
|
||||
@ -3915,7 +3916,7 @@ static const OOMatrix starboard_matrix =
|
||||
OOGL(GLMultOOMatrix([player rotationMatrix]));
|
||||
// translate the view
|
||||
// HPVect: camera-relative position
|
||||
OOGL(GLTranslateOOVector(vector_flip(position)));
|
||||
// OOGL(GLTranslateOOVector(vector_flip(position)));
|
||||
OOGL(glLightModelfv(GL_LIGHT_MODEL_AMBIENT, stars_ambient));
|
||||
}
|
||||
else
|
||||
@ -3971,7 +3972,7 @@ static const OOMatrix starboard_matrix =
|
||||
{
|
||||
//translate the object
|
||||
// HPVect: camera relative
|
||||
GLTranslateOOVector(HPVectorToVector([drawthing position]));
|
||||
GLTranslateOOVector([drawthing cameraRelativePosition]);
|
||||
//rotate the object
|
||||
GLMultOOMatrix([drawthing drawRotationMatrix]);
|
||||
}
|
||||
@ -4033,7 +4034,7 @@ static const OOMatrix starboard_matrix =
|
||||
{
|
||||
//translate the object
|
||||
// HPVect: camera relative positions
|
||||
GLTranslateOOVector(HPVectorToVector([drawthing position]));
|
||||
GLTranslateOOVector([drawthing cameraRelativePosition]);
|
||||
//rotate the object
|
||||
GLMultOOMatrix([drawthing drawRotationMatrix]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user