MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / renderObject

Method renderObject

Engine/source/T3D/physicalZone.cpp:261–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259
260
261void PhysicalZone::renderObject(ObjectRenderInst *ri,
262 SceneRenderState *state,
263 BaseMatInstance *overrideMat)
264{
265 if (overrideMat)
266 return;
267
268 GFXStateBlockDesc desc;
269 desc.setZReadWrite(true, false);
270 desc.setBlend(true);
271 desc.setCullMode(GFXCullNone);
272
273 GFXTransformSaver saver;
274
275 GFXDrawUtil *drawer = GFX->getDrawUtil();
276
277 Point3F start = getBoxCenter();
278 Box3F obb = mObjBox; //object bounding box
279
280 F32 baseForce = 10000; //roughly the ammount of force needed to push a player back as it walks into a zone. (used for visual scaling)
281
282 Point3F forceDir = getForce(&start);
283 F32 forceLen = forceDir.len()/ baseForce;
284 forceDir.normalizeSafe();
285 ColorI guideCol = LinearColorF(mFabs(forceDir.x), mFabs(forceDir.y), mFabs(forceDir.z), 0.125).toColorI();
286
287 if (force_type == VECTOR)
288 {
289 Point3F endPos = start + (forceDir * mMax(forceLen,0.75f));
290 drawer->drawArrow(desc, start, endPos, guideCol, 0.05f);
291 }
292
293 MatrixF mat = getRenderTransform();
294 mat.scale(getScale());
295
296 GFX->multWorld(mat);
297 start = obb.getCenter();
298
299 if (force_type == VECTOR)
300 {
301 drawer->drawPolyhedron(desc, mPolyhedron, ColorI(0, 255, 0, 45));
302 }
303 else if (force_type == SPHERICAL)
304 {
305 F32 rad = obb.getBoundingSphere().radius/ 2;
306 drawer->drawSphere(desc, rad, start, ColorI(0, 255, 0, 45));
307
308 rad = (rad + (mAppliedForce.most() / baseForce))/2;
309 desc.setFillModeWireframe();
310 drawer->drawSphere(desc, rad, start, ColorI(0, 0, 255, 255));
311 }
312 else
313 {
314 Point3F bottomPos = start;
315 bottomPos.z -= obb.len_z() / 2;
316
317 Point3F topPos = start;
318 topPos.z += obb.len_z() / 2;

Callers

nothing calls this directly

Calls 15

mFabsFunction · 0.85
mMaxFunction · 0.85
setZReadWriteMethod · 0.80
setBlendMethod · 0.80
setCullModeMethod · 0.80
getDrawUtilMethod · 0.80
toColorIMethod · 0.80
drawArrowMethod · 0.80
multWorldMethod · 0.80
mostMethod · 0.80
setFillModeWireframeMethod · 0.80
LinearColorFClass · 0.50

Tested by

no test coverage detected