当前位置: 首页>>代码示例>>C++>>正文


C++ MT_Vector3函数代码示例

本文整理汇总了C++中MT_Vector3函数的典型用法代码示例。如果您正苦于以下问题:C++ MT_Vector3函数的具体用法?C++ MT_Vector3怎么用?C++ MT_Vector3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MT_Vector3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的MT_Vector3函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。