Home Products Download Order Contacts

comp.graphics.algorithms

Subject: 3D camera question




Really stuck here, and could use some help. I'm trying to add a camera to my
3D engine. Say I just have one shape - a large triangle that's acting as the
ground plane.

The triangle is not transformed, as you can see the arguments to the
rotation and translation are 0. For reference, I have one of the matrix
methods below, it sets it up and then multiplies. If I change the values of
my camera rotation, the triangle still rotates as if I were simply rotating
it (from its center) and not the camera. I know I need to subtract the
location of the camera relative to the shape, but Im not sure how/where to
do this. Can anyone help? Please let me know if you need more information.

TIA

---------------------

camTransX = 0.0;
camTransY = -50.0;
camTransZ = 500.0;

groundMatrix.setIdentity();
groundMatrix.rotateX(0);
groundMatrix.rotateY(0);
groundMatrix.rotateZ(0);
groundMatrix.translate(0, 0, 0);

groundMatrix.rotateX(camRotX);
groundMatrix.rotateY(camRotY);
groundMatrix.rotateZ(camRotZ);
groundMatrix.translate(camTransX, camTransY, camTransZ);
ground.draw(groundMatrix);





-------------------

public function rotateY(angleY:Number):Void {

if (angleY == 0) {
return;
}

var cosAngle:Number = Math.cos(angleY);
var sinAngle:Number = Math.sin(angleY);

temp[0][0] = cosAngle;
temp[0][1] = 0;
temp[0][2] = -sinAngle;
temp[0][3] = 0;

temp[1][0] = 0;
temp[1][1] = 1;
temp[1][2] = 0;
temp[1][3] = 0;

temp[2][0] = sinAngle;
temp[2][1] = 0;
temp[2][2] = cosAngle;
temp[2][3] = 0;

temp[3][0] = 0;
temp[3][1] = 0;
temp[3][2] = 0;
temp[3][3] = 1;

multiply();
}



Reply


View All Messages in comp.graphics.algorithms

path:


Replies:
Re: 3D camera question

Copyright 2006 WatermarkFactory.com. All Rights Reserved.