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

Method _initRender

Engine/source/environment/skySphere.cpp:316–580  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void SkySphere::_initRender()
317{
318 U32 rings = 32;
319 U32 height = 16;
320 U32 radius = 1;
321
322 F32 x, y, z, xy; // vertex position
323 F32 nx, ny, nz, lengthInv = 1.0f / radius; // normal
324 F32 s, t; // texCoord
325
326 F32 ringStep = M_2PI / rings;
327 F32 heightStep = M_PI / height; // M_HALFPI for dome.
328 F32 ringAng, heightAng;
329
330 //clear vecs
331 clearVectors();
332
333 for (U32 i = 0; i <= height; ++i)
334 {
335 heightAng = M_PI / 2 - (F32)i * heightStep;
336 F32 xy = radius * mCos(heightAng);
337 F32 z = radius * mSin(heightAng);
338
339 for (U32 j = 0; j <= rings; ++j)
340 {
341 SphereVertex vert;
342 ringAng = j * ringStep;
343 x = xy * mCos(ringAng);
344 y = xy * mSin(ringAng);
345 vert.pos.set(Point3F(x,y,z));
346
347 nx = x * lengthInv;
348 ny = y * lengthInv;
349 nz = z * lengthInv;
350 vert.nor.set(Point3F(nx, ny, nz));
351
352 s = (F32)j / rings;
353 t = (F32)i / height;
354 vert.s = s;
355 vert.t = t;
356
357 tmpVertices.push_back(vert);
358 }
359 }
360
361 SphereVertex v1, v2, v3, v4;
362 U32 vi1, vi2 = 0;
363
364 for (U32 i = 0; i < height; ++i)
365 {
366 vi1 = i * (rings + 1);
367 vi2 = (i + 1) * (rings + 1);
368
369 for (U32 j = 0; j < rings; ++j, ++vi1, ++vi2)
370 {
371 v1 = tmpVertices[vi1];
372 v2 = tmpVertices[vi2];
373 v3 = tmpVertices[vi1 + 1];

Callers

nothing calls this directly

Calls 15

mCosFunction · 0.85
mSinFunction · 0.85
allocateAndRegisterMethod · 0.80
addFeatureMethod · 0.80
Point3FClass · 0.50
addVertexFunction · 0.50
dMemcpyFunction · 0.50
setMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
isNullMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected