• Create Account

### #ActualBelos

Posted 21 June 2012 - 07:30 AM

I used the following code to get the camera:

Matrix3D Camera
{
get
{
Vector3D cameraZAxis = -this.LookDirection;
cameraZAxis.Normalize();

Vector3D cameraXAxis = Vector3D.CrossProduct(this.UpDirection, cameraZAxis);
cameraXAxis.Normalize();

Vector3D cameraYAxis = Vector3D.CrossProduct(cameraZAxis, cameraXAxis);

Vector3D cameraPosition = (Vector3D)this.Position;
double offsetX = -Vector3D.DotProduct(cameraXAxis, cameraPosition);
double offsetY = -Vector3D.DotProduct(cameraYAxis, cameraPosition);
double offsetZ = -Vector3D.DotProduct(cameraZAxis, cameraPosition);

return new Matrix3D(new double[,]{{cameraXAxis.X, cameraYAxis.X, cameraZAxis.X, 0},
{cameraXAxis.Y, cameraYAxis.Y, cameraZAxis.Y, 0},
{cameraXAxis.Z, cameraYAxis.Z, cameraZAxis.Z, 0},
{offsetX, offsetY, offsetZ, 1}});
}
}



The default camera matrix is
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{-100,0,0,1}
after I multiply the three matrices(the third is the model matrix) by the point and the resulting W in the point is very huge like -13000 so I am very confused right now!!
the model matrix is
{0,0,0,100}
{0,0,0,100}
{0,0,0,100}
{0,0,0,1}
Can you tell me where I have gone wrong?
note: this is not xn

### #2Belos

Posted 21 June 2012 - 07:29 AM

I used the following code to get the camera:

[color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Matrix3D[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Camera[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]		[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]{[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]				[/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]get[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]				[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]{[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraZAxis [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]=[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]-[/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]this[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]LookDirection[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3];[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						cameraZAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Normalize[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]();[/[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]background[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]][/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraXAxis [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]=[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]CrossProduct[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]([/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]this[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]UpDirection[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraZAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]);[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						cameraXAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Normalize[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]();[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraYAxis [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]=[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]CrossProduct[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]([/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]cameraZAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraXAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]);[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraPosition [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]=[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]([/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3])[/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]this[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Position[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3];[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]double[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] offsetX [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]=[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]-[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]DotProduct[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]([/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]cameraXAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraPosition[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]);[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]double[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] offsetY [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]=[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]-[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]DotProduct[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]([/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]cameraYAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraPosition[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]);[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]double[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] offsetZ [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]=[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]-[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Vector3D[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]DotProduct[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]([/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]cameraZAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraPosition[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]);[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]						[/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]return[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]new[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#660066][font=tahoma, helvetica, arial, sans-serif][size=3]Matrix3D[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]([/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]new[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#000088][font=tahoma, helvetica, arial, sans-serif][size=3]double[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3][,]{{[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]cameraXAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]X[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraYAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]X[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraZAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]X[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#006666][font=tahoma, helvetica, arial, sans-serif][size=3]0[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]},[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]																[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]{[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]cameraXAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]Y[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraYAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]Y[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraZAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]Y[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#006666][font=tahoma, helvetica, arial, sans-serif][size=3]0[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]},[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]																[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]{[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]cameraXAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]Z[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraYAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]Z[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] cameraZAxis[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3].[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]Z[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#006666][font=tahoma, helvetica, arial, sans-serif][size=3]0[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]},[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]																[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]{[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]offsetX[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] offsetY[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] offsetZ[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3],[/size][/font][/color][color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3] [/size][/font][/color][color=#006666][font=tahoma, helvetica, arial, sans-serif][size=3]1[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]}});[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]				[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]}[/size][/font][/color]
[color=#000000][font=tahoma, helvetica, arial, sans-serif][size=3]		[/size][/font][/color][color=#666600][font=tahoma, helvetica, arial, sans-serif][size=3]}[/size][/font][/color]

The default camera matrix is
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{-100,0,0,1}
after I multiply the three matrices(the third is the model matrix) by the point and the resulting W in the point is very huge like -13000 so I am very confused right now!!
the model matrix is
{0,0,0,100}
{0,0,0,100}
{0,0,0,100}
{0,0,0,1}
Can you tell me where I have gone wrong?
note: this is not xn

### #1Belos

Posted 21 June 2012 - 07:28 AM

I used the following code to get the camera:

Matrix3D Camera
{
get
{
Vector3D cameraZAxis = -this.LookDirection;
cameraZAxis.Normalize();[/background]
Vector3D cameraXAxis = Vector3D.CrossProduct(this.UpDirection, cameraZAxis);
cameraXAxis.Normalize();
Vector3D cameraYAxis = Vector3D.CrossProduct(cameraZAxis, cameraXAxis);
Vector3D cameraPosition = (Vector3D)this.Position;
double offsetX = -Vector3D.DotProduct(cameraXAxis, cameraPosition);
double offsetY = -Vector3D.DotProduct(cameraYAxis, cameraPosition);
double offsetZ = -Vector3D.DotProduct(cameraZAxis, cameraPosition);
return new Matrix3D(new double[,]{{cameraXAxis.X, cameraYAxis.X, cameraZAxis.X, 0},
{cameraXAxis.Y, cameraYAxis.Y, cameraZAxis.Y, 0},
{cameraXAxis.Z, cameraYAxis.Z, cameraZAxis.Z, 0},
{offsetX, offsetY, offsetZ, 1}});
}
}

The default camera matrix is
{1,0,0,0},
{0,1,0,0},
{0,0,1,0},
{-100,0,0,1}
after I multiply the three matrices(the third is the model matrix) by the point and the resulting W in the point is very huge like -13000 so I am very confused right now!!
the model matrix is
{0,0,0,100}
{0,0,0,100}
{0,0,0,100}
{0,0,0,1}
Can you tell me where I have gone wrong?
note: this is not xn

PARTNERS