Adding Visual representation

#1
I created Area trigger now I want to add some visual representation to it.
I saw the code in default entities but i can't figure out how to implement it because i can't inherit CPhysicsPrimitiveComponent
in my Initialize function

Code: Select all

pressurePlate->SetTriggerBounds(AABB(Vec3(0.0, 0.0, 0.0), 10.f));
pressurePlate of type IEntityTriggerComponent so any idea how to do it

Re: Adding Visual representation

#2
If I understood you correctly you try to draw some sort of geometry to show the area trigger. I would recommend using the AuxGeomRenderer to draw some debug geometry. Below you can see some simple examples of what the AuxGeomRenderer can do:

Code: Select all

// This will draw a red line from the start postion to the end position gEnv->pAuxGeomRenderer->DrawLine(startPos, ColorF(1, 0, 0), endPos, ColorF(1, 0, 0)) // This will draw a bounding box in red gEnv->pAuxGeomRenderer->DrawAABB(myAABB, true, ColorF(1, 0, 0)); // This will draw a sphere at a specific position gEnv->pAuxGeomRenderer->DrawSphere(pos, 4, ColorF(1, 0, 0));
I guess you understand the concept. One important thing to mention, you have to draw those shapes every frame. The AuxGeomRenderer has pretty much every simple geometry you might need. I hope this can answer your question.

Cheers,
Alex

Re: Adding Visual representation

#4
Sure, since you have a component you can get an update event. First you have to override the GetEventMask function of your component. This will specify which events you are going to receive, for a full list of entity events go to the EEntityEvent enum. To get the update event you have to do something like this.

Code: Select all

virtual uint64 GetEventMask() const final { return BIT64(ENTITY_EVENT_UPDATE); };
Now the system knows that you want to get the update event.
In your header you have to override the process event function to receive the event.

Code: Select all

virtual void ProcessEvent(SEntityEvent& event) final;
In your cpp you can now implement the function and receive the event.

Code: Select all

void CEntityComponentTrigger::ProcessEvent(SEntityEvent& event) { switch (event.event) { case ENTITY_EVENT_UPDATE: // This will be called every frame // Do what ever you want to do here break; } }
Cheers,
Alex

Who is online

Users browsing this forum: No registered users and 2 guests