/////////////////////////////////////////////////////////////////////// /// Called every frame to render /////////////////////////////////////////////////////////////////////// void VCNRenderNode::Render() const { if (!mActive || !mRender) return; // Let the base class do its stuff VCNNode::Render(); // Check if we are in the view frustum if ( IsInFrustum() ) { // Trace the object being rendered //GPU_PROFILE_OBJECT_BLOCK( GetTag().c_str() ); // Tell the transform manager what the new current transform is VCNXformCore::GetInstance()->SetWorldTransform( mWorld ); VCNMaterialCore* materialCore = VCNMaterialCore::GetInstance(); // Set the current material materialCore->SelectMaterial( mMaterialID ); VCNMesh* mesh = VCNResourceCore::GetInstance()->GetResource<VCNMesh>( mMeshID ); if ( const VCND3DAnimator* anim = GetComponent<VCND3DAnimator>() ) { mesh->SetBoneTransforms( anim->GetTransformPtr() ); } VCNNode* parent = VCNNodeCore::GetInstance()->GetNode(GetParent()); VCNMaterial* material = materialCore->GetCurrentMaterial(); VCNEffectParamSet& params = material->GetEffectParamSet(); params.AddFloat(VCNTXT("Selected"), (IsSelected() || parent->IsSelected()) ? 1.0f : 0.0f); // Render the mesh VCNEffectCore::GetInstance()->RenderMesh( mMeshID, mBoundingSphere ); mesh->SetBoneTransforms( nullptr ); #if !defined( FINAL ) // Render the frame of the node if ( InputManager::GetInstance().IsKeyPressed( KEY_F ) ) { const Matrix4 nodeFrame = GetWorldTransformation(); const Vector3 center = nodeFrame.GetTranslation(); VCNRenderCore::GetInstance()->DrawLine( center, center + nodeFrame.GetXAxis().Normalized(), VCNColor(1.0f, 0.0f, 0.0f) ); VCNRenderCore::GetInstance()->DrawLine( center, center + nodeFrame.GetYAxis().Normalized(), VCNColor(0.0f, 1.0f, 0.0f) ); VCNRenderCore::GetInstance()->DrawLine( center, center + nodeFrame.GetZAxis().Normalized(), VCNColor(0.0f, 0.0f, 1.0f) ); } #endif } }
void BatchRenderer::DrawArrow( const Matrix4& arrowTransform, const FColor& color, FLOAT arrowLength, FLOAT headSize ) { mxSWIPED("Unreal Engine 3"); const Vec3D origin = arrowTransform.GetTranslation(); const Vec3D endPoint = arrowTransform.TransformVector(Vec3D( arrowLength, 0.0f, 0.0f )); const FLOAT headScale = 0.5f; const FColor& startColor = FColor::WHITE; const FColor& endColor = color; this->DrawLine3D( origin, endPoint, startColor, endColor ); this->DrawLine3D( endPoint, arrowTransform.TransformVector(Vec3D( arrowLength-headSize, +headSize*headScale, +headSize*headScale )), startColor, endColor ); this->DrawLine3D( endPoint, arrowTransform.TransformVector(Vec3D( arrowLength-headSize, +headSize*headScale, -headSize*headScale )), startColor, endColor ); this->DrawLine3D( endPoint, arrowTransform.TransformVector(Vec3D( arrowLength-headSize, -headSize*headScale, +headSize*headScale )), startColor, endColor ); this->DrawLine3D( endPoint, arrowTransform.TransformVector(Vec3D( arrowLength-headSize, -headSize*headScale, -headSize*headScale )), startColor, endColor ); }
void Draw( BatchRenderer & batchRenderer, const Matrix4& transform, const FColor& color ) { const Vec3D apex = transform.TransformVector( arrowHeadVertex ); // draw the 'stem' batchRenderer.DrawLine3D( transform.GetTranslation(), apex, FColor::WHITE, color ); // draw the arrow head for( UINT iSegment = 0 ; iSegment < AXIS_ARROW_SEGMENTS ; iSegment++ ) { const Vec3D& p0 = transform.TransformVector( arrowVertices[ iSegment ] ); const Vec3D& p1 = transform.TransformVector( arrowVertices[ iSegment + 1 ] ); // Draw the base triangle of the cone. // NOTE: no need because we disabled backface culling //batchRenderer.DrawSolidTriangle3D( p0,p1,arrowBaseVertex,color ); // Draw the top triangle of the cone. batchRenderer.DrawSolidTriangle3D( p0, p1, apex, color ); } }