1. Check material names passed to the physics engine (for collision sensors.)

Consider:
gameobj->getClientInfo()->m_auxilary_info = (matname ? (void*)(matname+2) : NULL);
It works if matname is "MAblah", but not if matname is "".

2. Added constructor for struct RAS_CameraData.
3. Added initializers to the struct KX_ClientObjectInfo constructor
4. Collision sensors won't detect near sensors.
5. A stack of minor tweaks, adjusting whitespace, using ++it for stl stuff.
This commit is contained in:
Kester Maddock
2004-04-11 02:50:02 +00:00
parent d3e88eae71
commit ae9233a5b0
25 changed files with 170 additions and 333 deletions

View File

@@ -820,13 +820,9 @@ static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX
}
static KX_Camera *gamecamera_from_bcamera(Camera *ca, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) {
RAS_CameraData camdata;
RAS_CameraData camdata(ca->lens, ca->clipsta, ca->clipend, ca->type == CAM_PERSP);
KX_Camera *gamecamera;
camdata.m_lens= ca->lens;
camdata.m_clipend= ca->clipend;
camdata.m_clipstart= ca->clipsta;
gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata);
gamecamera->SetName(ca->id.name + 2);

View File

@@ -37,6 +37,7 @@ SOURCEDIR = source/gameengine/GamePlayer
DIR = $(OCGDIR)/gameengine/GamePlayer
DIRS = common ghost
ifneq ($(NAN_NO_PLUGIN),true)
ifeq ($(OS),$(findstring $(OS), "freebsd irix windows"))
ifneq ($(FREE_WINDOWS),true)
DIRS += netscape
@@ -54,5 +55,6 @@ ifeq ($(OS),$(findstring $(OS), "solaris"))
DIRS += netscape
endif
endif
endif
include nan_subdirs.mk

View File

@@ -118,7 +118,7 @@ int my_set_tpage(TFace *tface)
unsigned int *rect, *bind;
int tpx, tpy, tilemode, tileXRep,tileYRep;
/* afschakelen */
/* disable */
if(tface==0) {
if(lasttface==0) return 0;

View File

@@ -144,10 +144,10 @@ bool GPG_Application::startWindow(STR_String& title,
//STR_String title ("Blender Player - GHOST");
m_mainWindow = fSystem->createWindow(title, windowLeft, windowTop, windowWidth, windowHeight, GHOST_kWindowStateNormal,
GHOST_kDrawingContextTypeOpenGL, stereoVisual);
if (!m_mainWindow) {
if (!m_mainWindow) {
printf("error: could not create main window\n");
exit(-1);
}
exit(-1);
}
/* Check the size of the client rectangle of the window and resize the window
* so that the client rectangle has the size requested.
@@ -396,14 +396,14 @@ bool GPG_Application::startEngine(void)
}
// Temporary hack to disable banner display for NaN approved content.
/*
m_canvas->SetBannerDisplayEnabled(true);
Camera* cam;
/* Camera* cam;
cam = (Camera*)G.scene->camera->data;
if (cam) {
if (((cam->flag) & 48)==48) {
m_canvas->SetBannerDisplayEnabled(false);
}
if (((cam->flag) & 48)==48) {
m_canvas->SetBannerDisplayEnabled(false);
}
}
else {
showError(CString("Camera data invalid."));

View File

@@ -104,8 +104,8 @@ void usage(char* program)
consoleoption = "";
#endif
printf("usage: %s -w [-p l t w h] %s[-g gamengineoptions] "
"-s stereomode filename.blend\n", program, consoleoption);
printf("usage: %s [-w [-p l t w h]] %s[-g gamengineoptions] "
"[-s stereomode] filename.blend\n", program, consoleoption);
printf(" -w: display in a window\n");
printf(" -p: specify window position\n");
printf(" l = window left coordinate\n");

View File

@@ -37,7 +37,7 @@
*/
struct KX_ClientObjectInfo
{
enum {
enum clienttype {
STATIC,
ACTOR,
RESERVED1,
@@ -47,9 +47,13 @@ struct KX_ClientObjectInfo
void* m_clientobject;
void* m_auxilary_info;
public:
KX_ClientObjectInfo(void *clientobject) :
m_clientobject(clientobject)
KX_ClientObjectInfo(void *clientobject, clienttype type = STATIC, void *auxilary_info = NULL) :
m_type(type),
m_clientobject(clientobject),
m_auxilary_info(auxilary_info)
{}
bool isActor() { return m_type <= ACTOR; }
};
#endif //__KX_CLIENTOBJECT_INFO_H

View File

@@ -80,7 +80,7 @@
GEN_Map<GEN_HashedPtr,DT_ShapeHandle> map_gamemesh_to_sumoshape;
// forward declarations
void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_SceneHandle solidscene,class SM_Object* sumoObj,const char* matname,bool isDynamic,bool isActor);
void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_SceneHandle solidscene,class SM_Object* sumoObj,const STR_String& matname,bool isDynamic,bool isActor);
DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj);
@@ -158,7 +158,7 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj,
sumoObj->setRigidBody(objprop->m_angular_rigidbody?true:false);
objprop->m_isactor = objprop->m_dyna = true;
BL_RegisterSumoObject(gameobj,sceneptr,sumoEnv->GetSolidScene(),sumoObj,NULL,true, true);
BL_RegisterSumoObject(gameobj,sceneptr,sumoEnv->GetSolidScene(),sumoObj,"",true, true);
}
else {
@@ -229,7 +229,7 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj,
BL_RegisterSumoObject(gameobj,sceneptr,
sumoEnv->GetSolidScene(),sumoObj,
matname.ReadPtr(),
matname,
objprop->m_dyna,
objprop->m_isactor);
}
@@ -251,7 +251,15 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj,
void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_SceneHandle solidscene,class SM_Object* sumoObj,const char* matname,bool isDynamic,bool isActor) {
void BL_RegisterSumoObject(
KX_GameObject* gameobj,
class SM_Scene* sumoScene,
DT_SceneHandle solidscene,
class SM_Object* sumoObj,
const STR_String& matname,
bool isDynamic,
bool isActor)
{
@@ -274,7 +282,7 @@ void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,DT_S
//gameobj->GetClientInfo()->m_clientobject = gameobj;
// store materialname in auxinfo, needed for touchsensors
gameobj->getClientInfo()->m_auxilary_info = (matname? (void*)(matname+2) : NULL);
gameobj->getClientInfo()->m_auxilary_info = (matname.Length() ? (void*)(matname.ReadPtr()+2) : NULL);
physicscontroller->SetObject(gameobj->GetSGNode());

View File

@@ -73,8 +73,7 @@ KX_GameObject::KX_GameObject(
m_pPhysicsController1(NULL)
{
m_ignore_activity_culling = false;
m_pClient_info = new KX_ClientObjectInfo(this);
m_pClient_info->m_type = KX_ClientObjectInfo::ACTOR;
m_pClient_info = new KX_ClientObjectInfo(this, KX_ClientObjectInfo::ACTOR);
m_pSGNode = new SG_Node(this,sgReplicationInfo,callbacks);
// define the relationship between this node and it's parent.

View File

@@ -63,25 +63,25 @@ class KX_GameObject : public SCA_IObject
{
Py_Header;
bool m_bDyna;
KX_ClientObjectInfo* m_pClient_info;
STR_String m_name;
STR_String m_text;
bool m_bDyna;
KX_ClientObjectInfo* m_pClient_info;
STR_String m_name;
STR_String m_text;
std::vector<RAS_MeshObject*> m_meshes;
bool m_bSuspendDynamics;
bool m_bUseObjectColor;
MT_Vector4 m_objectColor;
bool m_bSuspendDynamics;
bool m_bUseObjectColor;
MT_Vector4 m_objectColor;
// Is this object set to be visible? Only useful for the
// visibility subsystem right now.
bool m_bVisible;
bool m_bVisible;
KX_IPhysicsController* m_pPhysicsController1;
SG_Node* m_pSGNode;
KX_IPhysicsController* m_pPhysicsController1;
SG_Node* m_pSGNode;
protected:
MT_CmMatrix4x4 m_OpenGL_4x4Matrix;
MT_CmMatrix4x4 m_OpenGL_4x4Matrix;
public:
virtual void /* This function should be virtual - derived classed override it */

View File

@@ -62,8 +62,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
m_ResetMargin(resetmargin)
{
m_client_info = new KX_ClientObjectInfo(gameobj);
m_client_info->m_type = KX_ClientObjectInfo::NEAR;
m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::NEAR);
DT_ShapeHandle shape = (DT_ShapeHandle) vshape;
m_sumoObj = new SM_Object(shape,NULL,NULL,NULL);
@@ -91,9 +90,7 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
m_ResetMargin(resetmargin)
{
m_client_info = new KX_ClientObjectInfo(gameobj);
m_client_info->m_type = KX_ClientObjectInfo::NEAR;
m_client_info->m_auxilary_info = NULL;
m_client_info = new KX_ClientObjectInfo(gameobj, KX_ClientObjectInfo::NEAR);
m_sumoObj = new SM_Object(DT_NewSphere(0.0),NULL,NULL,NULL);
m_sumoObj->setMargin(m_Margin);
@@ -118,9 +115,7 @@ CValue* KX_NearSensor::GetReplica()
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_clientobject);
replica->m_client_info->m_type = KX_ClientObjectInfo::NEAR;
replica->m_client_info->m_auxilary_info = NULL;
replica->m_client_info = new KX_ClientObjectInfo(m_client_info->m_clientobject, KX_ClientObjectInfo::NEAR);
replica->m_sumoObj = new SM_Object(DT_NewSphere(0.0),NULL,NULL,NULL);
replica->m_sumoObj->setMargin(m_Margin);

View File

@@ -119,6 +119,19 @@ KX_TouchSensor::~KX_TouchSensor()
m_colliders->Release();
}
CValue* KX_TouchSensor::GetReplica()
{
KX_TouchSensor* replica = new KX_TouchSensor(*this);
replica->m_colliders = new CListValue();
replica->m_bCollision = false;
replica->m_bTriggered= false;
replica->m_hitObject = NULL;
replica->m_bLastTriggered = false;
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
return replica;
}
void KX_TouchSensor::ReParent(SCA_IObject* parent)
{
KX_GameObject *gameobj = static_cast<KX_GameObject *>(parent);
@@ -159,7 +172,7 @@ DT_Bool KX_TouchSensor::HandleCollision(void* obj1,void* obj2,const DT_CollDa
(KX_GameObject*)client_info->m_clientobject :
NULL);
if (gameobj && (gameobj != parent))
if (gameobj && (gameobj != parent) && client_info->isActor())
{
if (!m_colliders->SearchValue(gameobj))
m_colliders->Add(gameobj->AddRef());
@@ -171,14 +184,8 @@ DT_Bool KX_TouchSensor::HandleCollision(void* obj1,void* obj2,const DT_CollDa
{
if (client_info->m_auxilary_info)
{
found = (m_touchedpropname == ((char*)client_info->m_auxilary_info));
found = (m_touchedpropname == STR_String((char*)client_info->m_auxilary_info));
}
if (found)
{
int i=0;
}
} else
{
found = (gameobj->GetProperty(m_touchedpropname) != NULL);

View File

@@ -77,17 +77,7 @@ public:
PyTypeObject* T=&Type) ;
virtual ~KX_TouchSensor();
virtual CValue* GetReplica() {
KX_TouchSensor* replica = new KX_TouchSensor(*this);
replica->m_colliders = new CListValue();
replica->m_bCollision = false;
replica->m_bTriggered= false;
replica->m_hitObject = NULL;
replica->m_bLastTriggered = false;
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
return replica;
};
virtual CValue* GetReplica();
virtual void SynchronizeTransform();
virtual bool Evaluate(CValue* event);
virtual void ReParent(SCA_IObject* parent);

View File

@@ -92,7 +92,7 @@ vector<NG_NetworkMessage*> NG_LoopBackNetworkDeviceInterface::RetrieveNetworkMes
vector<NG_NetworkMessage*> messages;
std::deque<NG_NetworkMessage*>::iterator mesit=m_messages[m_currentQueue].begin();
for (; !(mesit == m_messages[m_currentQueue].end());mesit++)
for (; !(mesit == m_messages[m_currentQueue].end()); ++mesit)
{
// We don't increase the reference count for these messages. We

View File

@@ -374,6 +374,8 @@ DT_Bool SM_Object::boing(
if (obj2->isDynamic())
obj2->dynamicCollision(local2, -normal, dist, -rel_vel, restitution, friction_factor, invMass);
//fix(client_data, (void*) obj1, (void*) obj2, coll_data);
return DT_CONTINUE;
}
@@ -411,6 +413,9 @@ DT_Bool SM_Object::fix(
MT_Point3 local1(p1), local2(p2);
// Get collision data from SOLID
MT_Vector3 normal(local2 - local1);
if (normal.dot(normal) < MT_EPSILON)
return DT_CONTINUE;
// This distinction between dynamic and non-dynamic objects should not be
// necessary. Non-dynamic objects are assumed to have infinite mass.
@@ -439,7 +444,7 @@ DT_Bool SM_Object::fix(
MT_Scalar rel_vel_normal = -0.99*(normal.dot(rel_vel));
obj2->addLinearVelocity(rel_vel_normal*normal);
}
}
}
return DT_CONTINUE;
@@ -461,9 +466,34 @@ void SM_Object::relax(void)
notifyClient();
}
SM_Object::SM_Object(
) {
SM_Object::SM_Object() :
m_dynamicParent(0),
m_client_object(0),
m_shape(0),
m_materialProps(0),
m_materialPropsBackup(0),
m_shapeProps(0),
m_shapePropsBackup(0),
m_object(0),
m_margin(0.0),
m_scaling(1.0, 1.0, 1.0),
m_reaction_impulse(0.0, 0.0, 0.0),
m_reaction_force(0.0, 0.0, 0.0),
m_kinematic(false),
m_prev_kinematic(false),
m_is_rigid_body(false),
m_lin_mom(0.0, 0.0, 0.0),
m_ang_mom(0.0, 0.0, 0.0),
m_force(0.0, 0.0, 0.0),
m_torque(0.0, 0.0, 0.0),
m_error(0.0, 0.0, 0.0),
m_combined_lin_vel (0.0, 0.0, 0.0),
m_combined_ang_vel (0.0, 0.0, 0.0),
m_fh_object(0)
{
// warning no initialization of variables done by moto.
std::cout << "SM_Object::SM_Object()" << std::endl;
}
SM_Object::

View File

@@ -162,8 +162,8 @@ void SM_Scene::remove(SM_Object& object) {
void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
// Don't waste time...but it's OK to spill a little.
if (timeStep < 0.001)
return;
//if (timeStep < 0.001)
// return;
// Divide the timeStep into a number of subsamples of size roughly
// equal to subSampling (might be a little smaller).
@@ -208,14 +208,16 @@ void SM_Scene::proceed(MT_Scalar timeStep, MT_Scalar subSampling) {
#if 0
clearObjectCombinedVelocities();
#endif
if (DT_Test(m_scene, m_fixRespTable))
/* if (DT_Test(m_scene, m_fixRespTable))
for (i = m_objectList.begin(); i != m_objectList.end(); ++i)
(*i)->relax();
(*i)->relax(); */
DT_Test(m_scene, m_fixRespTable);
// Finish this timestep by saving al state information for the next
// timestep and clearing the accumulated forces.
for (i = m_objectList.begin(); i != m_objectList.end(); ++i) {
(*i)->relax();
(*i)->proceedKinematic(timeStep);
(*i)->saveReactionForce(timeStep);
(*i)->clearForce();

View File

@@ -71,6 +71,7 @@ SumoPhysicsController::~SumoPhysicsController()
m_sumoScene->remove(*m_sumoObj);
delete m_sumoObj;
m_sumoObj = NULL;
}
}

View File

@@ -56,6 +56,7 @@ SumoPhysicsEnvironment::SumoPhysicsEnvironment()
SumoPhysicsEnvironment::~SumoPhysicsEnvironment()
{
std::cout << "delete m_sumoScene " << m_sumoScene << std::endl;
delete m_sumoScene;
DT_DestroyScene(m_solidScene);
//DT_DestroyRespTable(m_respTable);

View File

@@ -1,196 +0,0 @@
#ifndef SOLID_H
#define SOLID_H
#include "solid_types.h"
#ifdef __cplusplus
extern "C" {
#endif
DT_DECLARE_HANDLE(DT_ObjectHandle);
DT_DECLARE_HANDLE(DT_SceneHandle);
DT_DECLARE_HANDLE(DT_ShapeHandle);
DT_DECLARE_HANDLE(DT_RespTableHandle);
typedef enum DT_ScalarType {
DT_FLOAT,
DT_DOUBLE
} DT_ScalarType;
typedef enum DT_ResponseType {
DT_NO_RESPONSE,
DT_SIMPLE_RESPONSE,
DT_WITNESSED_RESPONSE,
DT_DEPTH_RESPONSE,
} DT_ResponseType;
typedef struct DT_CollData {
DT_Vector3 point1;
DT_Vector3 point2;
DT_Vector3 normal;
} DT_CollData;
typedef void (*DT_ResponseCallback)(
void *client_data,
void *client_object1,
void *client_object2,
const DT_CollData *coll_data);
/* Shape definition, similar to OpenGL */
extern DT_ShapeHandle DT_Box(DT_Scalar x, DT_Scalar y, DT_Scalar z);
extern DT_ShapeHandle DT_Cone(DT_Scalar radius, DT_Scalar height);
extern DT_ShapeHandle DT_Cylinder(DT_Scalar radius, DT_Scalar height);
extern DT_ShapeHandle DT_Sphere(DT_Scalar radius);
extern DT_ShapeHandle DT_Ray(DT_Scalar x, DT_Scalar y, DT_Scalar z);
extern DT_ShapeHandle DT_NewComplexShape();
extern void DT_EndComplexShape();
extern DT_ShapeHandle DT_NewPolyhedron();
extern void DT_EndPolyhedron();
extern void DT_Begin();
extern void DT_End();
extern void DT_Vertex(DT_Scalar x, DT_Scalar y, DT_Scalar z);
/* Vertex arrays maintained by the client application can be accessed directly
by SUMO. For instance, you have a vertex struct in the client of the form:
struct Vertex {
float xyz[3];
float uv[2];
float normal[3];
};
And maintain vertex arrays e.g. as
struct Vertex vertices[328];
Within a Polyhedron or a ComplexShape you can use this data by specifying
DT_VertexBase(vertices, DT_FLOAT, sizeof(struct Vertex));
and refer to vertices in the array using
DT_VertexIndex(10);
or
DT_Index indices[5] = { 6, 4, 8, 1, 3 };
DT_VertexIndices(5, indices);
or even
DT_VertexRange(8, 4);
for the range 8, 9, 10, 11.
*/
extern void DT_SetVertexBase(const void *base, DT_ScalarType type,
DT_Size stride);
extern void DT_VertexIndex(DT_Index index);
extern void DT_VertexIndices(DT_Count count, const DT_Index *indices);
extern void DT_VertexRange(DT_Index first, DT_Count count);
/* currently not implemented */
extern void DT_ChangeVertexBase(DT_ShapeHandle shape, const void *base);
extern void DT_DeleteShape(DT_ShapeHandle shape);
/* Scene */
extern DT_SceneHandle DT_CreateScene();
extern void DT_DeleteScene(DT_SceneHandle scene);
extern void DT_AddObject(DT_SceneHandle scene, DT_ObjectHandle object);
extern void DT_RemoveObject(DT_SceneHandle scene, DT_ObjectHandle object);
/* Object */
extern DT_ObjectHandle DT_CreateObject(
void *client_object, /* pointer to object in client memory */
DT_ShapeHandle shape /* the shape or geometry of the object */
);
extern void DT_DeleteObject(DT_ObjectHandle object);
extern void DT_SetScaling(DT_ObjectHandle object, const DT_Vector3 scaling);
extern void DT_SetPosition(DT_ObjectHandle object, const DT_Vector3 position);
extern void DT_SetOrientation(DT_ObjectHandle object, const DT_Quaternion orientation);
extern void DT_SetMargin(DT_ObjectHandle object, DT_Scalar margin);
extern void DT_SetMatrixf(DT_ObjectHandle object, const float *m);
extern void DT_GetMatrixf(DT_ObjectHandle object, float *m);
extern void DT_SetMatrixd(DT_ObjectHandle object, const double *m);
extern void DT_GetMatrixd(DT_ObjectHandle object, double *m);
extern void DT_GetWorldCoord(DT_ObjectHandle object,
const DT_Vector3 local,
DT_Vector3 world);
extern DT_Scalar DT_GetClosestPair(DT_ObjectHandle object1, DT_ObjectHandle object2,
DT_Vector3 point1, DT_Vector3 point2);
/* Response, see SOLID user manual */
extern DT_RespTableHandle DT_CreateRespTable();
extern void DT_DeleteRespTable(DT_RespTableHandle respTable);
extern void DT_CallResponse(DT_RespTableHandle respTable,
DT_ObjectHandle object1,
DT_ObjectHandle object2,
const DT_CollData *coll_data);
extern void DT_SetDefaultResponse(DT_RespTableHandle respTable,
DT_ResponseCallback response,
DT_ResponseType type,
void *client_data);
extern void DT_ClearDefaultResponse(DT_RespTableHandle respTable);
extern void DT_SetObjectResponse(DT_RespTableHandle respTable,
DT_ObjectHandle object,
DT_ResponseCallback response,
DT_ResponseType type, void *client_data);
extern void DT_ClearObjectResponse(DT_RespTableHandle respTable,
DT_ObjectHandle object);
extern void DT_SetPairResponse(DT_RespTableHandle respTable,
DT_ObjectHandle object1,
DT_ObjectHandle object2,
DT_ResponseCallback response,
DT_ResponseType type,
void *client_data);
extern void DT_ClearPairResponse(DT_RespTableHandle respTable,
DT_ObjectHandle object1,
DT_ObjectHandle object2);
/* Perform a collision test for a given scene, using a response table */
extern DT_Count DT_Test(DT_SceneHandle scene, DT_RespTableHandle respTable);
extern void *DT_RayTest(DT_SceneHandle scene, void *ignore_client,
const DT_Vector3 from, const DT_Vector3 to,
DT_Vector3 spot, DT_Vector3 normal);
extern int DT_ObjectRayTest(DT_ObjectHandle object,
const DT_Vector3 from, const DT_Vector3 to,
DT_Vector3 spot, DT_Vector3 normal);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,39 +0,0 @@
#ifndef SOLID_BROADPHASE_H
#define SOLID_BROADPHASE_H
#include "solid_types.h"
#ifdef __cplusplus
extern "C" {
#endif
DT_DECLARE_HANDLE(BP_SceneHandle);
DT_DECLARE_HANDLE(BP_ProxyHandle);
typedef void (*BP_Callback)(void *client_data,
void *object1,
void *object2);
extern BP_SceneHandle BP_CreateScene(void *client_data,
BP_Callback beginOverlap,
BP_Callback endOverlap);
extern void BP_DeleteScene(BP_SceneHandle scene);
extern BP_ProxyHandle BP_CreateProxy(BP_SceneHandle scene, void *object,
const DT_Vector3 lower,
const DT_Vector3 upper);
extern void BP_DeleteProxy(BP_SceneHandle scene,
BP_ProxyHandle proxy);
extern void BP_SetBBox(BP_ProxyHandle proxy,
const DT_Vector3 lower,
const DT_Vector3 upper);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,15 +0,0 @@
#ifndef SOLID_TYPES_H
#define SOLID_TYPES_H
#define DT_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
typedef double DT_Scalar;
typedef unsigned int DT_Count;
typedef unsigned int DT_Index;
typedef unsigned int DT_Size;
typedef DT_Scalar DT_Vector3[3];
typedef DT_Scalar DT_Quaternion[4];
#endif

View File

@@ -37,6 +37,15 @@ struct RAS_CameraData
float m_lens;
float m_clipstart;
float m_clipend;
bool m_perspective;
RAS_CameraData(float lens = 35., float clipstart = 0.1, float clipend = 100., bool perspective = true) :
m_lens(lens),
m_clipstart(clipstart),
m_clipend(clipend),
m_perspective(perspective)
{
}
};
#endif //__RAS_CAMERADATA_H

View File

@@ -94,8 +94,12 @@ public:
virtual void ClearDepthBuffer()=0;
virtual void ClearCachingInfo(void)=0;
virtual void EndFrame()=0;
/**
* SetRenderArea sets the render area in the 2d canvas
*/
virtual void SetRenderArea()=0;
// Stereo Functions
virtual void SetStereoMode(const int stereomode)=0;
virtual bool Stereo()=0;
virtual void SetEye(const int eye)=0;
@@ -103,6 +107,20 @@ public:
virtual void SetFocalLength(const float focallength)=0;
virtual void SwapBuffers()=0;
// Drawing Functions
/**
* IndexPrimitives: Renders primitives.
* @param vertexarrays is an array of vertex arrays
* @param indexarrays is an array of index arrays
* @param mode determines the type of primitive stored in the vertex/index arrays:
* 0 triangles
* 1 lines (default)
* 2 quads
* @param polymat (reserved)
* @param useObjectColor will render the object using @param rgbacolor instead of
* vertex colours.
*/
virtual void IndexPrimitives( const vecVertexArray& vertexarrays,
const vecIndexArrays & indexarrays,
int mode,
@@ -110,6 +128,10 @@ public:
class RAS_IRenderTools* rendertools,
bool useObjectColor,
const MT_Vector4& rgbacolor)=0;
/**
* IndexPrimitivesEx: See IndexPrimitives.
* IndexPrimitivesEx will renormalize faces if @param vertexarrays[i].getFlag() & TV_CALCFACENORMAL
*/
virtual void IndexPrimitives_Ex( const vecVertexArray& vertexarrays,
const vecIndexArrays & indexarrays,
int mode,
@@ -117,6 +139,10 @@ public:
class RAS_IRenderTools* rendertools,
bool useObjectColor,
const MT_Vector4& rgbacolor)=0;
/**
* IndexPrimitives_3DText will render text into the polygons.
* The text to be rendered is from @param rendertools client object's text property.
*/
virtual void IndexPrimitives_3DText( const vecVertexArray& vertexarrays,
const vecIndexArrays & indexarrays,
int mode,
@@ -161,12 +187,18 @@ public:
float blue,
float alpha)=0;
/**
* @param drawingmode = KX_BOUNDINGBOX, KX_WIREFRAME, KX_SOLID, KX_SHADED or KX_TEXTURED.
*/
virtual void SetDrawingMode(int drawingmode)=0;
virtual int GetDrawingMode()=0;
virtual void EnableTextures(bool enable)=0;
virtual void SetCullFace(bool enable)=0;
/**
* Sets wireframe mode.
*/
virtual void SetLines(bool enable)=0;
virtual double GetTime()=0;
@@ -177,7 +209,8 @@ public:
float bottom,
float top,
float frustnear,
float frustfar
float frustfar,
bool perspective = true
)=0;
virtual void SetSpecularity(float specX,

View File

@@ -68,7 +68,7 @@ RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer()
void Myinit_gl_stuff(void)
static void Myinit_gl_stuff(void)
{
float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 };
float mat_shininess[] = { 35.0 };
@@ -259,7 +259,7 @@ void RAS_OpenGLRasterizer::Exit()
glClearDepth(1.0);
glClearColor(m_redback, m_greenback, m_blueback, m_alphaback);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glDepthMask (GL_TRUE);
glDepthMask (GL_TRUE);
glDepthFunc(GL_LEQUAL);
glBlendFunc(GL_ONE, GL_ZERO);
@@ -292,7 +292,7 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time)
glShadeModel(GL_SMOOTH);
m_2DCanvas->BeginFrame();
m_2DCanvas->BeginFrame();
return true;
}
@@ -1083,7 +1083,8 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
float bottom,
float top,
float frustnear,
float frustfar
float frustfar,
bool perspective
){
MT_Matrix4x4 result;
double mat[16];
@@ -1110,10 +1111,11 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
}
// leave bottom, top, bottom and top untouched
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(left, right, bottom, top, frustnear, frustfar);
glGetDoublev(GL_PROJECTION_MATRIX, mat);
result.setValue(mat);

View File

@@ -203,7 +203,8 @@ public:
float bottom,
float top,
float frustnear,
float frustfar
float frustfar,
bool perspective
);
virtual void SetSpecularity(

View File

@@ -73,10 +73,6 @@ bool RAS_VAOpenGLRasterizer::Init(void)
if (result)
{
// if possible, add extensions to other platforms too, if this
// rasterizer becomes messy just derive one for each platform
// (ie. KX_Win32Rasterizer, KX_LinuxRasterizer etc.)
glEnableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
@@ -187,6 +183,17 @@ void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays
glColor3d(0,0,0);
}
// use glDrawElements to draw each vertexarray
static bool doWarning = true;
if (vertexarrays.size() > 1 && doWarning)
{
/* TODO: if vertexarrays.size() == 1 then if we are multitexturing
we can glLockArraysEXT the vertex arrays - GL will be able to cache
the vertex transforms. */
std::cout << "# vertex arrays: " << vertexarrays.size() << std::endl;
std::cout << "I wondered if this could happen: please inform the proper authorities." << std::endl;
doWarning = false;
}
for (vt=0;vt<vertexarrays.size();vt++)
{
vertexarray = &((*vertexarrays[vt]) [0]);