sjaakiejj
Member
|
RE: Questions regarding player class
Most of this code comes from the tutorial associated with extending the object class.
Interactive.cpp
Code:
#include "stdafx.h"
#include "Main.h"
void Interactive::create(Game::ObjParams &obj)
{
//Default Creation
position = obj.matrixFinal().pos;
mesh = obj.mesh();
//If I draw according to the scaleMatrix, rotation works. If I do it according to //the normal matrix, nothing works.
scaleMatrix = obj.matrixFinal();
//Now setup the parameters
if (Game::Param *parameter = obj.findParam("script"))
luaScript = parameter->asStr();
}
UInt Interactive::drawPrepare()
{
if(mesh && Frustum(mesh->box,matrix()))
mesh->draw(matrix());
return 0; // return 0 because no additional rendering modes are required
}
void Interactive::drawShadow()
{
if(mesh && Frustum(mesh->box,matrix()))
mesh->drawShadow(matrix());
}
void Interactive::drawOverlay()
{
__super::drawOverlay();
}
void Interactive::transform()
{
//do nothing
}
Interactive::Interactive()
{
luaScript = 0;
}
Interactive.h
Code:
STRUCT(Interactive, Game::Obj)
//{
Vec position;
MeshPtr mesh;
Str8 luaScript; //This will store the lua script
Matrix scaleMatrix;
Interactive(); //default constructor
virtual Vec pos( ) {return position ;} // get position
virtual void pos(C Vec &pos) { T.position=pos;} // set position
virtual Matrix matrix( ) {return position ;} // get matrix
virtual void matrix(C Matrix &matrix) { T.position=matrix.pos;} // set matrix
virtual Bool update(){ return true;};
virtual void create(Game::ObjParams &obj); //extend default create
virtual void drawOverlay();
virtual UInt drawPrepare();
virtual void drawShadow();
virtual void transform();
};
(This post was last modified: 08-29-2010 02:08 PM by sjaakiejj.)
|
|
08-29-2010 02:08 PM |
|
Esenthel
Administrator
|
RE: Questions regarding player class
UInt Interactive::drawPrepare()
{
if(mesh && Frustum(mesh->box,matrix()))
mesh->draw(matrix());
you use draw(matrix())
and you have:
virtual Matrix matrix( ) {return position ;} // get matrix
so you set normalized matrix at position
|
|
08-29-2010 03:17 PM |
|