• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ VDynamicMesh类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了VDynamicMesh类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: VASSERT

void vHavokShapeFactory::GetHktDependencies(VResourceSnapshot &snapshot, VisBaseEntity_cl *pEntity)
{
  VASSERT(pEntity != NULL);

  // Get wrapped rigid body
  vHavokRigidBody *pWrappedRigidBody = pEntity->Components().GetComponentOfType<vHavokRigidBody>();
  if (pWrappedRigidBody == NULL)
    return;

  // Get shape
  vHavokPhysicsModule *pModule = vHavokPhysicsModule::GetInstance();
  VASSERT(pModule != NULL);
  pModule->MarkForRead();
  const hkpRigidBody *pRigidBody = pWrappedRigidBody->GetHkRigidBody();
  if (pRigidBody == NULL)
  {
    pModule->UnmarkForRead();
    return;
  }
  const hkpShape *pShape = pRigidBody->getCollidable()->getShape();
  pModule->UnmarkForRead();
  
  // Only convex/ mesh rigid bodies have a cached HKT file
  const hkClass* loadedClassType = hkVtableClassRegistry::getInstance().getClassFromVirtualInstance(pShape);
  if (loadedClassType!=&hkvConvexVerticesShapeClass && loadedClassType!=&hkvBvCompressedMeshShapeClass)
    return;

  // Get mesh
  VDynamicMesh *pMesh = pEntity->GetMesh();
  if (pMesh == NULL)
    return;

  // Get scale
  hkvVec3 vScale = pEntity->GetScaling();
  bool shrinkToFit = pWrappedRigidBody->Havok_TightFit;

  // Get HKT file dependency for convex/ mesh rigid body
  if (loadedClassType == &hkvConvexVerticesShapeClass) 
  {
    VStaticString<FS_MAX_PATH> szCachedShapeName(pMesh->GetFilename());
    vHavokCachedShape::GetConvexShapePath(szCachedShapeName, vScale, shrinkToFit);
    IVFileInStream *pIn = Vision::File.Open(szCachedShapeName);
    if (pIn)
    {
      snapshot.AddFileDependency(pMesh, szCachedShapeName, pIn->GetSize() );
      pIn->Close();
    }
  }
  else if(loadedClassType == &hkvBvCompressedMeshShapeClass) 
  {
    VStaticString<FS_MAX_PATH> szCachedShapeName(pMesh->GetFilename());
    vHavokCachedShape::GetMeshShapePath(szCachedShapeName, vScale, VisStaticMeshInstance_cl::VIS_COLLISION_BEHAVIOR_CUSTOM, (VisWeldingType_e)pWrappedRigidBody->Havok_WeldingType);
    IVFileInStream *pIn = Vision::File.Open(szCachedShapeName);
    if (pIn)
    {
      snapshot.AddFileDependency(pMesh, szCachedShapeName, pIn->GetSize() );
      pIn->Close();
    }
  }
}
开发者ID:cDoru,项目名称:projectanarchy,代码行数:60,代码来源:vHavokShapeFactory.cpp


示例2: CommonDeinit

// ----------------------------------------------------------------------------
void vHavokChainAnimation::CommonInit()
{
  CommonDeinit();

  if (!m_pOwner || !m_pOwner->IsOfType(V_RUNTIME_CLASS(VisBaseEntity_cl)))
    return;

  Vision::Callbacks.OnUpdateSceneFinished += this;

  m_pOwnerEntity = static_cast<VisBaseEntity_cl*>(m_pOwner);
  VisAnimConfig_cl *pAnimConfig = m_pOwnerEntity->GetAnimConfig();

  // If there is no AnimConfig, but we can get a skeleton, create the AnimConfig.
  if (!pAnimConfig)
  {
    VDynamicMesh *pMesh = m_pOwnerEntity->GetMesh();
    VisSkeleton_cl *pSkeleton = pMesh ? pMesh->GetSkeleton() : NULL;
    if (pSkeleton)
    {
      VisAnimFinalSkeletalResult_cl* pFinalSkeletalResult;
      pAnimConfig = VisAnimConfig_cl::CreateSkeletalConfig(pMesh, &pFinalSkeletalResult);
      m_pOwnerEntity->SetAnimConfig(pAnimConfig);
    }
  }
}
开发者ID:Alagong,项目名称:projectanarchy,代码行数:26,代码来源:vHavokChainAnimation.cpp


示例3: AddAnimationSequence

bool VAnimationComponent::AddAnimationSequence(const char * szAnimSequence)
{
  if (szAnimSequence == NULL || GetOwner() == NULL) return false;

  VDynamicMesh * pMesh = ((VisBaseEntity_cl *)m_pOwner)->GetMesh();
  if(pMesh==NULL)
  {
    hkvLog::Warning("AddAnimationSequence: No mesh present!");
    return false;
  }

  VASSERT_MSG(pMesh->GetSequenceSetCollection()!=NULL, "No animation sequence set present!");

  VisAnimSequenceSet_cl *pSet = Vision::Animations.GetSequenceSetManager()->LoadAnimSequenceSet(szAnimSequence);

  if(pSet==NULL)
  {
    hkvLog::Warning("AddAnimationSequence: Could not load '%s' animation sequence.", szAnimSequence);
    return false;
  }

  pMesh->GetSequenceSetCollection()->Add(pSet);

  return true;
}
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:25,代码来源:VAnimationComponent.cpp


示例4: MessageFunction

void VAnimationEventEffectTrigger::MessageFunction( int iID, INT_PTR iParamA, INT_PTR iParamB )
{  
  IVTransitionEventTrigger::MessageFunction(iID, iParamA, iParamB);

#ifdef WIN32
  if (iID == VIS_MSG_EDITOR_GETSTANDARDVALUES)
  {
    // Get bone names
    const char *szKey = (const char *)iParamA;
    if (!strcmp(szKey,"Bone"))
    {
      // Check for model and skeleton
      VisBaseEntity_cl* pEntity = (VisBaseEntity_cl *)m_pOwner;
      if (pEntity == NULL)
        return;
      VDynamicMesh* pMesh = pEntity->GetMesh();
      if (pMesh == NULL)
        return;
      VisSkeleton_cl *pSkeleton = pMesh->GetSkeleton();
      if (pSkeleton == NULL)
        return;

      // Fill list with bone names (first entry is empty)
      VStrList *pDestList = (VStrList*) iParamB;
      pDestList->AddString(" ");
      for (int i = 0; i < pSkeleton->GetBoneCount(); i++)
        pDestList->AddString(pSkeleton->GetBone(i)->m_sBoneName.AsChar());
    }
  }
#endif
}
开发者ID:Bewolf2,项目名称:projectanarchy,代码行数:31,代码来源:VAnimationEventEffectTrigger.cpp


示例5: UpdateAnimationAndBoneIndexList

void vHavokBehaviorComponent::UpdateAnimationAndBoneIndexList()
{
	// Set up the animation config
	VDynamicMesh* mesh = m_entityOwner->GetMesh();
	if( mesh != HK_NULL && mesh->GetSkeleton() != HK_NULL )
	{
		// create an anim config, if one is not present
		VisAnimConfig_cl* pConfig = m_entityOwner->GetAnimConfig();
		if ( pConfig == HK_NULL )
		{
			pConfig = VisAnimConfig_cl::CreateSkeletalConfig(mesh);
			m_entityOwner->SetAnimConfig( pConfig );
		}

		pConfig->SetFlags(pConfig->GetFlags() | MULTITHREADED_ANIMATION);

		// Create mapping
		VisSkeleton_cl* visionSkeleton = mesh->GetSkeleton();
		const hkaSkeleton* havokSkeleton = m_character->getSetup()->m_animationSkeleton;

		for( int i = 0; i < havokSkeleton->m_bones.getSize(); i++ )
		{
			const VHashString &boneName = havokSkeleton->m_bones[i].m_name.cString();
			int visionBoneIndex = visionSkeleton->GetBoneIndexByName( boneName );
			m_boneIndexList.pushBack( visionBoneIndex );
		}
	}
}
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:28,代码来源:vHavokBehaviorComponent.cpp


示例6: StartSingleAnimation

void SimpleSkeletalAnimatedObject_cl::LookAt()
{
  // start a single animation
  StartSingleAnimation(true);

  // start a simple skeletal animation
  bool bLooped = true;
  int iFlags = VSKELANIMCTRL_DEFAULTS;
  if (bLooped)
    iFlags |= VANIMCTRL_LOOP;
  m_spSingleAnimControl = VisAnimConfig_cl::StartSkeletalAnimation(this, "Run", iFlags);


  // find the head bone index
  VDynamicMesh *pMesh = GetMesh();
  m_iHeadBoneIndex = pMesh->GetSkeleton()->GetBoneIndexByName("skeleton1:Head");

  // create a rotation matrix that defines the actual orientation of the head. This is model specific and can
  // only be found out by trial and error (typically 0, 90 or 180 deg). In our case the head is rotated by 180 degrees; Without this additional
  // orientation that model would follow the target with the backside of the head.
  m_RelativeHeadOrientation.setFromEulerAngles (90, 0, 270);

  // create an entity that rotates around the model
  m_pLookAtTarget = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3::ZeroVector(), "Models/MagicBall.model");
  m_fLookAtRotationPhase = 0.f;
}
开发者ID:RexBaribal,项目名称:projectanarchy,代码行数:26,代码来源:SimpleSkeletalAnimatedObject.cpp


示例7: VEventEffectTriggerInfo_t

bool VAnimationEventEffectTrigger::CommonInit()
{
  // Initialize base component
  if (!IVTransitionEventTrigger::CommonInit())
    return false;
  
  // Get owner entity
  VisBaseEntity_cl *pEntity = (VisBaseEntity_cl *)m_pOwner;
  if (pEntity == NULL)
    return false;

  // Fill the event trigger info
  if (m_iEventTriggerInfoCount <= 0)
  {
    VEventEffectTriggerInfo_t* info = NULL;
    if(m_pActiveTriggerInfo == NULL) //make sure it does not get created more than once
    {
      // Create new list with only one entry and set properties
      info = new VEventEffectTriggerInfo_t();
    }
    else
    {
      info = (VEventEffectTriggerInfo_t*)m_pActiveTriggerInfo;
    }

    info->m_vPositionOffset = PositionOffset;
    info->m_vOrientationOffset= OrientationOffset;


    // Get effect file
    info->m_spEffectFile = VisParticleGroupManager_cl::GlobalManager().LoadFromFile(EffectFilename);
    if (info->m_spEffectFile == NULL || !GetEventTriggerInfoBaseData(info))
    {
      V_SAFE_DELETE(info);
      m_pActiveTriggerInfo = NULL;
      return false;
    }

    // Get Bone Index if specified
    if (!AttachToBone.IsEmpty())
    {
      VDynamicMesh* pMesh = pEntity->GetMesh();
      if (pMesh == NULL)
        return false;
      VisSkeleton_cl *pSkeleton = pMesh->GetSkeleton();
      if (pSkeleton == NULL)
        return false;

      info->m_iAttachToBone = pSkeleton->GetBoneIndexByName(AttachToBone);
    }

    // Set it as the active event trigger info
    m_pActiveTriggerInfo = info;
  }

  return true;
}
开发者ID:Bewolf2,项目名称:projectanarchy,代码行数:57,代码来源:VAnimationEventEffectTrigger.cpp


示例8: DeleteModels

void MergedModelFactory_cl::PreviewModel()
{
  DeleteModels();

  m_pPreviewModelEntities = new VisBaseEntity_cl*[BARBARIAN_MAX];
  m_pPreviewModelEntities[BARBARIAN_BODY] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Body.model");
  m_pPreviewModelEntities[BARBARIAN_ARM] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Arm.model");
  m_pPreviewModelEntities[BARBARIAN_SHOULDER] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Shoulder.model");
  m_pPreviewModelEntities[BARBARIAN_LEGS] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Legs.model");
  m_pPreviewModelEntities[BARBARIAN_KNEE] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Knee.model");
  m_pPreviewModelEntities[BARBARIAN_ACCESSOIRE] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Accessoire.model");
  m_pPreviewModelEntities[BARBARIAN_BELT] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Belt.model");
  m_pPreviewModelEntities[BARBARIAN_CLOTH] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Cloth.model");
  m_pPreviewModelEntities[BARBARIAN_BEARD] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Beard.model");
  m_pPreviewModelEntities[BARBARIAN_AXE] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Axe.model");
  m_pPreviewModelEntities[BARBARIAN_SWORD] = Vision::Game.CreateEntity("VisBaseEntity_cl", hkvVec3(0.f, 0.f, 0.f), "Barbarian_Sword.model");

  // Setup animation system
  VDynamicMesh* pBodyMesh = m_pPreviewModelEntities[BARBARIAN_BODY]->GetMesh();
  VisSkeletalAnimSequence_cl* pSequence = static_cast<VisSkeletalAnimSequence_cl*>(pBodyMesh->GetSequence("Idle", VIS_MODELANIM_SKELETAL));

  // Create shared skeletal anim control to animate all models in sync
  VisSkeletalAnimControl_cl* pSkeletalAnimControl = 
    VisSkeletalAnimControl_cl::Create(pBodyMesh->GetSkeleton(), pSequence, VSKELANIMCTRL_DEFAULTS | VANIMCTRL_LOOP);

  for (int i = 0; i < BARBARIAN_MAX; i++)
  {
    // Create anim config per entity
    VisAnimFinalSkeletalResult_cl* pFinalSkeletalResult = NULL;
    VisAnimConfig_cl* pConfig = VisAnimConfig_cl::CreateSkeletalConfig(m_pPreviewModelEntities[i]->GetMesh(), &pFinalSkeletalResult);
    pConfig->SetFlags(pConfig->GetFlags() | APPLY_MOTION_DELTA);

    // Anim config uses shared skeletal anim control as input
    pFinalSkeletalResult->SetSkeletalAnimInput(pSkeletalAnimControl);

    m_pPreviewModelEntities[i]->SetAnimConfig(pConfig);
    m_pPreviewModelEntities[i]->SetPosition(m_vPos);
    m_pPreviewModelEntities[i]->SetOrientation(m_vOri);
#ifndef _VISION_PSP2
    m_pPreviewModelEntities[i]->SetCastShadows(TRUE);
#endif
  }

  m_pCameraEntity->AttachToParent(m_pPreviewModelEntities[BARBARIAN_BODY]);
  m_pPlayerCamera->ResetOldPosition();
  m_pPlayerCamera->Follow = true;
  m_pPlayerCamera->Zoom = false;
  m_pPlayerCamera->InitialYaw = -90.f;

  
  UpdatePreview();
}
开发者ID:cDoru,项目名称:projectanarchy,代码行数:52,代码来源:MergedModelFactory.cpp


示例9: SetCastShadows

// **************************************************
//            OVERRIDDEN ENTITY FUNCTIONS
// **************************************************
void TransitionBarbarian_cl::InitFunction()
{
  if (!HasMesh())
    return;

  SetCastShadows(TRUE);
  
  // Setup all animation sequences
	SetupAnimations();
  if (!m_bModelValid)
    return;

  if( !m_pPhys)
  {
    m_pPhys = new vHavokCharacterController();
    m_pPhys->Initialize();

    hkvAlignedBBox bbox;
    VDynamicMesh *pMesh = GetMesh();
    pMesh->GetCollisionBoundingBox(bbox);

    float r = bbox.getSizeX() * 0.5f;
    m_pPhys->Capsule_Radius = r;
    m_pPhys->Character_Top.set(0,0,bbox.m_vMax.z - r);
    m_pPhys->Character_Bottom.set(0,0,bbox.m_vMin.z + r);

    m_pPhys->Max_Slope = 75.0f;
    AddComponent(m_pPhys);
    //	pPhys->SetDebugRendering(TRUE);
  }
 
  // Get Model
  VDynamicMesh* pModel = GetMesh();
	VASSERT(pModel);

  // Transition table to use
  VTransitionTable *pTable = VTransitionManager::GlobalManager().LoadTransitionTable(pModel,"Barbarian.vTransition");
  VASSERT(pTable && pTable->IsLoaded());

	// Setup the state machine component and pass the filename of the transition file
  // in which the transitions between the various animation states are defined.
	m_pStateMachine = new VTransitionStateMachine();
  m_pStateMachine->Init(this, pTable);
	AddComponent(m_pStateMachine);

	// Set initial state
	m_pStateMachine->SetState(m_pSkeletalSequenceList[ANIMID_IDLE]);
}
开发者ID:Bewolf2,项目名称:projectanarchy,代码行数:51,代码来源:TransitionBarbarian.cpp


示例10: GetMesh

// **************************************************
//            SETUP ANIMATIONS
// **************************************************
void TransitionBarbarian_cl::SetupAnimations()
{
  m_bModelValid = false;
  VDynamicMesh *pModel = GetMesh();
  VVERIFY_OR_RET(pModel);

  m_pSkeletalSequenceList[ANIMID_IDLE] = (VisSkeletalAnimSequence_cl*)pModel->GetSequence("Idle", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_pSkeletalSequenceList[ANIMID_IDLE]);

  m_pSkeletalSequenceList[ANIMID_WALK] = (VisSkeletalAnimSequence_cl*)pModel->GetSequence("Walk", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_pSkeletalSequenceList[ANIMID_WALK]);

  m_pSkeletalSequenceList[ANIMID_RUN] = (VisSkeletalAnimSequence_cl*)pModel->GetSequence("Run", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_pSkeletalSequenceList[ANIMID_RUN]);

  m_bModelValid = true;
}
开发者ID:Bewolf2,项目名称:projectanarchy,代码行数:20,代码来源:TransitionBarbarian.cpp


示例11: GetMesh

void SimpleSkeletalAnimatedObject_cl::ForwardKinematics()
{
  // Apply forward kinematics to the head "Neck" bone, using a bone modifier node. The bone modifier
  // gets a skeletal animation as input, modifies the translation of the neck bone and generates the
  // combined result. The animation tree looks as follows:
  //
  // - FinalSkeletalResult
  //    - BoneModifierNode (modifies the neck bone)
  //      - SkeletalAnimControl (Walk Animation)
  //
  // The translation of the neck bone is set on the bone modifier node.
  //

  // Create a new AnimConfig instance
  VDynamicMesh *pMesh = GetMesh();
  VisAnimFinalSkeletalResult_cl* pFinalSkeletalResult;
  VisAnimConfig_cl* pConfig = VisAnimConfig_cl::CreateSkeletalConfig(pMesh, &pFinalSkeletalResult);

  // Get skeletal animation sequence.
  VisSkeletalAnimSequence_cl* pAnimSequenceWalk = 
    static_cast<VisSkeletalAnimSequence_cl*>(pMesh->GetSequence("Walk", VIS_MODELANIM_SKELETAL));
  if (pAnimSequenceWalk == NULL)
    return;

  // Create the animation control to play the walk animation (via a helper function).
  VSmartPtr<VisSkeletalAnimControl_cl> spWalkAnimControl = VisSkeletalAnimControl_cl::Create(
    pMesh->GetSkeleton(), pAnimSequenceWalk, VANIMCTRL_LOOP|VSKELANIMCTRL_DEFAULTS, 1.0f, true);

  // Create the bone modifier node that translates the head bone. Set the animation control instance
  // as the input for this node.
  m_spBoneModifierNode = new VisAnimBoneModifierNode_cl(pMesh->GetSkeleton());
  m_spBoneModifierNode->SetModifierInput(spWalkAnimControl);
  hkvQuat customBoneRotation;

  // set the neck bone translation on the bone modifier node
  m_iNeckBoneIndex = pMesh->GetSkeleton()->GetBoneIndexByName("skeleton1:Neck");
  customBoneRotation.setFromEulerAngles (0, -45, 0);
  m_spBoneModifierNode->SetCustomBoneRotation(m_iNeckBoneIndex, customBoneRotation, VIS_MODIFY_BONE);

  // finally set the bone modifier as the root animation node
  pFinalSkeletalResult->SetSkeletalAnimInput(m_spBoneModifierNode);
  SetAnimConfig(pConfig);

  // The bone modifier node is now part of the animation tree. You can at any time update the translation
  // on the bone modifier. The animation system will take care of generating the proper final result.
}
开发者ID:RexBaribal,项目名称:projectanarchy,代码行数:46,代码来源:SimpleSkeletalAnimatedObject.cpp


示例12: vPos

VisMeshBuffer_cl *VRendererNodeHelper::GetSphereMeshBuffer()
{
  if (m_spSphereMeshBuffer != NULL)
    return m_spSphereMeshBuffer;

  VDynamicMesh *pMesh = Vision::Game.LoadDynamicMesh("\\Models\\MagicBall.model", true, false);
  VASSERT(pMesh!=NULL);

  m_spSphereMeshBuffer = new VisMeshBuffer_cl();
  m_spSphereMeshBuffer->SetPrimitiveType(VisMeshBuffer_cl::MB_PRIMTYPE_INDEXED_TRILIST);
#ifdef HK_DEBUG
  m_spSphereMeshBuffer->SetFilename("<DeferredShadingSphereMesh>");
#endif

  VisMBVertexDescriptor_t descr;
  descr.Reset();
  descr.m_iPosOfs = 0 | VERTEXDESC_FORMAT_FLOAT3;
  descr.m_iStride = sizeof(float)*3;

  // get model properties
  int iVertexCount = pMesh->GetNumOfVertices();
  int iIndexCount = pMesh->GetNumOfTriangles() * 3;

  // copy vertex buffer, normalize vertex positions
  m_spSphereMeshBuffer->AllocateVertices(descr, iVertexCount); 
  float *pDestVerts = (float *)m_spSphereMeshBuffer->LockVertices(VIS_LOCKFLAG_DISCARDABLE);
  pMesh->CopyMeshVertices(pDestVerts, descr, 0, iVertexCount);
  for (int i=0; i<iVertexCount*3; i+=3)
  {
    hkvVec3 vPos(pDestVerts[i], pDestVerts[i+1], pDestVerts[i+2]);
    vPos.normalizeIfNotZero();
    memcpy(&pDestVerts[i], vPos.data, 3*sizeof(float));
  }
  m_spSphereMeshBuffer->UnLockVertices();

  // copy index buffer
  m_spSphereMeshBuffer->AllocateIndexList(iIndexCount);
  unsigned short *pDestIndices = (unsigned short *)m_spSphereMeshBuffer->LockIndices(VIS_LOCKFLAG_DISCARDABLE);
  pMesh->CopyMeshIndices(pDestIndices, (VisSurface_cl *)NULL);
  m_spSphereMeshBuffer->UnLockIndices();

  return m_spSphereMeshBuffer;
}
开发者ID:cDoru,项目名称:projectanarchy,代码行数:43,代码来源:VisApiRendererNode.cpp


示例13: GetMesh

// **************************************************
//            SETUP ANIMATIONS
// **************************************************
void TransitionCharacter_cl::SetupAnimations()
{
  m_bModelValid = false;
  VDynamicMesh *pMesh = GetMesh();
  VVERIFY_OR_RET(pMesh);

  // idle animations
  m_spSkeletalSequenceList[ANIMID_IDLE] = (VisSkeletalAnimSequence_cl*)pMesh->GetSequence("Idle", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_spSkeletalSequenceList[ANIMID_IDLE]);

  // run animations
  m_spSkeletalSequenceList[ANIMID_RUN] = (VisSkeletalAnimSequence_cl*)pMesh->GetSequence("Run", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_spSkeletalSequenceList[ANIMID_RUN]);

  // walk animations
  m_spSkeletalSequenceList[ANIMID_WALK] = (VisSkeletalAnimSequence_cl*)pMesh->GetSequence("Walk", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_spSkeletalSequenceList[ANIMID_WALK]);

  // turn animations
  m_spSkeletalSequenceList[ANIMID_TURN] = (VisSkeletalAnimSequence_cl*)pMesh->GetSequence("Turn", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_spSkeletalSequenceList[ANIMID_TURN]);

  // walk backwards animation
  m_spSkeletalSequenceList[ANIMID_WALKBACKWARDS] = (VisSkeletalAnimSequence_cl*)pMesh->GetSequence("Run_BWD", VIS_MODELANIM_SKELETAL);
  VVERIFY_OR_RET(m_spSkeletalSequenceList[ANIMID_WALKBACKWARDS]);

  m_bModelValid = true;
}
开发者ID:cDoru,项目名称:projectanarchy,代码行数:31,代码来源:TransitionCharacter.cpp


示例14: VISION_PROFILE_FUNCTION

bool VisClothDeformer_cl::UpdateDeformerResult(VisVertexAnimResult_cl* pVertexAnimResult)
{
  VISION_PROFILE_FUNCTION(VIS_PROFILE_ANIMSYS_RESULT_VERTEX_ANIM);
   
  if(m_spMesh == NULL)
    return false;

  //// fill vertexanimresult with the mesh data
  // destination buffer
  float *pDestVertexPosition;
  const int  iDestVertexPositionStride = pVertexAnimResult->GetDestVertexPosition(pDestVertexPosition);
  float *pDestVertexNormal;
  const int  iDestVertexNormalStride = pVertexAnimResult->GetDestVertexNormal(pDestVertexNormal);

  int iVertexCount = m_spMesh->GetVertexCount();
  VDynamicMesh *pMesh = pVertexAnimResult->GetMesh();
  VASSERT(pMesh->GetNumOfVertices() == m_spMesh->GetVertexCount());
  VisObjectVertexDelta_t *pVertexDelta = m_spMesh->GetVertexDeltaList();

  // copy mesh vertices into vertexanim result
  hkvVec3 tempNormal(hkvNoInitialization);
  hkvVec3 vTranslate;
  if (m_pParentObject)
    vTranslate = m_pParentObject->GetPosition();

  for(int i=0; i<iVertexCount; i++, pVertexDelta++, ADVANCE_VERTEXPOINTERS)
  {
    pDestVertexPosition[0] = pVertexDelta->delta[0] - vTranslate.x;
    pDestVertexPosition[1] = pVertexDelta->delta[1] - vTranslate.y;
    pDestVertexPosition[2] = pVertexDelta->delta[2] - vTranslate.z;
    tempNormal.set(pVertexDelta->normal[0], pVertexDelta->normal[1], pVertexDelta->normal[2]);
    tempNormal.normalizeIfNotZero();
    pDestVertexNormal[0] = tempNormal.x;
    pDestVertexNormal[1] = tempNormal.y;
    pDestVertexNormal[2] = tempNormal.z;
  }

  return true;
}
开发者ID:Alagong,项目名称:projectanarchy,代码行数:39,代码来源:ClothDeformer.cpp


示例15: VASSERT

// Render shaders on entities
void VPostProcessTranslucencies::DrawEntitiesShaders(const VisEntityCollection_cl &EntityCollection, VPassType_e ePassType)
{
  VisDrawCallInfo_t SurfaceShaderList[RLP_MAX_ENTITY_SURFACESHADERS];
  unsigned int iNumEntities = EntityCollection.GetNumEntries();
  unsigned int i;

  Vision::RenderLoopHelper.BeginEntityRendering();

  for (i=0; i<iNumEntities; i++)
  {
    VisBaseEntity_cl *pEntity = EntityCollection.GetEntry(i);
    // Foreground entities will be handled separately
    if (pEntity->IsObjectAlwaysInForegroundEnabled()) continue;
    if ( pEntity->HasShadersForPass(ePassType) )
    {
      // Get a list of the corresponding pass type surface shaders
      VisShaderSet_cl *pShaderSet = pEntity->GetActiveShaderSet();
      if (pShaderSet == NULL) continue;
      int iNumSurfaceShaders = pShaderSet->GetShaderAssignmentList(SurfaceShaderList, ePassType, RLP_MAX_ENTITY_SURFACESHADERS);
      VASSERT(iNumSurfaceShaders < RLP_MAX_ENTITY_SURFACESHADERS);
      if (iNumSurfaceShaders == 0) continue;

      VDynamicMesh *pMesh = pEntity->GetMesh();

      // If the model has lit surfaces, and if the shaders makes use of the lighting information, we need to set up
      // the global lights.
      if (pMesh != NULL && pMesh->HasLitSurfaces() && (pShaderSet->GetCombinedTrackingMask()&(VSHADER_TRACKING_LIGHTGRID_PS|VSHADER_TRACKING_LIGHTGRID_GS|VSHADER_TRACKING_LIGHTGRID_VS)) )
      {
        Vision::RenderLoopHelper.TrackLightGridInfo(pEntity);
      }
      // Render the entity with the surface shader list
      Vision::RenderLoopHelper.RenderEntityWithSurfaceShaderList(pEntity, iNumSurfaceShaders, SurfaceShaderList);
    } 
  }

  Vision::RenderLoopHelper.EndEntityRendering();

} 
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:39,代码来源:VPostProcessTranslucencies.cpp


示例16: INSERT_PERF_MARKER_SCOPE

// Renders foreground entities (i.e. entities which have been flagged as "always in foreground")
void VPostProcessTranslucencies::DrawTransparentForegroundEntities(const VisEntityCollection_cl &EntityCollection)
{
  unsigned int iNumEntities = EntityCollection.GetNumEntries(); // this collection only contains foreground objects
  if (iNumEntities==0 || m_spForegroundFillPassTechnique==NULL)
    return;

  INSERT_PERF_MARKER_SCOPE("VisionRenderLoop_cl::DrawForegroundEntities");

  unsigned int i;
  const hkvMat4* pLastProj = NULL;

  Vision::RenderLoopHelper.BeginEntityRendering();
  const int iPassCount = m_spForegroundFillPassTechnique->GetShaderCount();
  for (int iPass=0;iPass<=iPassCount;iPass++) // +1 passes, where the last one is the actual material pass
  {
    for (i=0; i<iNumEntities; i++)
    {
      VisBaseEntity_cl *pEntity = EntityCollection.GetEntry(i);

      // Render only Entities that are flagged as "always in foreground"
      VASSERT_MSG(pEntity->IsObjectAlwaysInForegroundEnabled(), "Only entities with this flag should be passed to this function");

      if (pEntity->HasShadersForPass(VPT_TransparentPass))
      {
        VDynamicMesh *pMesh = pEntity->GetMesh();
        VisShaderSet_cl *pShaderSet = pEntity->GetActiveShaderSet();

        VASSERT(pMesh && pShaderSet);

        const hkvMat4* pThisProj = pEntity->GetCustomProjectionMatrixForForegroundObject();

        if (pThisProj != pLastProj)
        {
          VisRenderStates_cl::SetCurrentProjectionMatrix(pThisProj);
          pLastProj = pThisProj;
        }

        if (iPass<iPassCount) // depth fill pass
        {
          VCompiledShaderPass *pPass = m_spForegroundFillPassTechnique->GetShader(iPass);
          Vision::RenderLoopHelper.RenderEntityWithShaders(pEntity, 1, &pPass);
        }
        else // material pass
        {
          const VisDrawCallInfo_t *pAssignment;

          int iNumSurfaceShaders = pShaderSet->GetShaderAssignmentList(&pAssignment);

          // If the shaders make use of the lighting information, we need to track the light grid
          if (pMesh != NULL && pMesh->HasLitSurfaces() && 
            (pShaderSet->GetCombinedTrackingMask() & (VSHADER_TRACKING_LIGHTGRID_PS|VSHADER_TRACKING_LIGHTGRID_GS|VSHADER_TRACKING_LIGHTGRID_VS)) )
          {
            Vision::RenderLoopHelper.TrackLightGridInfo(pEntity);
          }

          // Render the entity with the surface shader list
          Vision::RenderLoopHelper.RenderEntityWithSurfaceShaderList(pEntity, iNumSurfaceShaders, pAssignment);
        }
      }
    }
  }

  Vision::RenderLoopHelper.EndEntityRendering();

  // reset to context projection matrix
  if (pLastProj)
  {
    VisRenderStates_cl::SetCurrentProjectionMatrix(NULL);
  }
}
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:71,代码来源:VPostProcessTranslucencies.cpp


示例17: SetCastShadows

void AnimatedWarrior_cl::InitFunction()
{
  SetCastShadows(TRUE);
  
  SetupAnimations();
  if (!m_bModelValid)
    return;

	m_pCharacterController = new vHavokCharacterController();
	m_pCharacterController->Initialize();

	hkvAlignedBBox bbox;
	GetMesh()->GetCollisionBoundingBox(bbox);

  float r = bbox.getSizeX() * 0.5f;
	m_pCharacterController->Capsule_Radius = r;
	m_pCharacterController->Character_Top.set(0,0,bbox.m_vMax.z - r);
  m_pCharacterController->Character_Bottom.set(0,0,bbox.m_vMin.z + r);

 	m_pCharacterController->Max_Slope = 75.0f;

  if (!m_bEnabled)
    m_pCharacterController->SetEnabled(FALSE);

	AddComponent(m_pCharacterController);

  //// setup animation system
  // create config
  VDynamicMesh* pMesh = GetMesh();
  VASSERT(pMesh);
  VisSkeleton_cl* pSkeleton = pMesh->GetSkeleton();
  VASSERT(pSkeleton);

  // create mixer structure, we keep pointers on the mixers to add and remove inputs
  m_spLayerMixer = new VisAnimLayerMixerNode_cl(pSkeleton);

  m_pNormalizeMixer = new VisAnimNormalizeMixerNode_cl(pSkeleton);
  m_spLayerMixer->AddMixerInput(m_pNormalizeMixer, 1.f);

  //// create per bone weighting list for upper body
  int iBoneCount = pSkeleton->GetBoneCount();
  float* fPerBoneWeightingList = new float[iBoneCount];
  memset(fPerBoneWeightingList, 0, sizeof(float)*iBoneCount);

  // set all bone weights above the spine to 1
  pSkeleton->SetBoneWeightRecursive(1.f, pSkeleton->GetBoneIndexByName("skeleton1:Spine"), fPerBoneWeightingList);

  int iMixerInputIndex = -1;

  for(int i=0; i<UPPERBODY_CONTROLCOUNT; i++)
  {
    m_spUpperBodyControls[i] = new VisSkeletalAnimControl_cl(pSkeleton, VSKELANIMCTRL_DEFAULTS);
    m_spUpperBodyControls[i]->AddEventListener(this); // we want to receive all events from sequence and control
    iMixerInputIndex = m_spLayerMixer->AddMixerInput(m_spUpperBodyControls[i], 0.f);
    m_spLayerMixer->ApplyPerBoneWeightingMask(iMixerInputIndex, iBoneCount, fPerBoneWeightingList);
  }
  
  V_SAFE_DELETE_ARRAY(fPerBoneWeightingList);

  // set the start animation
  BlendOverFullBodyAnimation(0.f, ANIMID_IDLE, 1.f, 0.f);
 
  SetFullBodyState(m_pFullBodyIdleState[FBSTATETYPE_NORMAL]);
  SetUpperBodyState(m_pUpperBodyIdleState);

  // initialize variables for upperbody fadein/fadeout
  m_eUpperBodyFadeState = FADESTATE_NONE;

  // setup neck bone for head rotation
  m_iHeadBoneIndex = pSkeleton->GetBoneIndexByName("skeleton1:Neck");
  m_fHeadRotationAngles[0] = 0.f; m_fHeadRotationAngles[1] = 0.f; m_fHeadRotationAngles[2] = 0.f;
  m_bHeadInMovement = false;

  // setup the torch
  hkvVec3 vDummyOrigin;
  m_pTorch = (AttachedTorch_cl *) Vision::Game.CreateEntity( "AttachedTorch_cl", vDummyOrigin );
  
  HideTorch();

  // attach the torch to the bone
  //hkvVec3 localTranslation(-11.f, -4.5f, 25.f);
  hkvVec3 localTranslation(-11.f, 5.5f, 0.f);
  float euler[3] = {90, 0, 185};
  hkvQuat localRotation;
  localRotation.setFromEulerAngles (euler[2], euler[1], euler[0]); // pass as roll, pitch, yaw
  m_pTorch->Attach(this, "skeleton1:RightHand", localRotation, localTranslation);

  SetEnabled(true);
}
开发者ID:Arpit007,项目名称:projectanarchy,代码行数:89,代码来源:AnimatedWarrior.cpp


示例18: StartAnimation

BOOL VLineFollowerComponent::StartAnimation(const char *szAnimName)
{
  VisBaseEntity_cl* pOwner = (VisBaseEntity_cl *)GetOwner();
  if (!pOwner)
    return false;

  m_bPlayingAnim = false;

  // Check for animation sequences
  VDynamicMesh *pMesh = pOwner->GetMesh();
  if (!pMesh || !pMesh->GetSequenceSetCollection() || !pMesh->GetSequenceSetCollection()->GetSequenceSetCount())
    return false;

  VisAnimFinalSkeletalResult_cl* pFinalSkeletalResult = NULL;
  VisVertexAnimDeformer_cl* pVertexAnimDeformer = NULL;

  // Get the sequence(s) for vertex and skeletal animation
  VisSkeletalAnimSequence_cl* pAnimSequenceSkeletal = (VisSkeletalAnimSequence_cl*)pMesh->GetSequence(szAnimName, VIS_MODELANIM_SKELETAL);
  VisVertexAnimSequence_cl* pAnimSequenceVertex = (VisVertexAnimSequence_cl*)pMesh->GetSequence(szAnimName, VIS_MODELANIM_VERTEX);

  // If no sequence with the given name is present
  if ((!pAnimSequenceSkeletal) && (!pAnimSequenceVertex))
  {
    VisAnimSequenceSet_cl * pSequenceSet =  pMesh->GetSequenceSetCollection()->GetSequenceSet(0);
    // Find the first skeletal or vertex animation and use it
    for (int i=0; i< pSequenceSet->GetSequenceCount(); ++i)
    {
      VisAnimSequence_cl* pTempAnimSequence = pSequenceSet->GetSequence(i);
      if (pTempAnimSequence->GetType() == VIS_MODELANIM_SKELETAL)
      {
        // If it is a skeletal animation, create a config for it
        VisAnimConfig_cl* pConfig = VisAnimConfig_cl::CreateSkeletalConfig(pMesh, &pFinalSkeletalResult);
        VisSkeletalAnimControl_cl* pSkeletalAnimControl = VisSkeletalAnimControl_cl::Create(pMesh->GetSkeleton(), (VisSkeletalAnimSequence_cl*)pTempAnimSequence, VANIMCTRL_LOOP|VSKELANIMCTRL_DEFAULTS, 1.0f, true);
        pFinalSkeletalResult->SetSkeletalAnimInput(pSkeletalAnimControl);
        pOwner->SetAnimConfig(pConfig);
        m_bPlayingAnim = true;
        return true;
      }
      else if (pTempAnimSequence->GetType() == VIS_MODELANIM_VERTEX)
      {
        // If it is a vertex animation, create a config for it
        VisAnimConfig_cl* pConfig = VisAnimConfig_cl::CreateVertexConfig(pMesh, &pVertexAnimDeformer);
        VisVertexAnimControl_cl* pVertexAnimControl = VisVertexAnimControl_cl::Create((VisVertexAnimSequence_cl*)pTempAnimSequence, VANIMCTRL_LOOP|VSKELANIMCTRL_DEFAULTS, 1.0f, true);
        pVertexAnimDeformer->AddVertexAnimControl(pVertexAnimControl, 1.0f);
        pOwner->SetAnimConfig(pConfig);
        m_bPlayingAnim = true;
        return true;
      }
    }
    // If neither a skeletal nor a vertex animation has been found, report failure
    return false;
  }

  // If both a vertex and a skeletal animation with the given name has been found
  // create a combined config for skeletal and vertex animation.
  VisAnimConfig_cl* pConfig = NULL;
  if ((pAnimSequenceSkeletal) && (pAnimSequenceVertex))
    pConfig = VisAnimConfig_cl::CreateSkeletalVertexConfig(pMesh, &pFinalSkeletalResult, &pVertexAnimDeformer);

  // If it is just a skeletal animation, create a config for it
  if (pAnimSequenceSkeletal)
  {    
    if (!pConfig)
      pConfig = VisAnimConfig_cl::CreateSkeletalConfig(pMesh, &pFinalSkeletalResult);

    // If a skeletal animation has been found create a control for it
    VisSkeletalAnimControl_cl* pSkeletalAnimControl = VisSkeletalAnimControl_cl::Create(pMesh->GetSkeleton(), pAnimSequenceSkeletal, VANIMCTRL_LOOP|VSKELANIMCTRL_DEFAULTS, 1.0f, true);
    // And set it as the input for the final skeletal result
    pFinalSkeletalResult->SetSkeletalAnimInput(pSkeletalAnimControl);
  }

  // If it is just a vertex animation, create a config for it
  if (pAnimSequenceVertex)
  {
    if (!pConfig)
      pConfig = VisAnimConfig_cl::CreateVertexConfig(pMesh, &pVertexAnimDeformer);

    // If a vertex animation has been found create a control for it
    VisVertexAnimControl_cl* pVertexAnimControl = VisVertexAnimControl_cl::Create(pAnimSequenceVertex, VANIMCTRL_LOOP|VSKELANIMCTRL_DEFAULTS, 1.0f, true);
    // And set add it to the vertex anim deformer
    pVertexAnimDeformer->AddVertexAnimControl(pVertexAnimControl, 1.0f);
  }

  // Set the current config
  pOwner->SetAnimConfig(pConfig);

  // Make sure we get the motion delta from the animation
  pOwner->GetAnimConfig()->SetFlags(pOwner->GetAnimConfig()->GetFlags() | APPLY_MOTION_DELTA | MULTITHREADED_ANIMATION);

  // And report success
  m_bPlayingAnim = true;
  return true;
}
开发者ID:Alagong,项目名称:projectanarchy,代码行数:93,代码来源:VLineFollowerComponent.cpp


示例19: SaveGame

VBool SaveGame(int iNum)
{
  if ( (iNum < 1) || (iNum > 4) )
  {
    // we just allow 4 save games
    return FALSE;
  }

  int i;
  char pszSaveFileName[FS_MAX_PATH];

  sprintf(pszSaveFileName,SAVEGAME_NAME, iNum);
  IVFileOutStream* pOut = Vision::File.Create(pszSaveFileName);
  // creating the file didn't work!
  if (!pOut)
  {
    return FALSE;
  }

  VArchive ar( pszSaveFileName, pOut, Vision::GetTypeManager() );

  // serialize global game data
  ar << ARCHIVE_START_TAG; 		      // magic number
  int iSavingVersion = Vision::GetArchiveVersion();
  ar << iSavingVersion;             // archive class version
  ar << g_iCurrentMap;              // current map number
  ar << Vision::GetTimer()->GetTime();		// current time

  // count entities
  SerializeBaseEntity_cl *pSerEnt = NULL;
  VisBaseEntity_cl *pEnt = NULL;
  int iFullCtr = 0;
  int iReCreateCtr = 0;
  int iNumOfAllEntities = VisBaseEntity_cl::ElementManagerGetSize();
  for (i = 0; i < iNumOfAllEntities; i++)
  {
    pEnt = VisBaseEntity_cl::ElementManagerGet(i);
    if ( pEnt )
    {
      if ( pEnt->IsOfType(SerializeBaseEntity_cl::GetClassTypeId()) )
      {
        pSerEnt = static_cast<SerializeBaseEntity_cl*>(pEnt);
        if ( pSerEnt->GetSerializeType() == SERIALIZE_FULL )
          iFullCtr++;
        else
          iReCreateCtr++;
      }
    }
  }

  // serialize number of entities
  ar << iReCreateCtr;
  ar << iFullCtr;

  hkvVec3 vTemp;

  // do ReCreate serialization of entities
  for (i = 0; i < iNumOfAllEntities; i++)
  {
    pEnt = VisBaseEntity_cl::ElementManagerGet(i);
    if ( pEnt )
    {
      if ( pEnt->IsOfType(SerializeBaseEntity_cl::GetClassTypeId()) )
      {
        pSerEnt = (SerializeBaseEntity_cl *) pEnt;
        if ( pSerEnt->GetSerializeType() == SERIALIZE_RECREATE )
        {
          char pszEntityParams[4000];
          GetEntityParameters( pSerEnt, pszEntityParams );
          VDynamicMesh* pMesh = pSerEnt->GetMesh();
          ar << pSerEnt->GetClassFullName() << pSerEnt->GetEntityKey();
          vTemp = pSerEnt->GetPosition();
          vTemp.SerializeAsVisVector (ar);
          vTemp = pSerEnt->GetOrientation();
          vTemp.SerializeAsVisVector (ar);
          const char *szFilename = pMesh ? pMesh->GetFilename() : NULL;
          ar << szFilename << pszEntityParams;
        }
      }
    }
  }

  // do full serialization of entities
  for (i = 0; i < iNumOfAllEntities; i++)
  {
    pEnt = VisBaseEntity_cl::ElementManagerGet(i);
    if ( pEnt )
    {
      if ( pEnt->IsOfType(SerializeBaseEntity_cl::GetClassTypeId()) )
      {
        pSerEnt = (SerializeBaseEntity_cl *) pEnt;
        if ( pSerEnt->GetSerializeType() == SERIALIZE_FULL )
        {
          ar << pSerEnt;
        }
      }
    }
  }

  // store end tag - useful to verify a valid archive
//.........这里部分代码省略.........
开发者ID:cDoru,项目名称:projectanarchy,代码行数:101,代码来源:main.cpp


示例20: vRayStart

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VEC类代码示例发布时间:2022-05-31
下一篇:
C++ VDStringW类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap