Yea, it is possible the values are local space, that would make sense. Ill
try that out. :)

Thank you.

On Fri, Aug 19, 2011 at 3:03 PM, Asher Baker <[email protected]> wrote:

> Complete guess, but is it possible the position you are getting is
> relative to the entity origin instead of world? Would explain the
> small values.
>
> On Fri, Aug 19, 2011 at 8:49 PM, Michael Kramer
> <[email protected]> wrote:
> > is pEntity of type CBaseViewModel?
> > if not, try casting pEntity to CBaseViewModel
> >
> > On Fri, Aug 19, 2011 at 12:55 PM, Ryan Sheffer <[email protected]>
> wrote:
> >>
> >> Thanks for the code, but unfortunately I need a way to get the
> attachment
> >> without using the beams attachment point stuff.
> >>
> >> On Thu, Aug 18, 2011 at 11:13 PM, Michael Kramer
> >> <[email protected]> wrote:
> >>>
> >>> When I drew a beam for one of my weapons I used the following:
> >>> pBeam->PointEntInit( endPos, this );
> >>> pBeam->SetEndAttachment( 1 );
> >>> pBeam->SetWidth( width / 4.0f );
> >>> pBeam->SetEndWidth( width );
> >>> However this was serverside code, But I did then have it also spark on
> >>> the muzzle, so I did:
> >>> CBaseViewModel *pViewModel = pOwner->GetViewModel();
> >>> pViewModel->GetAttachment(LookupAttachment("muzzle"),origin,angles);
> >>> g_pEffects->Sparks(origin);
> >>>
> >>> Below is the entire drawBeam function I used:
> >>> CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
> >>> CBaseViewModel *pViewModel = pOwner->GetViewModel();
> >>> if ( pOwner == NULL )
> >>> return;
> >>> //Check to store off our view model index
> >>> if ( pViewModel == NULL )
> >>> {
> >>> CBaseViewModel *vm = pOwner->GetViewModel();
> >>> if ( vm )
> >>> {
> >>> m_hViewModel.Set( vm );
> >>> }
> >>> }
> >>> #ifndef CLIENT_DLL
> >>> //Draw a tracer down the middle
> >>> UTIL_Tracer( startPos, endPos, 0, TRACER_DONT_USE_ATTACHMENT, 6500,
> true,
> >>> "GaussTracer" );
> >>> //Draw the main beam shaft
> >>> CBeam *pBeam = CBeam::BeamCreate( GAUSS_BEAM_SPRITE, width );
> >>> if ( useMuzzle )
> >>> {
> >>> pBeam->PointEntInit( endPos, this );
> >>> pBeam->SetEndAttachment( 1 );
> >>> pBeam->SetWidth( width / 4.0f );
> >>> pBeam->SetEndWidth( width );
> >>> }
> >>> else
> >>> {
> >>> pBeam->SetStartPos( startPos );
> >>> pBeam->SetEndPos( endPos );
> >>> pBeam->SetWidth( width );
> >>> pBeam->SetEndWidth( width / 4.0f );
> >>> }
> >>> pBeam->SetBrightness( 255 );
> >>> pBeam->SetColor( 255, 145+random->RandomInt( -16, 16 ), 0 );
> >>> pBeam->RelinkBeam();
> >>> pBeam->LiveForTime( 5.1f );
> >>>
> >>> On Thu, Aug 18, 2011 at 11:11 PM, Ryan Sheffer <[email protected]>
> >>> wrote:
> >>>>
> >>>> Hey coders!
> >>>>
> >>>> I came across a nasty little issue and I thought maybe somebody has
> come
> >>>> across this before.
> >>>> I am trying to create a client side beam from the muzzle of the
> players
> >>>> view model to where the bullet impacts, but I cannot get the
> attachment
> >>>> position for the muzzle on the view model.
> >>>>
> >>>> Here is the code I am using for getting the attachment:
> >>>>
> >>>>     int    attachment = pEntity->LookupAttachment( "muzzle" );
> >>>>     pEntity->GetAttachment( attachment, vecAttachment, angAttachment
> );
> >>>>
> >>>> pEntity is the view model.
> >>>> This is the same way I saw it done on the physcannons client side
> code.
> >>>> The position it gets appears to be somewhere close to the origin of
> the
> >>>> map but the coordinates are not exactly 0, 0, 0. One way to fix the
> position
> >>>> is to give myself a weapon_physcannon and then when I switch back to
> my gun
> >>>> the attachment position is where it should be, from the muzzle. I
> don't see
> >>>> anything special in the weapon_physcannon's code so I am baffled.
> >>>>
> >>>> Some things to note:
> >>>> - This is a client side entity, client side code
> >>>> - The attachment on the model looks fine in the model viewer
> >>>>
> >>>> So any help would be wonderful, I am just digging away at the
> debugging
> >>>> trying to find the issue but nothing sticks out, only the fact that
> having a
> >>>> physcannon at the same time fixes the problem.
> >>>>
> >>>> Here is the full code for the beam just in case:
> >>>>
> >>>> void C_WeaponSonicRifle::CreateShotBeam(void)
> >>>> {
> >>>>     CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
> >>>>
> >>>>     if ( pOwner == NULL )
> >>>>         return;
> >>>>
> >>>>     BeamInfo_t beamInfo;
> >>>>     C_BaseAnimating *pEntity = NULL;
> >>>>     trace_t tr;
> >>>>
> >>>>     Vector    vecAttachment, vecCrosshair, vecDir;
> >>>>     QAngle    angAttachment;
> >>>>
> >>>>     if ( IsCarriedByLocalPlayer() && !::input->CAM_IsThirdPerson() )
> >>>>     {
> >>>>         pEntity = pOwner->GetViewModel();
> >>>>         vecDir = pOwner->GetAutoaimVector(AUTOAIM_5DEGREES);
> >>>>     }
> >>>>     else
> >>>>     {
> >>>>         pEntity = this;
> >>>>         vecDir = pOwner->GetAutoaimVector(AUTOAIM_5DEGREES);
> >>>>     }
> >>>>
> >>>>     pEntity->PushAllowBoneAccess( true, true, "sonic rifle" );
> >>>>
> >>>>     int    attachment = pEntity->LookupAttachment( "muzzle" );
> >>>>     pEntity->GetAttachment( attachment, vecAttachment, angAttachment
> );
> >>>>
> >>>>     pEntity->PopBoneAccess( "sonic rifle" );
> >>>>
> >>>>     vecCrosshair = pOwner->Weapon_ShootPosition();
> >>>>     UTIL_TraceLine(vecCrosshair, vecCrosshair + (vecDir *
> >>>> MAX_TRACE_LENGTH), MASK_SONICBEAMS, pOwner, COLLISION_GROUP_NONE,
> &tr);
> >>>>
> >>>>     beamInfo.m_pStartEnt = NULL;
> >>>>     beamInfo.m_pEndEnt = NULL;
> >>>>
> >>>>     //beamInfo.m_nType = TE_BEAMPOINTS;
> >>>>     beamInfo.m_vecStart = tr.endpos;
> >>>>     beamInfo.m_vecEnd = vecAttachment;
> >>>>
> >>>>     beamInfo.m_nStartAttachment = NULL;
> >>>>     beamInfo.m_nEndAttachment = NULL;
> >>>>
> >>>>     beamInfo.m_pszModelName = "sprites/laserbeam.vmt";
> >>>>     beamInfo.m_flHaloScale = 0.0f;
> >>>>     beamInfo.m_flLife = 2.5f;
> >>>>
> >>>>     beamInfo.m_flWidth = 3.0f;
> >>>>     beamInfo.m_flEndWidth = 3.0f;
> >>>>
> >>>>     beamInfo.m_flFadeLength = 0.0f;
> >>>>     beamInfo.m_flAmplitude = 0;
> >>>>
> >>>>     beamInfo.m_flBrightness = 255.0;
> >>>>
> >>>>     beamInfo.m_flSpeed = 1.0f;
> >>>>     beamInfo.m_nStartFrame = 0.0;
> >>>>     beamInfo.m_flFrameRate = 30.0;
> >>>>
> >>>>     beamInfo.m_flRed = 255;
> >>>>     beamInfo.m_flGreen = 255;
> >>>>     beamInfo.m_flBlue = 255;
> >>>>
> >>>>     beamInfo.m_nSegments = 4;
> >>>>     beamInfo.m_bRenderable = true;
> >>>>     beamInfo.m_nFlags = (FBEAM_SHADEIN | FBEAM_SHADEOUT |
> >>>> FBEAM_FADEOUT);
> >>>>
> >>>>     beams->CreateBeamPoints( beamInfo );
> >>>> }
> >>>>
> >>>> Thanks guys :)
> >>>>
> >>>> --
> >>>> ~Ryan ( skidz )
> >>>>
> >>>> _______________________________________________
> >>>> To unsubscribe, edit your list preferences, or view the list archives,
> >>>> please visit:
> >>>> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >>>>
> >>>>
> >>>
> >>>
> >>> _______________________________________________
> >>> To unsubscribe, edit your list preferences, or view the list archives,
> >>> please visit:
> >>> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >>>
> >>>
> >>
> >>
> >>
> >> --
> >> ~Ryan ( skidz )
> >>
> >> _______________________________________________
> >> To unsubscribe, edit your list preferences, or view the list archives,
> >> please visit:
> >> http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >>
> >>
> >
> >
> > _______________________________________________
> > To unsubscribe, edit your list preferences, or view the list archives,
> > please visit:
> > http://list.valvesoftware.com/mailman/listinfo/hlcoders
> >
> >
> >
>
> _______________________________________________
> To unsubscribe, edit your list preferences, or view the list archives,
> please visit:
> http://list.valvesoftware.com/mailman/listinfo/hlcoders
>
>


-- 
~Ryan ( skidz )
_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to