framework2
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
12enum of3dPrimitiveType {
13OF_3D_PRIMITIVE_PLANE,
14OF_3D_PRIMITIVE_SPHERE,
15OF_3D_PRIMITIVE_ICO_SPHERE,
16OF_3D_PRIMITIVE_BOX,
17OF_3D_PRIMITIVE_CONE,
18OF_3D_PRIMITIVE_CYLINDER,
19OF_3D_PRIMITIVE_BOX_WIREFRAME
20};
21
22
23of3dGraphics::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
35ofMesh* boxWireframeMesh = boxWireframe.getMeshPtr();
36boxWireframeMesh->clear();
37boxWireframeMesh->setMode( OF_PRIMITIVE_LINES );
38
39boxWireframeMesh->addVertex({-.5f, -.5f, -.5f});
40boxWireframeMesh->addVertex({.5f, -.5f, -.5f});
41boxWireframeMesh->addVertex({.5f, .5f, -.5f});
42boxWireframeMesh->addVertex({-.5f, .5f, -.5f});
43
44boxWireframeMesh->addVertex({-.5f, -.5f, .5f});
45boxWireframeMesh->addVertex({.5f, -.5f, .5f});
46boxWireframeMesh->addVertex({.5f, .5f, .5f});
47boxWireframeMesh->addVertex({-.5f, .5f, .5f});
48
49// front face
50boxWireframeMesh->addIndex(0);
51boxWireframeMesh->addIndex(1);
52
53boxWireframeMesh->addIndex(1);
54boxWireframeMesh->addIndex(2);
55
56boxWireframeMesh->addIndex(2);
57boxWireframeMesh->addIndex(3);
58
59boxWireframeMesh->addIndex(3);
60boxWireframeMesh->addIndex(0);
61
62// back face
63boxWireframeMesh->addIndex(4);
64boxWireframeMesh->addIndex(5);
65
66boxWireframeMesh->addIndex(5);
67boxWireframeMesh->addIndex(6);
68
69boxWireframeMesh->addIndex(6);
70boxWireframeMesh->addIndex(7);
71
72boxWireframeMesh->addIndex(7);
73boxWireframeMesh->addIndex(4);
74
75
76boxWireframeMesh->addIndex(0);
77boxWireframeMesh->addIndex(4);
78
79boxWireframeMesh->addIndex(1);
80boxWireframeMesh->addIndex(5);
81
82boxWireframeMesh->addIndex(2);
83boxWireframeMesh->addIndex(6);
84
85boxWireframeMesh->addIndex(3);
86boxWireframeMesh->addIndex(7);
87
88}
89
90//----------------------------------------------------------
91void of3dGraphics::renderCached3dPrimitive( const of3dPrimitive& model ) const{
92if(renderer->getFillMode() == OF_FILLED) {
93renderer->draw(model,OF_MESH_FILL);
94} else {
95renderer->draw(model,OF_MESH_WIREFRAME);
96}
97}
98
99// Plane //
100//----------------------------------------------------------
101void of3dGraphics::setPlaneResolution( int columns, int rows ) {
102plane.setResolution(columns, rows);
103}
104
105// returns columns as x value of vector and rows as y value
106//----------------------------------------------------------
107glm::vec2 of3dGraphics::getPlaneResolution() const{
108return plane.getResolution();
109}
110
111//----------------------------------------------------------
112void of3dGraphics::drawPlane(float x, float y, float width, float height) const{
113of3dGraphics::drawPlane( x, y, 0, width, height);
114}
115
116//----------------------------------------------------------
117void of3dGraphics::drawPlane(float x, float y, float z, float width, float height) const{
118glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
119m = glm::scale(m, glm::vec3(width,height,1));
120renderer->pushMatrix();
121renderer->multMatrix(m);
122renderCached3dPrimitive( plane );
123renderer->popMatrix();
124}
125
126//----------------------------------------------------------
127void of3dGraphics::drawPlane(const glm::vec3& position, float width, float height) const{
128drawPlane(position.x,position.y,position.z,width, height);
129}
130
131//----------------------------------------------------------
132void of3dGraphics::drawPlane( float width, float height ) const{
133glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(width,height,1));
134renderer->pushMatrix();
135renderer->multMatrix(m);
136renderCached3dPrimitive( plane );
137renderer->popMatrix();
138}
139
140
141// UV SPHERE //
142//----------------------------------------------------------
143void of3dGraphics::setSphereResolution(int res) {
144if(getSphereResolution() != res) {
145sphere.setResolution(res);
146}
147}
148
149//---------------------------------------------------------
150int of3dGraphics::getSphereResolution() const{
151return sphere.getResolution();
152}
153
154//----------------------------------------------------------
155void of3dGraphics::drawSphere(float x, float y, float z, float radius) const{
156glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
157m = glm::scale(m, glm::vec3(radius,radius,radius));
158renderer->pushMatrix();
159renderer->multMatrix(m);
160renderCached3dPrimitive( sphere );
161renderer->popMatrix();
162}
163
164//----------------------------------------------------------
165void of3dGraphics::drawSphere(float x, float y, float radius) const{
166drawSphere(x, y, 0, radius);
167}
168
169//----------------------------------------------------------
170void of3dGraphics::drawSphere(const glm::vec3& position, float radius) const{
171drawSphere(position.x,position.y,position.z,radius);
172}
173
174//----------------------------------------------------------
175void of3dGraphics::drawSphere(float radius) const{
176glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,radius,radius));
177renderer->pushMatrix();
178renderer->multMatrix(m);
179renderCached3dPrimitive( sphere );
180renderer->popMatrix();
181}
182
183
184// ICO SPHERE //
185//----------------------------------------------------------
186void of3dGraphics::setIcoSphereResolution( int res ) {
187if(getIcoSphereResolution() != res) {
188icoSphere.setResolution(res);
189}
190}
191
192//----------------------------------------------------------
193int of3dGraphics::getIcoSphereResolution() const{
194return icoSphere.getResolution();
195}
196
197//----------------------------------------------------------
198void of3dGraphics::drawIcoSphere(float x, float y, float z, float radius) const{
199glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
200m = glm::scale(m, glm::vec3(radius,radius,radius));
201renderer->pushMatrix();
202renderer->multMatrix(m);
203renderCached3dPrimitive( icoSphere );
204renderer->popMatrix();
205}
206
207//----------------------------------------------------------
208void of3dGraphics::drawIcoSphere(float x, float y, float radius) const{
209drawIcoSphere(x, y, 0, radius);
210}
211
212//----------------------------------------------------------
213void of3dGraphics::drawIcoSphere(const glm::vec3& position, float radius) const{
214drawIcoSphere(position.x,position.y,position.z,radius);
215}
216
217//----------------------------------------------------------
218void of3dGraphics::drawIcoSphere(float radius) const{
219glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,radius,radius));
220renderer->pushMatrix();
221renderer->multMatrix(m);
222renderCached3dPrimitive( icoSphere );
223renderer->popMatrix();
224}
225
226
227// Cylinder //
228//----------------------------------------------------------
229void of3dGraphics::setCylinderResolution( int radiusSegments, int heightSegments, int capSegments ) {
230if(getCylinderResolution() != glm::vec3{ radiusSegments, heightSegments, capSegments }) {
231cylinder.setResolution(radiusSegments, heightSegments, capSegments);
232}
233}
234
235//----------------------------------------------------------
236glm::vec3 of3dGraphics::getCylinderResolution() const{
237return cylinder.getResolution();
238}
239
240//----------------------------------------------------------
241void of3dGraphics::drawCylinder(float x, float y, float radius, float height) const{
242drawCylinder( x, y, 0, radius, height );
243}
244
245//----------------------------------------------------------
246void of3dGraphics::drawCylinder(float x, float y, float z, float radius, float height) const{
247glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
248m = glm::scale(m, glm::vec3(radius,height,radius));
249renderer->pushMatrix();
250renderer->multMatrix(m);
251renderCached3dPrimitive( cylinder );
252renderer->popMatrix();
253}
254
255//----------------------------------------------------------
256void of3dGraphics::drawCylinder(const glm::vec3& position, float radius, float height) const{
257drawCylinder( position.x, position.y, position.z, radius, height );
258}
259
260//----------------------------------------------------------
261void of3dGraphics::drawCylinder(float radius, float height) const{
262glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,height,radius));
263renderer->pushMatrix();
264renderer->multMatrix(m);
265renderCached3dPrimitive( cylinder );
266renderer->popMatrix();
267}
268
269
270
271// CONE //
272//----------------------------------------------------------
273void of3dGraphics::setConeResolution( int radiusSegments, int heightSegments, int capSegments){
274if(getConeResolution() != glm::vec3( radiusSegments, heightSegments, capSegments )) {
275cone.setResolution(radiusSegments, heightSegments, capSegments);
276}
277}
278
279//----------------------------------------------------------
280glm::vec3 of3dGraphics::getConeResolution() const{
281return cone.getResolution();
282}
283
284//----------------------------------------------------------
285void of3dGraphics::drawCone(float x, float y, float z, float radius, float height) const{
286glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
287m = glm::scale(m, glm::vec3(radius,height,radius));
288renderer->pushMatrix();
289renderer->multMatrix(m);
290renderCached3dPrimitive( cone );
291renderer->popMatrix();
292}
293
294//----------------------------------------------------------
295void of3dGraphics::drawCone(float x, float y, float radius, float height) const{
296drawCone( x, y, 0, radius, height );
297}
298
299//----------------------------------------------------------
300void of3dGraphics::drawCone(const glm::vec3& position, float radius, float height) const{
301drawCone( position.x, position.y, position.z, radius, height );
302}
303
304//----------------------------------------------------------
305void of3dGraphics::drawCone(float radius, float height) const{
306glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(radius,height,radius));
307renderer->pushMatrix();
308renderer->multMatrix(m);
309renderCached3dPrimitive( cone );
310renderer->popMatrix();
311}
312
313
314
315// BOX //
316//----------------------------------------------------------
317void of3dGraphics::setBoxResolution( int res ) {
318setBoxResolution(res, res, res);
319}
320
321//----------------------------------------------------------
322void of3dGraphics::setBoxResolution( int resWidth, int resHeight, int resDepth ) {
323if(getBoxResolution() != glm::vec3( resWidth, resHeight, resDepth )) {
324box.setResolution(resWidth, resHeight, resDepth);
325}
326}
327
328//----------------------------------------------------------
329glm::vec3 of3dGraphics::getBoxResolution() const{
330return box.getResolution();
331}
332
333//----------------------------------------------------------
334void of3dGraphics::drawBox( float x, float y, float z, float width, float height, float depth) const{
335glm::mat4 m = glm::translate(glm::mat4(1.0), glm::vec3(x,y,z));
336m = glm::scale(m, glm::vec3(width,height,depth));
337
338renderer->pushMatrix();
339renderer->multMatrix(m);
340if(renderer->getFillMode() == OF_FILLED || box.getResolution() != glm::vec3(1,1,1)) {
341renderCached3dPrimitive( box );
342} else {
343renderCached3dPrimitive( boxWireframe );
344}
345renderer->popMatrix();
346}
347
348//----------------------------------------------------------
349void of3dGraphics::drawBox(float x, float y, float z, float size) const{
350drawBox( x, y, z, size, size, size );
351}
352
353//----------------------------------------------------------
354void of3dGraphics::drawBox(const glm::vec3& position, float width, float height, float depth) const{
355drawBox( position.x, position.y, position.z, width, height, depth );
356}
357
358//----------------------------------------------------------
359void of3dGraphics::drawBox(const glm::vec3& position, float size) const{
360drawBox( position.x, position.y, position.z, size, size, size );
361}
362
363//----------------------------------------------------------
364void of3dGraphics::drawBox(float size) const{
365drawBox( size, size, size );
366}
367
368//----------------------------------------------------------
369void of3dGraphics::drawBox( float width, float height, float depth ) const{
370drawBox(0,0,0,width,height,depth);
371}
372
373
374void of3dGraphics::drawAxis(float size) const{
375glm::mat4 m = glm::scale(glm::mat4(1.0), glm::vec3(size,size,size));
376renderer->pushMatrix();
377renderer->multMatrix(m);
378renderCached3dPrimitive( axis );
379renderer->popMatrix();
380}
381
382//--------------------------------------------------------------
383void of3dGraphics::drawGrid(float stepSize, size_t numberOfSteps, bool labels, bool x, bool y, bool z) const{
384
385ofColor c;
386ofColor prevColor = renderer->getStyle().color;
387
388if (x) {
389c.setHsb(0.0f, 200.0f, 255.0f);
390renderer->setColor(c);
391drawGridPlane(stepSize, numberOfSteps, labels);
392}
393if (y) {
394c.setHsb(255.0f / 3.0f, 200.0f, 255.0f);
395renderer->setColor(c);
396glm::mat4 m = glm::rotate(glm::mat4(1.0), glm::half_pi<float>(), glm::vec3(0,0,-1));
397renderer->pushMatrix();
398renderer->multMatrix(m);
399drawGridPlane(stepSize, numberOfSteps, labels);
400renderer->popMatrix();
401}
402if (z) {
403c.setHsb(255.0f * 2.0f / 3.0f, 200.0f, 255.0f);
404renderer->setColor(c);
405glm::mat4 m = glm::rotate(glm::mat4(1.0), glm::half_pi<float>(), glm::vec3(0,1,0));
406renderer->pushMatrix();
407renderer->multMatrix(m);
408drawGridPlane(stepSize, numberOfSteps, labels);
409renderer->popMatrix();
410}
411
412if (labels) {
413ofDrawBitmapMode mode = renderer->getStyle().drawBitmapMode;
414renderer->setColor(255, 255, 255);
415float labelPos = stepSize * (numberOfSteps + 0.5);
416renderer->setBitmapTextMode(OF_BITMAPMODE_MODEL_BILLBOARD);
417renderer->drawString("x", labelPos, 0, 0);
418renderer->drawString("y", 0, labelPos, 0);
419renderer->drawString("z", 0, 0, labelPos);
420renderer->setBitmapTextMode(mode);
421}
422renderer->setColor(prevColor);
423}
424
425
426//--------------------------------------------------------------
427void of3dGraphics::drawGridPlane(float stepSize, size_t numberOfSteps, bool labels) const{
428float scale = stepSize * numberOfSteps;
429float lineWidth = renderer->getStyle().lineWidth;
430
431for (int iDimension=0; iDimension<2; iDimension++)
432{
433for (size_t i=0; i <= numberOfSteps; i++)
434{
435float yz = i * stepSize;
436
437if (i == numberOfSteps || i == 0)
438renderer->setLineWidth(2); // central axis or cap line
439else if ( i % 2 == 0){
440renderer->setLineWidth(1.5); // major
441} else {
442renderer->setLineWidth(1); // minor
443}
444
445if (iDimension == 0 ) {
446renderer->drawLine(0, yz, -scale, 0, yz, scale);
447if (yz !=0) renderer->drawLine(0, -yz, -scale, 0, -yz, scale);
448} else {
449renderer->drawLine(0, -scale, yz, 0, scale, yz);
450if (yz !=0) renderer->drawLine(0, -scale, -yz, 0, scale, -yz);
451}
452}
453}
454renderer->setLineWidth(lineWidth);
455
456if (labels) {
457//draw numbers on axes
458ofColor prevColor = renderer->getStyle().color;
459ofDrawBitmapMode mode = renderer->getStyle().drawBitmapMode;
460
461renderer->setColor(255, 255, 255);
462renderer->setBitmapTextMode(OF_BITMAPMODE_MODEL_BILLBOARD);
463
464renderer->drawString(ofToString(0), 0, 0, 0);
465
466for (float i = 1; i <= numberOfSteps; i++)
467{
468float yz = i * stepSize;
469renderer->drawString(ofToString(yz), 0, yz, 0);
470renderer->drawString(ofToString(-yz), 0, -yz, 0);
471renderer->drawString(ofToString(yz), 0, 0, yz);
472renderer->drawString(ofToString(-yz), 0, 0, -yz);
473}
474
475renderer->setColor(prevColor);
476renderer->setBitmapTextMode(mode);
477}
478
479}
480
481//--------------------------------------------------------------
482void of3dGraphics::drawArrow(const glm::vec3& start, const glm::vec3& end, float headSize) const{
483
484//draw line
485renderer->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
488const glm::mat4 cone_rotation = glm::mat4_cast(glm::rotation(glm::vec3(0,1,0), glm::normalize(start-end)));
489const glm::mat4 cone_translation = glm::translate(end);
490const glm::mat4 cone_transform = cone_translation * cone_rotation;
491
492renderer->pushMatrix();
493renderer->multMatrix(cone_transform);
494drawCone(headSize, headSize*2.);
495renderer->popMatrix();
496}
497
498//--------------------------------------------------------------
499void of3dGraphics::drawRotationAxes(float radius, float stripWidth, int circleRes) const{
500
501ofMesh axisXMesh;
502axisXMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
503
504ofMesh axisYMesh;
505axisYMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
506
507ofMesh axisZMesh;
508axisZMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
509
510for (int j = 0; j<=circleRes; j++) {
511float x = cos(glm::two_pi<float>() * j/circleRes);
512float y = sin(glm::two_pi<float>() * j/circleRes);
513axisXMesh.addColor(ofFloatColor(ofFloatColor::red));
514axisXMesh.addVertex({-stripWidth, x*radius, y*radius});
515axisXMesh.addColor(ofFloatColor(ofFloatColor::red));
516axisXMesh.addVertex({ stripWidth, x*radius, y*radius});
517
518axisYMesh.addColor(ofFloatColor(ofFloatColor::green));
519axisYMesh.addVertex({x*radius, -stripWidth, y*radius});
520axisYMesh.addColor(ofFloatColor(ofFloatColor::green));
521axisYMesh.addVertex({x*radius, stripWidth, y*radius});
522
523axisZMesh.addColor(ofFloatColor(ofFloatColor::blue));
524axisZMesh.addVertex({x*radius, y*radius, -stripWidth});
525axisZMesh.addColor(ofFloatColor(ofFloatColor::blue));
526axisZMesh.addVertex({x*radius, y*radius, stripWidth});
527}
528
529axisXMesh.draw();
530axisYMesh.draw();
531axisZMesh.draw();
532drawAxis(radius);
533}
534
535
536//----------------------------------------------------------
537void ofSetPlaneResolution( int columns, int rows ){
538ofGetCurrentRenderer()->setPlaneResolution(columns,rows);
539}
540
541//----------------------------------------------------------
542glm::vec2 ofGetPlaneResolution(){
543return ofGetCurrentRenderer()->getPlaneResolution();
544}
545
546//----------------------------------------------------------
547void ofDrawPlane(float x, float y, float width, float height){
548ofGetCurrentRenderer()->drawPlane(x,y,width,height);
549}
550
551//----------------------------------------------------------
552void ofDrawPlane(float x, float y, float z, float width, float height){
553ofGetCurrentRenderer()->drawPlane(x,y,z,width,height);
554}
555
556//----------------------------------------------------------
557void ofDrawPlane(const glm::vec3& position, float width, float height){
558ofGetCurrentRenderer()->drawPlane(position,width,height);
559}
560
561//----------------------------------------------------------
562void ofDrawPlane( float width, float height ){
563ofGetCurrentRenderer()->drawPlane(width,height);
564}
565
566
567// UV Sphere
568//----------------------------------------------------------
569void ofSetSphereResolution(int res){
570ofGetCurrentRenderer()->setSphereResolution(res);
571}
572
573//----------------------------------------------------------
574int ofGetSphereResolution(){
575return ofGetCurrentRenderer()->getSphereResolution();
576}
577
578//----------------------------------------------------------
579void ofDrawSphere(float x, float y, float radius){
580ofGetCurrentRenderer()->drawSphere(x,y,radius);
581}
582
583//----------------------------------------------------------
584void ofDrawSphere(float x, float y, float z, float radius){
585ofGetCurrentRenderer()->drawSphere(x,y,z,radius);
586}
587
588//----------------------------------------------------------
589void ofDrawSphere(const glm::vec3& position, float radius){
590ofGetCurrentRenderer()->drawSphere(position,radius);
591}
592
593//----------------------------------------------------------
594void ofDrawSphere(float radius){
595ofGetCurrentRenderer()->drawSphere(radius);
596}
597
598
599// Ico Sphere
600//----------------------------------------------------------
601void ofSetIcoSphereResolution( int res ){
602ofGetCurrentRenderer()->setIcoSphereResolution(res);
603}
604
605//----------------------------------------------------------
606int ofGetIcoSphereResolution(){
607return ofGetCurrentRenderer()->getIcoSphereResolution();
608}
609
610//----------------------------------------------------------
611void ofDrawIcoSphere(float x, float y, float z, float radius){
612ofGetCurrentRenderer()->drawIcoSphere(x,y,z,radius);
613}
614
615//----------------------------------------------------------
616void ofDrawIcoSphere(float x, float y, float radius){
617ofGetCurrentRenderer()->drawIcoSphere(x,y,radius);
618}
619
620//----------------------------------------------------------
621void ofDrawIcoSphere(const glm::vec3& position, float radius){
622ofGetCurrentRenderer()->drawIcoSphere(position,radius);
623}
624
625//----------------------------------------------------------
626void ofDrawIcoSphere(float radius){
627ofGetCurrentRenderer()->drawIcoSphere(radius);
628}
629
630
631// Cylinder //
632//----------------------------------------------------------
633void ofSetCylinderResolution( int radiusSegments, int heightSegments, int capSegments ){
634ofGetCurrentRenderer()->setCylinderResolution(radiusSegments,heightSegments,capSegments);
635}
636
637//----------------------------------------------------------
638glm::vec3 ofGetCylinderResolution(){
639return ofGetCurrentRenderer()->getCylinderResolution();
640}
641
642//----------------------------------------------------------
643void ofDrawCylinder(float x, float y, float radius, float height){
644ofGetCurrentRenderer()->drawCylinder(x,y,radius,height);
645}
646
647//----------------------------------------------------------
648void ofDrawCylinder(float x, float y, float z, float radius, float height){
649ofGetCurrentRenderer()->drawCylinder(x,y,z,radius,height);
650}
651
652//----------------------------------------------------------
653void ofDrawCylinder(const glm::vec3& position, float radius, float height){
654ofGetCurrentRenderer()->drawCylinder(position,radius,height);
655}
656
657//----------------------------------------------------------
658void ofDrawCylinder(float radius, float height){
659ofGetCurrentRenderer()->drawCylinder(radius,height);
660}
661
662//----------------------------------------------------------
663void ofSetConeResolution( int radiusSegments, int heightSegments, int capSegments){
664ofGetCurrentRenderer()->setConeResolution(radiusSegments,heightSegments,capSegments);
665}
666
667//----------------------------------------------------------
668glm::vec3 ofGetConeResolution(){
669return ofGetCurrentRenderer()->getConeResolution();
670}
671
672//----------------------------------------------------------
673void ofDrawCone(float x, float y, float z, float radius, float height){
674ofGetCurrentRenderer()->drawCone(x,y,z,radius,height);
675}
676
677//----------------------------------------------------------
678void ofDrawCone(float x, float y, float radius, float height){
679ofGetCurrentRenderer()->drawCone(x,y,radius,height);
680}
681
682//----------------------------------------------------------
683void ofDrawCone(const glm::vec3& position, float radius, float height){
684ofGetCurrentRenderer()->drawCone(position,radius,height);
685}
686
687//----------------------------------------------------------
688void ofDrawCone(float radius, float height){
689ofGetCurrentRenderer()->drawCone(radius,height);
690}
691
692//----------------------------------------------------------
693void ofSetBoxResolution( int res ){
694ofGetCurrentRenderer()->setBoxResolution(res);
695}
696
697//----------------------------------------------------------
698void ofSetBoxResolution( int resWidth, int resHeight, int resDepth ){
699ofGetCurrentRenderer()->setBoxResolution(resWidth,resHeight,resDepth);
700}
701
702//----------------------------------------------------------
703glm::vec3 ofGetBoxResolution(){
704return ofGetCurrentRenderer()->getBoxResolution();
705}
706
707//----------------------------------------------------------
708void ofDrawBox( float x, float y, float z, float width, float height, float depth){
709ofGetCurrentRenderer()->drawBox(x,y,z,width,height,depth);
710}
711
712//----------------------------------------------------------
713void ofDrawBox(float x, float y, float z, float size){
714ofGetCurrentRenderer()->drawBox(x,y,z,size);
715}
716
717//----------------------------------------------------------
718void ofDrawBox(const glm::vec3& position, float width, float height, float depth){
719ofGetCurrentRenderer()->drawBox(position,width,height,depth);
720}
721
722//----------------------------------------------------------
723void ofDrawBox(const glm::vec3& position, float size){
724ofGetCurrentRenderer()->drawBox(position,size);
725}
726
727//----------------------------------------------------------
728void ofDrawBox(float size){
729ofGetCurrentRenderer()->drawBox(size);
730}
731
732void ofDrawBox( float width, float height, float depth ){
733ofGetCurrentRenderer()->drawBox(width,height,depth);
734}
735
736
737// Deprecated methods - for compatability with previous versions of OF //
738//----------------------------------------------------------
739void ofSphere(float x, float y, float z, float radius) {
740ofDrawSphere(x, y, z, radius);
741}
742
743//----------------------------------------------------------
744void ofSphere(float x, float y, float radius) {
745ofDrawSphere(x, y, 0, radius);
746}
747
748//----------------------------------------------------------
749void ofSphere(const glm::vec3& position, float radius) {
750ofDrawSphere(position.x,position.y,position.z,radius);
751}
752
753//----------------------------------------------------------
754void ofSphere(float radius) {
755ofDrawSphere(radius);
756}
757
758//----------------------------------------------------------
759void ofCone(float x, float y, float z, float radius, float height) {
760ofDrawCone(x, y, z, radius, height);
761}
762
763//----------------------------------------------------------
764void ofCone(float x, float y, float radius, float height) {
765ofDrawCone( x, y, 0, radius, height );
766}
767
768//----------------------------------------------------------
769void ofCone(const glm::vec3& position, float radius, float height) {
770ofDrawCone( position.x, position.y, position.z, radius, height );
771}
772
773//----------------------------------------------------------
774void ofCone(float radius, float height) {
775ofDrawCone(radius, height );
776}
777
778
779
780// deprecated methods //
781//----------------------------------------------------------
782void ofBox( float x, float y, float z, float width, float height, float depth) {
783ofDrawBox(x,y,z,width,height,depth);
784}
785
786//----------------------------------------------------------
787void ofBox(float x, float y, float z, float size) {
788ofDrawBox( x, y, z, size, size, size );
789}
790
791//----------------------------------------------------------
792void ofBox(const glm::vec3& position, float width, float height, float depth) {
793ofDrawBox( position.x, position.y, position.z, width, height, depth );
794}
795
796//----------------------------------------------------------
797void ofBox(const glm::vec3& position, float size) {
798ofDrawBox( position.x, position.y, position.z, size, size, size );
799}
800
801//----------------------------------------------------------
802void ofBox(float size) {
803ofDrawBox( size, size, size );
804}
805
806//----------------------------------------------------------
807void ofBox( float width, float height, float depth ) {
808ofDrawBox(width,height,depth);
809}
810
811
812
813
814
815
816
817
818