Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Create A Sphere

DZone's Guide to

Create A Sphere

·
Free Resource

            float lRadius = 0.85f;
            
            cMeshModeler lModeler = new cMeshModeler();
            List
  
    lLine = new Vector
   
    (1);
            lLine.add(new cVector3f(0, 0, -lRadius));
            lModeler.mSetBorderList(lModeler.mCreateNewBorder(lLine));
            
            float lH, lr;
            for (int lAlpha = -80; lAlpha < 90; lAlpha = lAlpha + 10)
            {
                lH = lRadius * (float)Math.sin(lAlpha * Math.PI / 180);
                lr = lRadius * ((float)Math.cos(lAlpha * Math.PI / 180));
                lLine = cMathUtils.mCreateCircle(new cVector3f(0,0,lH), lr, 18);
                lModeler.mSewBorderToPoints(lLine);
            }
            lLine = new Vector
    
     (1);
            lLine.add(new cVector3f(0, 0, lRadius));
            lModeler.mSewBorderToPoints(lLine);
            
            cShapeNode lShape = new cShapeNode(null);
            lModeler.mGetMesh().mInitChildrenNodes();
            lModeler.mGetMesh().mSmoothVerticesNormals(true);
            lShape.mAddSceneGraphChild(lModeler.mGetMesh());
            aSceneGraph.mAddSceneGraphChild(lShape);

    
   
  
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}