framework2

Форк
0
809 строк · 25.8 Кб
1
//
2
//  of3dGraphics.cpp
3
//  openFrameworksLib
4
//
5
//  Created by Nick Hardeman on 9/14/12.
6
//
7
//
8

9
#include "of3dGraphics.h"
10

11

12
enum of3dPrimitiveType {
13
	OF_3D_PRIMITIVE_PLANE,
14
    OF_3D_PRIMITIVE_SPHERE,
15
    OF_3D_PRIMITIVE_ICO_SPHERE,
16
	OF_3D_PRIMITIVE_BOX,
17
	OF_3D_PRIMITIVE_CONE,
18
    OF_3D_PRIMITIVE_CYLINDER,
19
    OF_3D_PRIMITIVE_BOX_WIREFRAME
20
};
21

22

23
of3dGraphics::of3dGraphics(ofBaseRenderer * renderer)
24
:renderer(renderer)
25
,plane(1.0f, 1.0f, 6, 4)
26
,sphere(1.0f, 20)
27
,icoSphere(1.0f, 2)
28
,box(1.f, 1.f, 1.f, 1, 1, 1)
29
,cone( 1.f, 1.f, 9, 3, 2 )
30
,cylinder(1.f, 1.f, 8, 4, 2, true)
31
,boxWireframe(1.f, 1.f, 1.f )
32
,axis(ofMesh::axis())
33
{
34

35
    ofMesh* boxWireframeMesh = boxWireframe.getMeshPtr();
36
	boxWireframeMesh->clear();
37
	boxWireframeMesh->setMode( OF_PRIMITIVE_LINES );
38

39
	boxWireframeMesh->addVertex({-.5f, -.5f, -.5f});
40
	boxWireframeMesh->addVertex({.5f, -.5f, -.5f});
41
	boxWireframeMesh->addVertex({.5f, .5f, -.5f});
42
	boxWireframeMesh->addVertex({-.5f, .5f, -.5f});
43

44
	boxWireframeMesh->addVertex({-.5f, -.5f, .5f});
45
	boxWireframeMesh->addVertex({.5f, -.5f, .5f});
46
	boxWireframeMesh->addVertex({.5f, .5f, .5f});
47
	boxWireframeMesh->addVertex({-.5f, .5f, .5f});
48

49
	// front face
50
	boxWireframeMesh->addIndex(0);
51
	boxWireframeMesh->addIndex(1);
52

53
	boxWireframeMesh->addIndex(1);
54
	boxWireframeMesh->addIndex(2);
55

56
	boxWireframeMesh->addIndex(2);
57
	boxWireframeMesh->addIndex(3);
58

59
	boxWireframeMesh->addIndex(3);
60
	boxWireframeMesh->addIndex(0);
61

62
	// back face
63
	boxWireframeMesh->addIndex(4);
64
	boxWireframeMesh->addIndex(5);
65

66
	boxWireframeMesh->addIndex(5);
67
	boxWireframeMesh->addIndex(6);
68

69
	boxWireframeMesh->addIndex(6);
70
	boxWireframeMesh->addIndex(7);
71

72
	boxWireframeMesh->addIndex(7);
73
	boxWireframeMesh->addIndex(4);
74

75

76
	boxWireframeMesh->addIndex(0);
77
	boxWireframeMesh->addIndex(4);
78

79
	boxWireframeMesh->addIndex(1);
80
	boxWireframeMesh->addIndex(5);
81

82
	boxWireframeMesh->addIndex(2);
83
	boxWireframeMesh->addIndex(6);
84

85
	boxWireframeMesh->addIndex(3);
86
	boxWireframeMesh->addIndex(7);
87

88
}
89

90
//----------------------------------------------------------
91
void of3dGraphics::renderCached3dPrimitive( const of3dPrimitive& model ) const{
92
	if(renderer->getFillMode() == OF_FILLED) {
93
		renderer->draw(model,OF_MESH_FILL);
94
	} else {
95
		renderer->draw(model,OF_MESH_WIREFRAME);
96
	}
97
}
98

99
// Plane //
100
//----------------------------------------------------------
101
void of3dGraphics::setPlaneResolution( int columns, int rows ) {
102
    plane.setResolution(columns, rows);
103
}
104

105
// returns columns as x value of vector and rows as y value
106
//----------------------------------------------------------
107
glm::vec2 of3dGraphics::getPlaneResolution() const{
108
    return plane.getResolution();
109
}
110

111
//----------------------------------------------------------
112
void of3dGraphics::drawPlane(float x, float y, float width, float height) const{
113
	of3dGraphics::drawPlane( x, y, 0, width, height);
114
}
115

116
//----------------------------------------------------------
117
void of3dGraphics::drawPlane(float x, float y, float z, float width, float height) const{
118
	glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
119
	m = glm::scale(m, glm::vec3(width,height,1));
120
    renderer->pushMatrix();
121
    renderer->multMatrix(m);
122
    renderCached3dPrimitive( plane );
123
    renderer->popMatrix();
124
}
125

126
//----------------------------------------------------------
127
void of3dGraphics::drawPlane(const glm::vec3& position, float width, float height) const{
128
    drawPlane(position.x,position.y,position.z,width, height);
129
}
130

131
//----------------------------------------------------------
132
void of3dGraphics::drawPlane( float width, float height ) const{
133
	glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(width,height,1));
134
    renderer->pushMatrix();
135
    renderer->multMatrix(m);
136
    renderCached3dPrimitive( plane );
137
    renderer->popMatrix();
138
}
139

140

141
// UV SPHERE //
142
//----------------------------------------------------------
143
void of3dGraphics::setSphereResolution(int res) {
144
	if(getSphereResolution() != res) {
145
       sphere.setResolution(res);
146
    }
147
}
148

149
//---------------------------------------------------------
150
int of3dGraphics::getSphereResolution() const{
151
    return sphere.getResolution();
152
}
153

154
//----------------------------------------------------------
155
void of3dGraphics::drawSphere(float x, float y, float z, float radius) const{
156
	glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
157
	m = glm::scale(m, glm::vec3(radius,radius,radius));
158
    renderer->pushMatrix();
159
    renderer->multMatrix(m);
160
    renderCached3dPrimitive( sphere );
161
    renderer->popMatrix();
162
}
163

164
//----------------------------------------------------------
165
void of3dGraphics::drawSphere(float x, float y, float radius) const{
166
    drawSphere(x, y, 0, radius);
167
}
168

169
//----------------------------------------------------------
170
void of3dGraphics::drawSphere(const glm::vec3& position, float radius) const{
171
    drawSphere(position.x,position.y,position.z,radius);
172
}
173

174
//----------------------------------------------------------
175
void of3dGraphics::drawSphere(float radius) const{
176
	glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,radius,radius));
177
    renderer->pushMatrix();
178
    renderer->multMatrix(m);
179
    renderCached3dPrimitive( sphere );
180
    renderer->popMatrix();
181
}
182

183

184
// ICO SPHERE //
185
//----------------------------------------------------------
186
void of3dGraphics::setIcoSphereResolution( int res ) {
187
	if(getIcoSphereResolution() != res) {
188
        icoSphere.setResolution(res);
189
    }
190
}
191

192
//----------------------------------------------------------
193
int of3dGraphics::getIcoSphereResolution() const{
194
    return icoSphere.getResolution();
195
}
196

197
//----------------------------------------------------------
198
void of3dGraphics::drawIcoSphere(float x, float y, float z, float radius) const{
199
	glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
200
	m = glm::scale(m, glm::vec3(radius,radius,radius));
201
    renderer->pushMatrix();
202
    renderer->multMatrix(m);
203
    renderCached3dPrimitive( icoSphere );
204
    renderer->popMatrix();
205
}
206

207
//----------------------------------------------------------
208
void of3dGraphics::drawIcoSphere(float x, float y, float radius) const{
209
    drawIcoSphere(x, y, 0, radius);
210
}
211

212
//----------------------------------------------------------
213
void of3dGraphics::drawIcoSphere(const glm::vec3& position, float radius) const{
214
    drawIcoSphere(position.x,position.y,position.z,radius);
215
}
216

217
//----------------------------------------------------------
218
void of3dGraphics::drawIcoSphere(float radius) const{
219
	glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,radius,radius));
220
    renderer->pushMatrix();
221
    renderer->multMatrix(m);
222
    renderCached3dPrimitive( icoSphere );
223
    renderer->popMatrix();
224
}
225

226

227
// Cylinder //
228
//----------------------------------------------------------
229
void of3dGraphics::setCylinderResolution( int radiusSegments, int heightSegments, int capSegments ) {
230
	if(getCylinderResolution() != glm::vec3{ radiusSegments, heightSegments, capSegments }) {
231
        cylinder.setResolution(radiusSegments, heightSegments, capSegments);
232
    }
233
}
234

235
//----------------------------------------------------------
236
glm::vec3 of3dGraphics::getCylinderResolution() const{
237
    return cylinder.getResolution();
238
}
239

240
//----------------------------------------------------------
241
void of3dGraphics::drawCylinder(float x, float y, float radius, float height) const{
242
    drawCylinder( x, y, 0, radius, height );
243
}
244

245
//----------------------------------------------------------
246
void of3dGraphics::drawCylinder(float x, float y, float z, float radius, float height) const{
247
	glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
248
	m = glm::scale(m, glm::vec3(radius,height,radius));
249
    renderer->pushMatrix();
250
    renderer->multMatrix(m);
251
    renderCached3dPrimitive( cylinder );
252
    renderer->popMatrix();
253
}
254

255
//----------------------------------------------------------
256
void of3dGraphics::drawCylinder(const glm::vec3& position, float radius, float height) const{
257
    drawCylinder( position.x, position.y, position.z, radius, height );
258
}
259

260
//----------------------------------------------------------
261
void of3dGraphics::drawCylinder(float radius, float height) const{
262
	glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,height,radius));
263
    renderer->pushMatrix();
264
    renderer->multMatrix(m);
265
    renderCached3dPrimitive( cylinder );
266
    renderer->popMatrix();
267
}
268

269

270

271
// CONE //
272
//----------------------------------------------------------
273
void of3dGraphics::setConeResolution( int radiusSegments, int heightSegments, int capSegments){
274
	if(getConeResolution() != glm::vec3( radiusSegments, heightSegments, capSegments )) {
275
        cone.setResolution(radiusSegments, heightSegments, capSegments);
276
    }
277
}
278

279
//----------------------------------------------------------
280
glm::vec3 of3dGraphics::getConeResolution() const{
281
    return cone.getResolution();
282
}
283

284
//----------------------------------------------------------
285
void of3dGraphics::drawCone(float x, float y, float z, float radius, float height) const{
286
	glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
287
	m = glm::scale(m, glm::vec3(radius,height,radius));
288
    renderer->pushMatrix();
289
    renderer->multMatrix(m);
290
    renderCached3dPrimitive( cone );
291
    renderer->popMatrix();
292
}
293

294
//----------------------------------------------------------
295
void of3dGraphics::drawCone(float x, float y, float radius, float height) const{
296
	drawCone( x, y, 0, radius, height );
297
}
298

299
//----------------------------------------------------------
300
void of3dGraphics::drawCone(const glm::vec3& position, float radius, float height) const{
301
	drawCone( position.x, position.y, position.z, radius, height );
302
}
303

304
//----------------------------------------------------------
305
void of3dGraphics::drawCone(float radius, float height) const{
306
	glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,height,radius));
307
    renderer->pushMatrix();
308
    renderer->multMatrix(m);
309
    renderCached3dPrimitive( cone );
310
    renderer->popMatrix();
311
}
312

313

314

315
// BOX //
316
//----------------------------------------------------------
317
void of3dGraphics::setBoxResolution( int res ) {
318
    setBoxResolution(res, res, res);
319
}
320

321
//----------------------------------------------------------
322
void of3dGraphics::setBoxResolution( int resWidth, int resHeight, int resDepth ) {
323
	if(getBoxResolution() != glm::vec3( resWidth, resHeight, resDepth )) {
324
        box.setResolution(resWidth, resHeight, resDepth);
325
	}
326
}
327

328
//----------------------------------------------------------
329
glm::vec3 of3dGraphics::getBoxResolution() const{
330
    return box.getResolution();
331
}
332

333
//----------------------------------------------------------
334
void of3dGraphics::drawBox( float x, float y, float z, float width, float height, float depth) const{
335
	glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
336
	m = glm::scale(m, glm::vec3(width,height,depth));
337

338
    renderer->pushMatrix();
339
    renderer->multMatrix(m);
340
	if(renderer->getFillMode() == OF_FILLED || box.getResolution() != glm::vec3(1,1,1)) {
341
        renderCached3dPrimitive( box );
342
    } else {
343
        renderCached3dPrimitive( boxWireframe );
344
    }
345
    renderer->popMatrix();
346
}
347

348
//----------------------------------------------------------
349
void of3dGraphics::drawBox(float x, float y, float z, float size) const{
350
	drawBox( x, y, z, size, size, size );
351
}
352

353
//----------------------------------------------------------
354
void of3dGraphics::drawBox(const glm::vec3& position, float width, float height, float depth) const{
355
	drawBox( position.x, position.y, position.z, width, height, depth );
356
}
357

358
//----------------------------------------------------------
359
void of3dGraphics::drawBox(const glm::vec3& position, float size) const{
360
	drawBox( position.x, position.y, position.z, size, size, size );
361
}
362

363
//----------------------------------------------------------
364
void of3dGraphics::drawBox(float size) const{
365
	drawBox( size, size, size );
366
}
367

368
//----------------------------------------------------------
369
void of3dGraphics::drawBox( float width, float height, float depth ) const{
370
	drawBox(0,0,0,width,height,depth);
371
}
372

373

374
void of3dGraphics::drawAxis(float size) const{
375
	glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(size,size,size));
376
	renderer->pushMatrix();
377
    renderer->multMatrix(m);
378
    renderCached3dPrimitive( axis );
379
    renderer->popMatrix();
380
}
381

382
//--------------------------------------------------------------
383
void of3dGraphics::drawGrid(float stepSize, size_t numberOfSteps, bool labels, bool x, bool y, bool z) const{
384

385
	ofColor c;
386
	ofColor prevColor = renderer->getStyle().color;
387

388
	if (x) {
389
		c.setHsb(0.0f, 200.0f, 255.0f);
390
		renderer->setColor(c);
391
		drawGridPlane(stepSize, numberOfSteps, labels);
392
	}
393
	if (y) {
394
		c.setHsb(255.0f / 3.0f, 200.0f, 255.0f);
395
		renderer->setColor(c);
396
		glm::mat4 m = glm::rotate(glm::mat4(1.0), glm::half_pi<float>(), glm::vec3(0,0,-1));
397
		renderer->pushMatrix();
398
		renderer->multMatrix(m);
399
		drawGridPlane(stepSize, numberOfSteps, labels);
400
		renderer->popMatrix();
401
	}
402
	if (z) {
403
		c.setHsb(255.0f * 2.0f / 3.0f, 200.0f, 255.0f);
404
		renderer->setColor(c);
405
		glm::mat4 m = glm::rotate(glm::mat4(1.0), glm::half_pi<float>(), glm::vec3(0,1,0));
406
		renderer->pushMatrix();
407
		renderer->multMatrix(m);
408
		drawGridPlane(stepSize, numberOfSteps, labels);
409
		renderer->popMatrix();
410
	}
411

412
	if (labels) {
413
		ofDrawBitmapMode mode = renderer->getStyle().drawBitmapMode;
414
		renderer->setColor(255, 255, 255);
415
		float labelPos = stepSize * (numberOfSteps + 0.5);
416
		renderer->setBitmapTextMode(OF_BITMAPMODE_MODEL_BILLBOARD);
417
		renderer->drawString("x", labelPos, 0, 0);
418
		renderer->drawString("y", 0, labelPos, 0);
419
		renderer->drawString("z", 0, 0, labelPos);
420
		renderer->setBitmapTextMode(mode);
421
	}
422
	renderer->setColor(prevColor);
423
}
424

425

426
//--------------------------------------------------------------
427
void of3dGraphics::drawGridPlane(float stepSize, size_t numberOfSteps, bool labels) const{
428
	float scale = stepSize * numberOfSteps;
429
	float lineWidth = renderer->getStyle().lineWidth;
430

431
	for (int iDimension=0; iDimension<2; iDimension++)
432
	{
433
		for (size_t i=0; i <= numberOfSteps; i++)
434
		{
435
			float yz = i * stepSize;
436

437
			if (i == numberOfSteps || i == 0)
438
				renderer->setLineWidth(2);   // central axis or cap line
439
			else if ( i % 2 == 0){
440
				renderer->setLineWidth(1.5); // major
441
			} else {
442
				renderer->setLineWidth(1);   // minor
443
			}
444

445
			if (iDimension == 0 ) {
446
				renderer->drawLine(0, yz, -scale, 0, yz, scale);
447
				if (yz !=0) renderer->drawLine(0, -yz, -scale, 0, -yz, scale);
448
			} else {
449
				renderer->drawLine(0, -scale, yz, 0, scale, yz);
450
				if (yz !=0) renderer->drawLine(0, -scale, -yz, 0, scale, -yz);
451
			}
452
		}
453
	}
454
	renderer->setLineWidth(lineWidth);
455

456
	if (labels) {
457
		//draw numbers on axes
458
		ofColor prevColor = renderer->getStyle().color;
459
		ofDrawBitmapMode mode = renderer->getStyle().drawBitmapMode;
460

461
		renderer->setColor(255, 255, 255);
462
		renderer->setBitmapTextMode(OF_BITMAPMODE_MODEL_BILLBOARD);
463

464
		renderer->drawString(ofToString(0), 0, 0, 0);
465

466
		for (float i = 1; i <= numberOfSteps; i++)
467
		{
468
			float yz = i * stepSize;
469
			renderer->drawString(ofToString(yz), 0, yz, 0);
470
			renderer->drawString(ofToString(-yz), 0, -yz, 0);
471
			renderer->drawString(ofToString(yz), 0, 0, yz);
472
			renderer->drawString(ofToString(-yz), 0, 0, -yz);
473
		}
474

475
		renderer->setColor(prevColor);
476
		renderer->setBitmapTextMode(mode);
477
	}
478

479
}
480

481
//--------------------------------------------------------------
482
void of3dGraphics::drawArrow(const glm::vec3& start, const glm::vec3& end, float headSize) const{
483

484
	//draw line
485
	renderer->drawLine(start.x,start.y,start.z, end.x,end.y,end.z);
486

487
	// Note that `glm::rotation` requires its parameters to be normalized `glm::vec3`s
488
	const glm::mat4 cone_rotation    = glm::mat4_cast(glm::rotation(glm::vec3(0,1,0), glm::normalize(start-end)));
489
	const glm::mat4 cone_translation = glm::translate(end);
490
	const glm::mat4 cone_transform   = cone_translation * cone_rotation;
491

492
	renderer->pushMatrix();
493
	renderer->multMatrix(cone_transform);
494
    drawCone(headSize, headSize*2.);
495
    renderer->popMatrix();
496
}
497

498
//--------------------------------------------------------------
499
void of3dGraphics::drawRotationAxes(float radius, float stripWidth, int circleRes) const{
500

501
	ofMesh axisXMesh;
502
	axisXMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
503

504
	ofMesh axisYMesh;
505
	axisYMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
506

507
	ofMesh axisZMesh;
508
	axisZMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
509

510
	for (int j = 0; j<=circleRes; j++) {
511
		float x = cos(glm::two_pi<float>() * j/circleRes);
512
		float y = sin(glm::two_pi<float>() * j/circleRes);
513
		axisXMesh.addColor(ofFloatColor(ofFloatColor::red));
514
		axisXMesh.addVertex({-stripWidth, x*radius, y*radius});
515
		axisXMesh.addColor(ofFloatColor(ofFloatColor::red));
516
		axisXMesh.addVertex({ stripWidth, x*radius, y*radius});
517

518
		axisYMesh.addColor(ofFloatColor(ofFloatColor::green));
519
		axisYMesh.addVertex({x*radius, -stripWidth, y*radius});
520
		axisYMesh.addColor(ofFloatColor(ofFloatColor::green));
521
		axisYMesh.addVertex({x*radius,  stripWidth, y*radius});
522

523
		axisZMesh.addColor(ofFloatColor(ofFloatColor::blue));
524
		axisZMesh.addVertex({x*radius, y*radius, -stripWidth});
525
		axisZMesh.addColor(ofFloatColor(ofFloatColor::blue));
526
		axisZMesh.addVertex({x*radius, y*radius,  stripWidth});
527
	}
528

529
	axisXMesh.draw();
530
	axisYMesh.draw();
531
	axisZMesh.draw();
532
	drawAxis(radius);
533
}
534

535

536
//----------------------------------------------------------
537
void ofSetPlaneResolution( int columns, int rows ){
538
	ofGetCurrentRenderer()->setPlaneResolution(columns,rows);
539
}
540

541
//----------------------------------------------------------
542
glm::vec2 ofGetPlaneResolution(){
543
	return ofGetCurrentRenderer()->getPlaneResolution();
544
}
545

546
//----------------------------------------------------------
547
void ofDrawPlane(float x, float y, float width, float height){
548
	ofGetCurrentRenderer()->drawPlane(x,y,width,height);
549
}
550

551
//----------------------------------------------------------
552
void ofDrawPlane(float x, float y, float z, float width, float height){
553
	ofGetCurrentRenderer()->drawPlane(x,y,z,width,height);
554
}
555

556
//----------------------------------------------------------
557
void ofDrawPlane(const glm::vec3& position, float width, float height){
558
	ofGetCurrentRenderer()->drawPlane(position,width,height);
559
}
560

561
//----------------------------------------------------------
562
void ofDrawPlane( float width, float height ){
563
	ofGetCurrentRenderer()->drawPlane(width,height);
564
}
565

566

567
// UV Sphere
568
//----------------------------------------------------------
569
void ofSetSphereResolution(int res){
570
	ofGetCurrentRenderer()->setSphereResolution(res);
571
}
572

573
//----------------------------------------------------------
574
int ofGetSphereResolution(){
575
	return ofGetCurrentRenderer()->getSphereResolution();
576
}
577

578
//----------------------------------------------------------
579
void ofDrawSphere(float x, float y, float radius){
580
	ofGetCurrentRenderer()->drawSphere(x,y,radius);
581
}
582

583
//----------------------------------------------------------
584
void ofDrawSphere(float x, float y, float z, float radius){
585
	ofGetCurrentRenderer()->drawSphere(x,y,z,radius);
586
}
587

588
//----------------------------------------------------------
589
void ofDrawSphere(const glm::vec3& position, float radius){
590
	ofGetCurrentRenderer()->drawSphere(position,radius);
591
}
592

593
//----------------------------------------------------------
594
void ofDrawSphere(float radius){
595
	ofGetCurrentRenderer()->drawSphere(radius);
596
}
597

598

599
// Ico Sphere
600
//----------------------------------------------------------
601
void ofSetIcoSphereResolution( int res ){
602
	ofGetCurrentRenderer()->setIcoSphereResolution(res);
603
}
604

605
//----------------------------------------------------------
606
int ofGetIcoSphereResolution(){
607
	return ofGetCurrentRenderer()->getIcoSphereResolution();
608
}
609

610
//----------------------------------------------------------
611
void ofDrawIcoSphere(float x, float y, float z, float radius){
612
	ofGetCurrentRenderer()->drawIcoSphere(x,y,z,radius);
613
}
614

615
//----------------------------------------------------------
616
void ofDrawIcoSphere(float x, float y, float radius){
617
	ofGetCurrentRenderer()->drawIcoSphere(x,y,radius);
618
}
619

620
//----------------------------------------------------------
621
void ofDrawIcoSphere(const glm::vec3& position, float radius){
622
	ofGetCurrentRenderer()->drawIcoSphere(position,radius);
623
}
624

625
//----------------------------------------------------------
626
void ofDrawIcoSphere(float radius){
627
	ofGetCurrentRenderer()->drawIcoSphere(radius);
628
}
629

630

631
// Cylinder //
632
//----------------------------------------------------------
633
void ofSetCylinderResolution( int radiusSegments, int heightSegments, int capSegments ){
634
	ofGetCurrentRenderer()->setCylinderResolution(radiusSegments,heightSegments,capSegments);
635
}
636

637
//----------------------------------------------------------
638
glm::vec3 ofGetCylinderResolution(){
639
	return ofGetCurrentRenderer()->getCylinderResolution();
640
}
641

642
//----------------------------------------------------------
643
void ofDrawCylinder(float x, float y, float radius, float height){
644
	ofGetCurrentRenderer()->drawCylinder(x,y,radius,height);
645
}
646

647
//----------------------------------------------------------
648
void ofDrawCylinder(float x, float y, float z, float radius, float height){
649
	ofGetCurrentRenderer()->drawCylinder(x,y,z,radius,height);
650
}
651

652
//----------------------------------------------------------
653
void ofDrawCylinder(const glm::vec3& position, float radius, float height){
654
	ofGetCurrentRenderer()->drawCylinder(position,radius,height);
655
}
656

657
//----------------------------------------------------------
658
void ofDrawCylinder(float radius, float height){
659
	ofGetCurrentRenderer()->drawCylinder(radius,height);
660
}
661

662
//----------------------------------------------------------
663
void ofSetConeResolution( int radiusSegments, int heightSegments, int capSegments){
664
	ofGetCurrentRenderer()->setConeResolution(radiusSegments,heightSegments,capSegments);
665
}
666

667
//----------------------------------------------------------
668
glm::vec3 ofGetConeResolution(){
669
	return ofGetCurrentRenderer()->getConeResolution();
670
}
671

672
//----------------------------------------------------------
673
void ofDrawCone(float x, float y, float z, float radius, float height){
674
	ofGetCurrentRenderer()->drawCone(x,y,z,radius,height);
675
}
676

677
//----------------------------------------------------------
678
void ofDrawCone(float x, float y, float radius, float height){
679
	ofGetCurrentRenderer()->drawCone(x,y,radius,height);
680
}
681

682
//----------------------------------------------------------
683
void ofDrawCone(const glm::vec3& position, float radius, float height){
684
	ofGetCurrentRenderer()->drawCone(position,radius,height);
685
}
686

687
//----------------------------------------------------------
688
void ofDrawCone(float radius, float height){
689
	ofGetCurrentRenderer()->drawCone(radius,height);
690
}
691

692
//----------------------------------------------------------
693
void ofSetBoxResolution( int res ){
694
	ofGetCurrentRenderer()->setBoxResolution(res);
695
}
696

697
//----------------------------------------------------------
698
void ofSetBoxResolution( int resWidth, int resHeight, int resDepth ){
699
	ofGetCurrentRenderer()->setBoxResolution(resWidth,resHeight,resDepth);
700
}
701

702
//----------------------------------------------------------
703
glm::vec3 ofGetBoxResolution(){
704
	return ofGetCurrentRenderer()->getBoxResolution();
705
}
706

707
//----------------------------------------------------------
708
void ofDrawBox( float x, float y, float z, float width, float height, float depth){
709
	ofGetCurrentRenderer()->drawBox(x,y,z,width,height,depth);
710
}
711

712
//----------------------------------------------------------
713
void ofDrawBox(float x, float y, float z, float size){
714
	ofGetCurrentRenderer()->drawBox(x,y,z,size);
715
}
716

717
//----------------------------------------------------------
718
void ofDrawBox(const glm::vec3& position, float width, float height, float depth){
719
	ofGetCurrentRenderer()->drawBox(position,width,height,depth);
720
}
721

722
//----------------------------------------------------------
723
void ofDrawBox(const glm::vec3& position, float size){
724
	ofGetCurrentRenderer()->drawBox(position,size);
725
}
726

727
//----------------------------------------------------------
728
void ofDrawBox(float size){
729
	ofGetCurrentRenderer()->drawBox(size);
730
}
731

732
void ofDrawBox( float width, float height, float depth ){
733
	ofGetCurrentRenderer()->drawBox(width,height,depth);
734
}
735

736

737
// Deprecated methods - for compatability with previous versions of OF //
738
//----------------------------------------------------------
739
void ofSphere(float x, float y, float z, float radius) {
740
    ofDrawSphere(x, y, z, radius);
741
}
742

743
//----------------------------------------------------------
744
void ofSphere(float x, float y, float radius) {
745
    ofDrawSphere(x, y, 0, radius);
746
}
747

748
//----------------------------------------------------------
749
void ofSphere(const glm::vec3& position, float radius) {
750
    ofDrawSphere(position.x,position.y,position.z,radius);
751
}
752

753
//----------------------------------------------------------
754
void ofSphere(float radius) {
755
    ofDrawSphere(radius);
756
}
757

758
//----------------------------------------------------------
759
void ofCone(float x, float y, float z, float radius, float height) {
760
    ofDrawCone(x, y, z, radius, height);
761
}
762

763
//----------------------------------------------------------
764
void ofCone(float x, float y, float radius, float height) {
765
    ofDrawCone( x, y, 0, radius, height );
766
}
767

768
//----------------------------------------------------------
769
void ofCone(const glm::vec3& position, float radius, float height) {
770
    ofDrawCone( position.x, position.y, position.z, radius, height );
771
}
772

773
//----------------------------------------------------------
774
void ofCone(float radius, float height) {
775
    ofDrawCone(radius, height );
776
}
777

778

779

780
// deprecated methods //
781
//----------------------------------------------------------
782
void ofBox( float x, float y, float z, float width, float height, float depth) {
783
    ofDrawBox(x,y,z,width,height,depth);
784
}
785

786
//----------------------------------------------------------
787
void ofBox(float x, float y, float z, float size) {
788
    ofDrawBox( x, y, z, size, size, size );
789
}
790

791
//----------------------------------------------------------
792
void ofBox(const glm::vec3& position, float width, float height, float depth) {
793
    ofDrawBox( position.x, position.y, position.z, width, height, depth );
794
}
795

796
//----------------------------------------------------------
797
void ofBox(const glm::vec3& position, float size) {
798
    ofDrawBox( position.x, position.y, position.z, size, size, size );
799
}
800

801
//----------------------------------------------------------
802
void ofBox(float size) {
803
    ofDrawBox( size, size, size );
804
}
805

806
//----------------------------------------------------------
807
void ofBox( float width, float height, float depth ) {
808
    ofDrawBox(width,height,depth);
809
}
810

811

812

813

814

815

816

817

818

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.