本文整理汇总了C++中MT_Vector3函数的典型用法代码示例。如果您正苦于以下问题:C++ MT_Vector3函数的具体用法?C++ MT_Vector3怎么用?C++ MT_Vector3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MT_Vector3函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetVertex
void RAS_IDisplayArray::UpdateFrom(RAS_IDisplayArray *other, int flag)
{
if (flag & TANGENT_MODIFIED) {
for (unsigned int i = 0, size = other->GetVertexCount(); i < size; ++i) {
GetVertex(i)->SetTangent(MT_Vector4(other->GetVertex(i)->getTangent()));
}
}
if (flag & UVS_MODIFIED) {
const unsigned short uvSize = min_ii(GetVertexUvSize(), other->GetVertexUvSize());
for (unsigned int i = 0, size = other->GetVertexCount(); i < size; ++i) {
for (unsigned int uv = 0; uv < uvSize; ++uv) {
GetVertex(i)->SetUV(uv, MT_Vector2(other->GetVertex(i)->getUV(uv)));
}
}
}
if (flag & POSITION_MODIFIED) {
for (unsigned int i = 0, size = other->GetVertexCount(); i < size; ++i) {
GetVertex(i)->SetXYZ(MT_Vector3(other->GetVertex(i)->getXYZ()));
}
}
if (flag & NORMAL_MODIFIED) {
for (unsigned int i = 0, size = other->GetVertexCount(); i < size; ++i) {
GetVertex(i)->SetNormal(MT_Vector3(other->GetVertex(i)->getNormal()));
}
}
if (flag & COLORS_MODIFIED) {
const unsigned short colorSize = min_ii(GetVertexColorSize(), other->GetVertexColorSize());
for (unsigned int i = 0, size = other->GetVertexCount(); i < size; ++i) {
for (unsigned int color = 0; color < colorSize; ++color) {
GetVertex(i)->SetRGBA(color, other->GetVertex(i)->getRawRGBA(color));
}
}
}
}
开发者ID:UPBGE,项目名称:blender,代码行数:34,代码来源:RAS_IDisplayArray.cpp
示例2: Render
// #define DRAW_ALL_COLLIDERS
void KX_Terrain::Render()
{
for (KX_CellList::iterator it = m_cells.begin(), end = m_cells.end(); it != end; ++it) {
KX_Cell *cell = *it;
cell->SetColor(MT_Vector3(1.0f, 0.0f, 1.0f));
}
for (KX_CellList::iterator it = m_currentFront.begin(), end = m_currentFront.end(); it != end; ++it) {
KX_Cell *cell = *it;
cell->SetColor(MT_Vector3(1.0f, 1.0f, 0.0f));
cell->RenderVelocity(m_currentCollider - 1);
}
#ifdef DRAW_ALL_COLLIDERS
for (unsigned int i = 0; i < m_colliders.size(); ++i) {
KX_Cell *collider = m_colliders[i].cell;
collider->SetColor(MT_Vector3(0.0f, 0.0f, 0.0f));
}
#else
KX_Cell *collider = m_colliders[m_currentCollider - 1].cell;
collider->SetColor(MT_Vector3(0.0f, 0.0f, 0.0f));
collider->RenderVelocity(m_currentCollider - 1);
#endif
for (KX_CellList::iterator it = m_cells.begin(), end = m_cells.end(); it != end; ++it) {
KX_Cell *cell = *it;
cell->Render();
}
}
开发者ID:Passtechsoft,项目名称:TPEAlpGen,代码行数:30,代码来源:KX_Terrain.cpp
示例3: _PyUnicode_AsString
PyObject*
KX_VertexProxy::py_getattro(PyObject *attr)
{
char *attr_str= _PyUnicode_AsString(attr);
if (attr_str[1]=='\0') { // Group single letters
// pos
if (attr_str[0]=='x')
return PyFloat_FromDouble(m_vertex->getXYZ()[0]);
if (attr_str[0]=='y')
return PyFloat_FromDouble(m_vertex->getXYZ()[1]);
if (attr_str[0]=='z')
return PyFloat_FromDouble(m_vertex->getXYZ()[2]);
// Col
if (attr_str[0]=='r')
return PyFloat_FromDouble(m_vertex->getRGBA()[0]/255.0);
if (attr_str[0]=='g')
return PyFloat_FromDouble(m_vertex->getRGBA()[1]/255.0);
if (attr_str[0]=='b')
return PyFloat_FromDouble(m_vertex->getRGBA()[2]/255.0);
if (attr_str[0]=='a')
return PyFloat_FromDouble(m_vertex->getRGBA()[3]/255.0);
// UV
if (attr_str[0]=='u')
return PyFloat_FromDouble(m_vertex->getUV1()[0]);
if (attr_str[0]=='v')
return PyFloat_FromDouble(m_vertex->getUV1()[1]);
}
if (!strcmp(attr_str, "XYZ"))
return PyObjectFrom(MT_Vector3(m_vertex->getXYZ()));
if (!strcmp(attr_str, "UV"))
return PyObjectFrom(MT_Point2(m_vertex->getUV1()));
if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
{
const unsigned char *colp = m_vertex->getRGBA();
MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]);
color /= 255.0;
return PyObjectFrom(color);
}
if (!strcmp(attr_str, "normal"))
{
return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
}
py_getattro_up(CValue);
}
开发者ID:jinjoh,项目名称:NOOR,代码行数:52,代码来源:KX_VertexProxy.cpp
示例4: return
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
{
return (
/* m_flag == other->m_flag && */
/* at the moment the face only stores the smooth/flat setting so dont bother comparing it */
m_rgba == other->m_rgba &&
MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) &&
MT_fuzzyEqual(MT_Vector3(m_tangent), MT_Vector3(other->m_tangent)) &&
MT_fuzzyEqual(MT_Vector2(m_uv1), MT_Vector2(other->m_uv1)) &&
MT_fuzzyEqual(MT_Vector2(m_uv2), MT_Vector2(other->m_uv2)) /* &&
MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))*/) ;
/* dont bother comparing m_localxyz since we know there from the same vert */
}
开发者ID:jinjoh,项目名称:NOOR,代码行数:14,代码来源:RAS_TexVert.cpp
示例5: normalize
static MT_Vector3 normalize(const MT_Vector3& v)
{
// a sane normalize function that doesn't give (1, 0, 0) in case
// of a zero length vector, like MT_Vector3.normalize
MT_Scalar len = v.length();
return MT_fuzzyZero(len) ? MT_Vector3(0, 0, 0) : v / len;
}
开发者ID:Aligorith,项目名称:blender,代码行数:7,代码来源:IK_QJacobianSolver.cpp
示例6: MT_Vector3
MT_Vector3 KX_BulletPhysicsController::GetAngularVelocity()
{
float angVel[3];
//CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
return MT_Vector3(angVel[0],angVel[1],angVel[2]);
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:7,代码来源:KX_BulletPhysicsController.cpp
示例7: KX_GameObject
KX_FontObject::KX_FontObject(void* sgReplicationInfo,
SG_Callbacks callbacks,
RAS_IRasterizer* rasterizer,
Object *ob,
bool do_color_management):
KX_GameObject(sgReplicationInfo, callbacks),
m_object(ob),
m_dpi(72),
m_resolution(1.f),
m_rasterizer(rasterizer),
m_do_color_management(do_color_management)
{
Curve *text = static_cast<Curve *> (ob->data);
m_text = split_string(text->str);
m_fsize = text->fsize;
m_line_spacing = text->linedist;
m_offset = MT_Vector3(text->xof, text->yof, 0);
m_fontid = GetFontId(text->vfont);
/* initialize the color with the object color and store it in the KX_Object class
* This is a workaround waiting for the fix:
* [#25487] BGE: Object Color only works when it has a keyed frame */
copy_v4_v4(m_color, (const float*) ob->col);
this->SetObjectColor((const MT_Vector4&) m_color);
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:26,代码来源:KX_FontObject.cpp
示例8: MT_fuzzyEqual
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
{
bool uv_match = true;
for (int i=0; i<MAX_UNIT; i++)
uv_match = uv_match && MT_fuzzyEqual(MT_Vector2(m_uvs[i]), MT_Vector2(other->m_uvs[i]));
return (
/* m_flag == other->m_flag && */
/* at the moment the face only stores the smooth/flat setting so don't bother comparing it */
m_rgba == other->m_rgba &&
MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) &&
MT_fuzzyEqual(MT_Vector3(m_tangent), MT_Vector3(other->m_tangent)) &&
uv_match /* &&
MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))*/);
/* don't bother comparing m_localxyz since we know there from the same vert */
}
开发者ID:danielmarg,项目名称:blender-main,代码行数:17,代码来源:RAS_TexVert.cpp
示例9: BOP_removeOverlappedFaces
/**
* Removes faces from facesB that are overlapped with anyone from facesA.
* @param mesh mesh that contains the faces, edges and vertices
* @param facesA set of faces from object A
* @param facesB set of faces from object B
*/
void BOP_removeOverlappedFaces(BOP_Mesh *mesh, BOP_Faces *facesA, BOP_Faces *facesB)
{
for(unsigned int i=0;i<facesA->size();i++) {
BOP_Face *faceI = (*facesA)[i];
if (faceI->getTAG()==BROKEN) continue;
bool overlapped = false;
MT_Point3 p1 = mesh->getVertex(faceI->getVertex(0))->getPoint();
MT_Point3 p2 = mesh->getVertex(faceI->getVertex(1))->getPoint();
MT_Point3 p3 = mesh->getVertex(faceI->getVertex(2))->getPoint();
for(unsigned int j=0;j<facesB->size();) {
BOP_Face *faceJ = (*facesB)[j];
if (faceJ->getTAG()!=BROKEN) {
MT_Plane3 planeJ = faceJ->getPlane();
if (BOP_containsPoint(planeJ,p1) && BOP_containsPoint(planeJ,p2)
&& BOP_containsPoint(planeJ,p3)) {
MT_Point3 q1 = mesh->getVertex(faceJ->getVertex(0))->getPoint();
MT_Point3 q2 = mesh->getVertex(faceJ->getVertex(1))->getPoint();
MT_Point3 q3 = mesh->getVertex(faceJ->getVertex(2))->getPoint();
if (BOP_overlap(MT_Vector3(planeJ.x(),planeJ.y(),planeJ.z()),
p1,p2,p3,q1,q2,q3)) {
facesB->erase(facesB->begin()+j,facesB->begin()+(j+1));
faceJ->setTAG(BROKEN);
overlapped = true;
}
else j++;
}
else j++;
}else j++;
}
if (overlapped) faceI->setTAG(OVERLAPPED);
}
}
开发者ID:MakersF,项目名称:BlenderDev,代码行数:38,代码来源:BOP_Face2Face.cpp
示例10: GLSphere
GLSphere(MT_Scalar radius)
#if defined(USE_MARGIN)
: Shape(DT_NewPoint(MT_Vector3(0.0f, 0.0f, 0.0f))),
#else
: Shape(DT_NewSphere(1.0f)),
#endif
m_radius(radius)
{}
开发者ID:BackupTheBerlios,项目名称:solid3d-svn,代码行数:8,代码来源:gldemo.cpp
示例11: SCA_IActuator
KX_SteeringActuator::KX_SteeringActuator(SCA_IObject *gameobj,
int mode,
KX_GameObject *target,
KX_GameObject *navmesh,
float distance,
float velocity,
float acceleration,
float turnspeed,
bool isSelfTerminated,
int pathUpdatePeriod,
KX_ObstacleSimulation* simulation,
short facingmode,
bool normalup,
bool enableVisualization,
bool lockzvel)
: SCA_IActuator(gameobj, KX_ACT_STEERING),
m_target(target),
m_mode(mode),
m_distance(distance),
m_velocity(velocity),
m_acceleration(acceleration),
m_turnspeed(turnspeed),
m_simulation(simulation),
m_updateTime(0),
m_obstacle(NULL),
m_isActive(false),
m_isSelfTerminated(isSelfTerminated),
m_enableVisualization(enableVisualization),
m_facingMode(facingmode),
m_normalUp(normalup),
m_pathLen(0),
m_pathUpdatePeriod(pathUpdatePeriod),
m_lockzvel(lockzvel),
m_wayPointIdx(-1),
m_steerVec(MT_Vector3(0, 0, 0))
{
m_navmesh = static_cast<KX_NavMeshObject*>(navmesh);
if (m_navmesh)
m_navmesh->RegisterActuator(this);
if (m_target)
m_target->RegisterActuator(this);
if (m_simulation)
m_obstacle = m_simulation->GetObstacle((KX_GameObject*)gameobj);
KX_GameObject* parent = ((KX_GameObject*)gameobj)->GetParent();
if (m_facingMode>0 && parent)
{
m_parentlocalmat = parent->GetSGNode()->GetLocalOrientation();
}
else
m_parentlocalmat.setIdentity();
}
开发者ID:UPBGE,项目名称:blender,代码行数:52,代码来源:KX_SteeringActuator.cpp
示例12: inertia
MT_Vector3 KX_BulletPhysicsController::GetLocalInertia()
{
MT_Vector3 inertia(0.f, 0.f, 0.f);
btVector3 inv_inertia;
if (GetRigidBody()) {
inv_inertia = GetRigidBody()->getInvInertiaDiagLocal();
if (!btFuzzyZero(inv_inertia.getX()) &&
!btFuzzyZero(inv_inertia.getY()) &&
!btFuzzyZero(inv_inertia.getZ()))
inertia = MT_Vector3(1.f/inv_inertia.getX(), 1.f/inv_inertia.getY(), 1.f/inv_inertia.getZ());
}
return inertia;
}
开发者ID:JasonWilkins,项目名称:blender-wayland,代码行数:13,代码来源:KX_BulletPhysicsController.cpp
示例13: GetOpenGLMatrix
void KX_FontObject::UpdateBuckets()
{
// Update datas and add mesh slot to be rendered only if the object is not culled.
if (m_bVisible && m_meshUser) {
if (m_pSGNode->IsDirty()) {
GetOpenGLMatrix();
}
// Allow for some logic brick control
if (GetProperty("Text")) {
m_text = split_string(GetProperty("Text")->GetText());
}
// update the animated color
GetObjectColor().getValue(m_color);
// Font Objects don't use the glsl shader, this color management code is copied from gpu_shader_material.glsl
float color[4];
if (m_do_color_management) {
linearrgb_to_srgb_v4(color, m_color);
}
else {
copy_v4_v4(color, m_color);
}
// HARDCODED MULTIPLICATION FACTOR - this will affect the render resolution directly
const float RES = BGE_FONT_RES * m_resolution;
const float size = m_fsize * NodeGetWorldScaling()[0] * RES;
const float aspect = m_fsize / size;
// Account for offset
MT_Vector3 offset = NodeGetWorldOrientation() * m_offset * NodeGetWorldScaling();
// Orient the spacing vector
MT_Vector3 spacing = NodeGetWorldOrientation() * MT_Vector3(0.0f, m_fsize * m_line_spacing, 0.0f) * NodeGetWorldScaling()[1];
RAS_TextUser *textUser = (RAS_TextUser *)m_meshUser;
textUser->SetColor(MT_Vector4(color));
textUser->SetFrontFace(!m_bIsNegativeScaling);
textUser->SetFontId(m_fontid);
textUser->SetSize(size);
textUser->SetDpi(m_dpi);
textUser->SetAspect(aspect);
textUser->SetOffset(offset);
textUser->SetSpacing(spacing);
textUser->SetTexts(m_text);
textUser->ActivateMeshSlots();
}
}
开发者ID:UPBGE,项目名称:blender,代码行数:51,代码来源:KX_FontObject.cpp
示例14: split_string
void KX_FontObject::DrawFontText()
{
/* Allow for some logic brick control */
if (this->GetProperty("Text"))
m_text = split_string(this->GetProperty("Text")->GetText());
/* only draws the text if visible */
if (this->GetVisible() == 0) return;
/* update the animated color */
this->GetObjectColor().getValue(m_color);
/* Font Objects don't use the glsl shader, this color management code is copied from gpu_shader_material.glsl */
float color[4];
if (m_do_color_management) {
linearrgb_to_srgb_v4(color, m_color);
}
else {
copy_v4_v4(color, m_color);
}
/* HARDCODED MULTIPLICATION FACTOR - this will affect the render resolution directly */
const float RES = BGE_FONT_RES * m_resolution;
const float size = m_fsize * this->NodeGetWorldScaling()[0] * RES;
const float aspect = m_fsize / size;
/* Get a working copy of the OpenGLMatrix to use */
double mat[16];
memcpy(mat, this->GetOpenGLMatrix(), sizeof(double)*16);
/* Account for offset */
MT_Vector3 offset = this->NodeGetWorldOrientation() * m_offset * this->NodeGetWorldScaling();
mat[12] += offset[0]; mat[13] += offset[1]; mat[14] += offset[2];
/* Orient the spacing vector */
MT_Vector3 spacing = MT_Vector3(0, m_fsize*m_line_spacing, 0);
spacing = this->NodeGetWorldOrientation() * spacing * this->NodeGetWorldScaling()[1];
/* Draw each line, taking spacing into consideration */
for (int i=0; i<m_text.size(); ++i)
{
if (i!=0)
{
mat[12] -= spacing[0];
mat[13] -= spacing[1];
mat[14] -= spacing[2];
}
m_rasterizer->RenderText3D(m_fontid, m_text[i], int(size), m_dpi, color, mat, aspect);
}
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:51,代码来源:KX_FontObject.cpp
示例15: SG_SetActiveStage
void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
{
bool override_camera = (m_overrideCam && (scene->GetName() == m_overrideSceneName));
SG_SetActiveStage(SG_STAGE_SCENE);
// if there is no activecamera, or the camera is being
// overridden we need to construct a temporarily camera
if (!scene->GetActiveCamera() || override_camera)
{
KX_Camera* activecam = NULL;
RAS_CameraData camdata = RAS_CameraData();
if (override_camera)
{
camdata.m_lens = m_overrideCamLens;
camdata.m_clipstart = m_overrideCamNear;
camdata.m_clipend = m_overrideCamFar;
camdata.m_perspective= !m_overrideCamUseOrtho;
}
activecam = new KX_Camera(scene,KX_Scene::m_callbacks,camdata);
activecam->SetName("__default__cam__");
// set transformation
if (override_camera) {
const MT_CmMatrix4x4& cammatdata = m_overrideCamViewMat;
MT_Transform trans = MT_Transform(cammatdata.getPointer());
MT_Transform camtrans;
camtrans.invert(trans);
activecam->NodeSetLocalPosition(camtrans.getOrigin());
activecam->NodeSetLocalOrientation(camtrans.getBasis());
activecam->NodeUpdateGS(0);
} else {
activecam->NodeSetLocalPosition(MT_Point3(0.0, 0.0, 0.0));
activecam->NodeSetLocalOrientation(MT_Vector3(0.0, 0.0, 0.0));
activecam->NodeUpdateGS(0);
}
scene->AddCamera(activecam);
scene->SetActiveCamera(activecam);
scene->GetObjectList()->Add(activecam->AddRef());
scene->GetRootParentList()->Add(activecam->AddRef());
//done with activecam
activecam->Release();
}
scene->UpdateParents(0.0);
}
开发者ID:mik0001,项目名称:Blender,代码行数:50,代码来源:KX_KetsjiEngine.cpp
示例16: localCFrame
static PyObject *gPyCreateConstraint(PyObject *self,
PyObject *args,
PyObject *kwds)
{
/* FIXME - physicsid is a long being cast to a pointer, should at least use PyCapsule */
unsigned long long physicsid = 0, physicsid2 = 0;
int constrainttype = 0;
int flag = 0;
float pivotX = 0.0f, pivotY = 0.0f, pivotZ = 0.0f, axisX = 0.0f, axisY = 0.0f, axisZ = 0.0f;
static const char *kwlist[] = {"physicsid_1", "physicsid_2", "constraint_type", "pivot_x", "pivot_y", "pivot_z",
"axis_X", "axis_y", "axis_z", "flag", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "KKi|ffffffi:createConstraint", (char **)kwlist,
&physicsid, &physicsid2, &constrainttype,
&pivotX, &pivotY, &pivotZ, &axisX, &axisY, &axisZ, &flag))
{
return NULL;
}
if (PHY_GetActiveEnvironment()) {
PHY_IPhysicsController *physctrl = (PHY_IPhysicsController*)physicsid;
PHY_IPhysicsController *physctrl2 = (PHY_IPhysicsController*)physicsid2;
if (physctrl) { //TODO:check for existence of this pointer!
//convert from euler angle into axis
const float deg2rad = 0.017453292f;
//we need to pass a full constraint frame, not just axis
//localConstraintFrameBasis
MT_Matrix3x3 localCFrame(MT_Vector3(deg2rad*axisX, deg2rad*axisY, deg2rad*axisZ));
MT_Vector3 axis0 = localCFrame.getColumn(0);
MT_Vector3 axis1 = localCFrame.getColumn(1);
MT_Vector3 axis2 = localCFrame.getColumn(2);
int constraintid = PHY_GetActiveEnvironment()->CreateConstraint(
physctrl, physctrl2, (enum PHY_ConstraintType)constrainttype, pivotX, pivotY, pivotZ,
(float)axis0.x(), (float)axis0.y(), (float)axis0.z(),
(float)axis1.x(), (float)axis1.y(), (float)axis1.z(),
(float)axis2.x(), (float)axis2.y(), (float)axis2.z(), flag);
KX_ConstraintWrapper *wrap = new KX_ConstraintWrapper(
(enum PHY_ConstraintType)constrainttype, constraintid, PHY_GetActiveEnvironment());
return wrap->NewProxy(true);
}
}
Py_RETURN_NONE;
}
开发者ID:Andrewson3D,项目名称:blender-for-vray,代码行数:48,代码来源:KX_PyConstraintBinding.cpp
示例17: setRotation
void
MT_ExpMap::
setRotation(
const MT_Quaternion &q
) {
// ok first normalize the quaternion
// then compute theta the axis-angle and the normalized axis v
// scale v by theta and that's it hopefully!
m_q = q.normalized();
m_v = MT_Vector3(m_q.x(), m_q.y(), m_q.z());
MT_Scalar cosp = m_q.w();
m_sinp = m_v.length();
m_v /= m_sinp;
m_theta = atan2(double(m_sinp),double(cosp));
m_v *= m_theta;
}
开发者ID:BHCLL,项目名称:blendocv,代码行数:19,代码来源:MT_ExpMap.cpp
示例18: m_object
KX_FontObject::KX_FontObject(void *sgReplicationInfo,
SG_Callbacks callbacks,
RAS_IRasterizer *rasterizer,
Object *ob,
bool do_color_management)
:KX_GameObject(sgReplicationInfo, callbacks),
m_object(ob),
m_dpi(72),
m_resolution(1.0f),
m_rasterizer(rasterizer),
m_do_color_management(do_color_management)
{
Curve *text = static_cast<Curve *> (ob->data);
m_text = split_string(text->str);
m_fsize = text->fsize;
m_line_spacing = text->linedist;
m_offset = MT_Vector3(text->xof, text->yof, 0.0f);
m_fontid = GetFontId(text->vfont);
}
开发者ID:UPBGE,项目名称:blender,代码行数:20,代码来源:KX_FontObject.cpp
示例19: NewMeshFromFile
MEM_SmartPtr<BSP_TMesh>
BSP_PlyLoader::
NewMeshFromFile(
char * file_name,
MT_Vector3 &min,
MT_Vector3 &max
) {
min = MT_Vector3(MT_INFINITY,MT_INFINITY,MT_INFINITY);
max = MT_Vector3(-MT_INFINITY,-MT_INFINITY,-MT_INFINITY);
PlyProperty vert_props[] = { /* list of property information for a vertex */
{"x", PLY_FLOAT, PLY_FLOAT, offsetof(LoadVertex,x), 0, 0, 0, 0},
{"y", PLY_FLOAT, PLY_FLOAT, offsetof(LoadVertex,y), 0, 0, 0, 0},
{"z", PLY_FLOAT, PLY_FLOAT, offsetof(LoadVertex,z), 0, 0, 0, 0},
};
PlyProperty face_props[] = { /* list of property information for a vertex */
{"vertex_indices", PLY_INT, PLY_INT, offsetof(LoadFace,verts),
1, PLY_UCHAR, PLY_UCHAR, offsetof(LoadFace,nverts)},
};
MEM_SmartPtr<BSP_TMesh> mesh = new BSP_TMesh;
if (mesh == NULL) return NULL;
int i,j;
PlyFile *ply;
int nelems;
char **elist;
int file_type;
float version;
int nprops;
int num_elems;
PlyProperty **plist;
char *elem_name;
LoadVertex load_vertex;
LoadFace load_face;
/* open a PLY file for reading */
ply = ply_open_for_reading(
file_name,
&nelems,
&elist,
&file_type,
&version
);
if (ply == NULL) return NULL;
/* go through each kind of element that we learned is in the file */
/* and read them */
for (i = 0; i < nelems; i++) {
/* get the description of the first element */
elem_name = elist[i];
plist = ply_get_element_description (ply, elem_name, &num_elems, &nprops);
/* print the name of the element, for debugging */
/* if we're on vertex elements, read them in */
if (equal_strings ("vertex", elem_name)) {
/* set up for getting vertex elements */
ply_get_property (ply, elem_name, &vert_props[0]);
ply_get_property (ply, elem_name, &vert_props[1]);
ply_get_property (ply, elem_name, &vert_props[2]);
// make some memory for the vertices
mesh->VertexSet().reserve(num_elems);
/* grab all the vertex elements */
for (j = 0; j < num_elems; j++) {
/* grab and element from the file */
ply_get_element (ply, (void *)&load_vertex);
// pass the vertex into the mesh builder.
if (load_vertex.x < min.x()) {
min.x() = load_vertex.x;
} else
if (load_vertex.x > max.x()) {
max.x()= load_vertex.x;
}
if (load_vertex.y < min.y()) {
min.y() = load_vertex.y;
} else
if (load_vertex.y > max.y()) {
max.y()= load_vertex.y;
}
if (load_vertex.z < min.z()) {
//.........这里部分代码省略.........
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:101,代码来源:BSP_PlyLoader.cpp
示例20: switch
/**
* Transforms the collision object. A cone is not correctly centered
* for usage. */
void KX_RadarSensor::SynchronizeTransform()
{
// Getting the parent location was commented out. Why?
MT_Transform trans;
trans.setOrigin(((KX_GameObject*)GetParent())->NodeGetWorldPosition());
trans.setBasis(((KX_GameObject*)GetParent())->NodeGetWorldOrientation());
// What is the default orientation? pointing in the -y direction?
// is the geometry correctly converted?
// a collision cone is oriented
// center the cone correctly
// depends on the radar 'axis'
switch (m_axis)
{
case SENS_RADAR_X_AXIS: // +X Axis
{
MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
case SENS_RADAR_Y_AXIS: // +Y Axis
{
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
case SENS_RADAR_Z_AXIS: // +Z Axis
{
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
case SENS_RADAR_NEG_X_AXIS: // -X Axis
{
MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
case SENS_RADAR_NEG_Y_AXIS: // -Y Axis
{
//MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
//trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
case SENS_RADAR_NEG_Z_AXIS: // -Z Axis
{
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
default:
{
}
}
//Using a temp variable to translate MT_Point3 to float[3].
//float[3] works better for the Python interface.
MT_Point3 temp = trans.getOrigin();
m_cone_origin[0] = temp[0];
m_cone_origin[1] = temp[1];
m_cone_origin[2] = temp[2];
temp = trans(MT_Point3(0, -m_coneheight/2.0 ,0));
m_cone_target[0] = temp[0];
m_cone_target[1] = temp[1];
m_cone_target[2] = temp[2];
if (m_physCtrl)
{
PHY_IMotionState* motionState = m_physCtrl->GetMotionState();
const MT_Point3& pos = trans.getOrigin();
float ori[12];
trans.getBasis().getValue(ori);
motionState->setWorldPosition(pos[0], pos[1], pos[2]);
motionState->setWorldOrientation(ori);
m_physCtrl->WriteMotionStateToDynamics(true);
}
}
开发者ID:OldBrunet,项目名称:BGERTPS,代码行数:89,代码来源:KX_RadarSensor.cpp
注:本文中的MT_Vector3函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论