Jump to content

  • Log In with Google      Sign In   
  • Create Account

NatalieBerry88

Member Since 25 Nov 2011
Offline Last Active Dec 02 2011 02:28 PM

Topics I've Started

3d Open GL Game - How to fix a object to the camera =)

25 November 2011 - 08:40 PM

Hi guys!Posted Image I have successfully created a Player class which shows a player ( lovely cow! Posted Image ). However, I wanted to make the player be static in the screen, since I wanted to create a racing-supermario like game. Basically what I have now is a camera that goes around but I want to stick it to the player mesh.

Here is some code:

Camera look() function code

void CCamera::Look(){
    // Give openGL our camera position, then camera view, then camera up vector
    gluLookAt(m_vPosition.x, m_vPosition.y, m_vPosition.z,    
 	         m_vView.x, 	m_vView.y, 	m_vView.z,    
 	         m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);

}



Player.h
#ifndef _PLAYER_H#define _PLAYER_H


#include "Model_3DS.h"


// This class was made to handle models created for player use.


class Player
{


    Model_3DS playerModel;




public:




    
    void LoadPlayer();  //Method to load player mesh
    void DrawPlayer();  //Method to draw player mesh
   


        Player();                                    // Constructor
    virtual ~Player();
    
};



 #endif


Player.cpp
#include "Player.h"

Player::Player()
{
 	playerModel.scale = 3.0f;//Scale the model up
 	playerModel.pos.x = 250.0f;//Set the x position
 	playerModel.pos.y = 15;//Set the y position
 	playerModel.pos.z = 400.0f;//Set the z position
}


Player::~Player()
{


}






void Player::LoadPlayer(){
    playerModel.Load("Data/3DS/SecondaryObjects/cow2.3ds"); // Load a 3ds model
}


void Player::DrawPlayer(){


    playerModel.Draw();//Draw tree model
    



};

I was thinking that I should call the position of the camera in the player position, but I am not so sure how
Posted Image

If somebody could give me a hand would be great!
Also, if you want to add me on skype so its quicker would be good too ^^:
natalieberrystraw is my skype.

Thanks in advance! <3


Natalie xxx

3d Open GL Game - How to fix a object to the camera =)

25 November 2011 - 08:26 PM

Hi guys!Posted Image I have successfully created a Player class which shows a player ( lovely cow! Posted Image ). However, I wanted to make the player be static in the screen, since I wanted to create a racing-supermario like game. Basically what I have now is a camera that goes around but I want to stick it to the player mesh.

Here is some code:

Camera look() function code
void CCamera::Look(){
    // Give openGL our camera position, then camera view, then camera up vector
    gluLookAt(m_vPosition.x, m_vPosition.y, m_vPosition.z,    
     	     m_vView.x, 	m_vView.y, 	m_vView.z,    
     	     m_vUpVector.x, m_vUpVector.y, m_vUpVector.z);

}



Player.h
#ifndef _PLAYER_H#define _PLAYER_H


#include "Model_3DS.h"


// This class was made to handle models created for player use.


class Player
{


    Model_3DS playerModel;




public:




    
    void LoadPlayer();  //Method to load player mesh
    void DrawPlayer();  //Method to draw player mesh
   


        Player();                                    // Constructor
    virtual ~Player();
    
};



 #endif


Player.cpp
#include "Player.h"

Player::Player()
{
 	playerModel.scale = 3.0f;//Scale the model up
 	playerModel.pos.x = 250.0f;//Set the x position
 	playerModel.pos.y = 15;//Set the y position
 	playerModel.pos.z = 400.0f;//Set the z position
}


Player::~Player()
{


}






void Player::LoadPlayer(){
    playerModel.Load("Data/3DS/SecondaryObjects/cow2.3ds"); // Load a 3ds model
}


void Player::DrawPlayer(){


    playerModel.Draw();//Draw tree model
    



};


I was thinking that I should call the position of the camera in the player position, but I am not so sure how
Posted Image

If somebody could give me a hand would be great!
Also, if you want to add me on skype so its quicker would be good too ^^:
natalieberrystraw is my skype.

Thanks in advance! <3


Natalie xxx

PARTNERS