How to highlight a selected obj?
by Huan Li · in Torque 3D Professional · 06/08/2009 (9:01 am) · 7 replies
I can make a SceneObject selected, then how to highlight the selected Object like AFX?
Thanks.
Thanks.
#2
I read many Lighting related codes in Torque 3D Beta 2, what i found is taht some of its lighing codes was now under construction. Some interface has not been implemented, such as setupLight and resetLights defined in LightManager which was my first attempt to cut in. My current solution was to submit a highlighted version of sunlight in sun.cpp, and switch selected-obj's renderInstance's lightinfo to it during rendering.
Hope Beta 3 or later version could give us a better working ground.
06/14/2009 (11:10 pm)
@Jessel, it seems you didn't quite get the point of my problem, but thanks anyway. Now my selected obj can be highlighted by some kind of hacky way, and surely not a good solution. I read many Lighting related codes in Torque 3D Beta 2, what i found is taht some of its lighing codes was now under construction. Some interface has not been implemented, such as setupLight and resetLights defined in LightManager which was my first attempt to cut in. My current solution was to submit a highlighted version of sunlight in sun.cpp, and switch selected-obj's renderInstance's lightinfo to it during rendering.
Hope Beta 3 or later version could give us a better working ground.
#3
06/15/2009 (1:13 am)
I think those interfaces are being taken out instead, it's legacy lighting code that doesn't apply anymore in Torque3D. That's my understanding at least.
#4
06/15/2009 (2:23 am)
@Kornard, thanks for your remind on this.
#5
06/15/2009 (2:34 am)
@Huan li, I would just applied a new skin with a highlighted material to the object I want to highlight.
#6
A better way should be set ambient light brighter before rendering, and set it back when it's over. I can see the meshRenderInst being pushed back into a static RenderList as below:
06/15/2009 (6:05 am)
@Aun, the initMaterial function would be cpu consumming, that's intolerable to a onmouseover trigger, swapping a highlighting shader would be faster, but that way you must define a customematerial for every single mesh.A better way should be set ambient light brighter before rendering, and set it back when it's over. I can see the meshRenderInst being pushed back into a static RenderList as below:
sRenderList.push_back( ri ) void TSMesh::innerRender( TSMaterialList *materials, const TSRenderState &rdata, TSVertexBufferHandle &vb )
{
...
sRenderList.push_back( ri );
...
}But where is the real drawing code, anyone knows this please post it out, thanks in advance.
#7
06/15/2009 (12:36 pm)
Use shaders to find out the projection coordinates of the objects on the camera, when mouse hovers over.. voila!
Torque Owner JesseL
Pyrotronics-Games
Assign that object to your client.selectedObject or whatever you want to name it. On the client whatever object is put in the client.selectedObject make 25% brighter. If your looking for someone to code it for you.
A Gui Reticle Hud for Target Cycling
http://www.garagegames.com/community/resources/view/13805
PsuedoCode:
function serverCmdSelectObject(%client, %obj) { %client.selectedObject = %obj; commandToClient(%client, 'selectedObj', %obj); }function clientCmdSelectedObj(%obj) { //whatever method you choose to make the object select on client //I'm sure there is a way to increase the ambient lighting I'm just not sure what it is right now. %obj.setBrightness(+25); } function whenMouseClicks(%this) { %startPosition = %this.getWorldBoxCenter(); %forwardVector = normalizeVector(%this.getForwardVector()); %endPosition = VectorScale( %forwardVector, 100 ); %endPosition = VectorAdd( %startPosition, %endPosition ); %hitObject = containerRayCast( %startPosition, %endPosition, -1, %this ); %obj = ContainerRayCast( %plyEyeT, %endPos, -1, %this); if(%obj == %this) { %obj = ContainerSearchNext(); } if(%obj == 0) { error("No Object Selected Try again!"); } commandToServer('selectObj', %obj); }