Rotating a shape..help
by Steven Graham · in Torque Game Engine · 11/03/2006 (11:54 am) · 0 replies
Hi everyone, I have a very unique situation. Let me explain...
I work for a flight simulator company and I am using the tourque engine to develop games. Currently I need to use the engine to create a real time animation of our flight sim unit. I have the 3d models of our unit but I need to get pitch and roll data into the engine to move the models. I am not sure if any of you are familiar with Microsoft Flight Simulator but with some 3 party software you can extract the pitch and roll data from the games. That is how we control our simulators. Well I need to take that data from the game and import it into tourque to move the 3d models.
I am using a TCP connection to bring the pitch and roll data in to the model. I created a new class called StaticMoveableShape.cc. I am using the processtick function to receive data on the buffer.
I can succesfully get the pitch and roll data but I dont know where to put it. I know it has something to do with the MatrixF class and setTransform function but I dont know exactly what to do. I know that I want to roate the shapes on the x and y axis but I dont understand which column in setColumn controls the rotation of an object.
Here is my processTick function tell me what I should do.
I work for a flight simulator company and I am using the tourque engine to develop games. Currently I need to use the engine to create a real time animation of our flight sim unit. I have the 3d models of our unit but I need to get pitch and roll data into the engine to move the models. I am not sure if any of you are familiar with Microsoft Flight Simulator but with some 3 party software you can extract the pitch and roll data from the games. That is how we control our simulators. Well I need to take that data from the game and import it into tourque to move the 3d models.
I am using a TCP connection to bring the pitch and roll data in to the model. I created a new class called StaticMoveableShape.cc. I am using the processtick function to receive data on the buffer.
I can succesfully get the pitch and roll data but I dont know where to put it. I know it has something to do with the MatrixF class and setTransform function but I dont know exactly what to do. I know that I want to roate the shapes on the x and y axis but I dont understand which column in setColumn controls the rotation of an object.
Here is my processTick function tell me what I should do.
void StaticMoveableShape::processTick(const Move *move)
{
int error = 0;
float pitch = 0.0, roll = 0.0;
if(!isConnected)
{
if(!isListening)
{
if(SetupConnection()) //creates a TCP socket for listening
isListening = true;
}
if(isListening)
{
//accepts incoming connections
accept_socket = accept( listen_socket, NULL, NULL );
if(accept_socket != SOCKET_ERROR)
{
listen_socket = accept_socket;
isConnected = true;
}
else
{
error=WSAGetLastError();
}
}
}
if(isConnected)
{
recv_socket = listen_socket;
retval =recv(recv_socket,recBuff,35,0); //receives pitch & roll data
if(retval ==SOCKET_ERROR)
{
if(WSAGetLastError() != WSAEWOULDBLOCK)
{
closesocket(recv_socket);
}
}
else
{
// need help here!!!!! I dont where this data should go
MatrixF matrix;
Point3F rot;
memcpy(&pitch,&recBuff[0],4);
memcpy(&roll,&recBuff[4],4);
rot.y = mDegToRad(pitch);
rot.x = mDegToRad(roll);
matrix.setColumn(0,rot);
Parent::setTransform(matrix);
}
}
}