Custom Shape in Cocos3d - objective-c

I am developing an iPhone application that uses cocos3d. My question is: how to draw custom shape in cocos3d? for example a cylinder, a cylinder with an ellipse as its base instead of a circle, a polygone, etc. Can anyone please guide me how to start?
Thanks in advance

There's good support for doing that in Cocos3D.
CC3Mesh has simple property settings for allocating space for vertex content, plus a large family of methods for getting and setting various vertex content. Make sure you understand how to use the vertexContentTypes property.
The source files CC3ParametricMeshes.m and CC3ParametricMeshNodes.m contain a number of examples of creating mesh shapes programmatically. Have a look at the implementations in those files.

Related

How to create JPEG image on iOS from scratch

I'm trying to create an objective C classe for my iPad application which can convert a powerpoint file to a jpeg file.
Accordingly i've to read into the pptx format to see how the file is structured and create an image, from scratch, in which i can say this element goes there, this one here, this text there.
But actually i've no idea how to do this, if the best way is to use a already existing framework in iOS or an additional library?
Thanks to everyone ;)
Bye
The fastest way to visualize elements is, to me, OpenGL ES. You can use mobile GPU to visualize then there is CIImage for managing image.
Take a look at Quartz 2D, the drawing engine used as the main workhorse for 2D graphics on iOS. It gives you all the primitives for drawing shapes, fills, text and other objects you need to render the presentation.

Objective C: How to use CGLayerCreate and CGContextDrawLayerAtPoint?

I am studying Core Graphics to make dynamic textures for my project.
A friend told me that i should use CGLayerCreate and CGContextDrawLayerAtPoint
to improve the texture of the brush app that i am building but i haven't found any book or tutorial that includes CGLayerCreate and CGContextDrawAtPoint.
can you guys tell what's the use of this two and how will able to code them?
also if you know any core graphics book that includes those please tell me, it'll surely help me.
thanks!
The Quartz 2D Programming Guide has a chapter that discusses CGLayer objects.
Your friend might be thinking of this use of layers, quoting that chapter:
Repeated drawing. For example, you might want to create a pattern that
consists of the same item drawn over and over. Draw the item to a
layer and then repeatedly draw the layer, as shown in Figure 12-1. Any
Quartz object that you draw repeatedly—including CGPath, CGShading,
and CGPDFPage objects—benefits from improved performance if you draw
it to a CGLayer. Note that a layer is not just for onscreen drawing;
you can use it for graphics contexts that aren’t screen-oriented, such
as a PDF graphics context.
There's also a very very simple example in the Quartz2DBasics sample app.

3D Transformations on a Quartz2D path — Drawing Application

I'm in the planning stage of writing a Cocoa drawing application (for Mac, not iOS), and I'm trying to discern whether one of my features is technically possible via any of the drawing frameworks. Any help or relevant information would be greatly appreciated.
The idea is to apply a 3D transformation to an object drawn with Quartz2D. I've considered capturing the relevant portion of the canvas View (where objects are drawn) as an image and sending it to Core Animation, but that doesn't seem like the best option. Since this is a drawing application, it's less about 3D animation than it is about the transformed shape. This solution is also less than ideal because I assume that if the 2D object were a vector path rather a bitmap image, I would have to rasterize it to apply such a transformation. The ideal implementation would enable the user to dynamically rotate a flat object in 3 dimensions until she found a suitable orientation, lock in this transformation, and still be able to manually adjust the path's vector points.
Is this feasible? Would it require working directly with OpenGL? Help of any kind is most welcome.
Thank you!
Seems to me that anything you'd do with a 3D transform, you should be able to do with multiple affine transforms. See UIBezierPath's -applyTransform method.

Simple Drawing App Design -- Hillegass Book, Ch. 18

I am working through Aaron Hillegass' Cocoa Programming for Mac OS X and am doing the challenge for Chapter 18. Basically, the challenge is to write an app that can draw ovals using your mouse, and then additionally, add saving/loading and undo support. I'm trying to think of a good class design for this app that follows MVC. Here's what I had in mind:
Have a NSView-subclass that represents an oval (say JBOval) that I can use to easily draw an oval.
Have a main view (JBDrawingView) that holds JBOvals and draws them.
The thing is that I wasn't sure how to add archiving. Should I archive each JBOval? I think this would work, but archiving an NSView doesn't seem very efficient. Any ideas on a better class design?
Thanks.
Have a NSView-subclass that represents an oval (say JBOval) that I can use to easily draw an oval.
That doesn't sound very MVC. “JBOval” sounds like a model class to me.
Have a main view (JBDrawingView) that holds JBOvals and draws them.
I do like this part.
My suggestion is to have each model object (JBOval, etc.) able to create a Bézier path representing itself. The JBDrawingView (and you should come up with a better name for that, as all views draw by definition) should ask each model object for its Bézier path, fill settings, and stroke settings, and draw the object accordingly.
This keeps the knowledge of how to draw (the path, line width, colors, etc.) in the various shape classes where they belong, while also keeping the actual drawing code in the view layer where it belongs.
The answer to where to put archiving code should be intuitively obvious from this point.
Having a whole NSView for each oval seems rather heavyweight to me. I would descend them from NSObject instead and just have them draw to the current view.
They could also know how to archive themselves, although at that point you'd probably want to think about pulling them out of the view and thinking of them more as part of your model.
Your JBOval views would each be responsible for drawing themselves (basically drawing an oval path and filling it, within their bounds), but JBDrawingView would be responsible for mousing and dragging (and thereby sizing and positioning the JBOvals, which would be its subviews). The drawingView would do no drawing itself.
So far as archiving, you could either have a model class to represent each oval (such as its bounding rectangle, or any other dimensions you choose to represent each oval with). You could archive and unarchive these models to recreate your views.
Finally, I use the JB prefix too, so … :P at you.

Is it possible to animate markers in ArcMap?

I'm completely new to ArcGIS and ArcMap, but someone suggested this program to me for a project I'm working on.
I would like to animate individual entities on a map, and was wondering if it is possible to do so in ArcMap. I asked this earlier here and a member directed me to a tutorial on animating in ArcGIS. The animation in the guide was over a map spread (ie. each pixel on the map displays, say, a different color to indicate population data in the area). However I realized that if I zoom in a lot, eventually the image will degenerate into pixels, which is why I need an actual object to mark a certain point. I checked some online tutorials and it seems like we can place markers on the map. Can someone tell me if it is possible to animate these markers (for example via a for-loop)? And if so, could you point me in a direction where to start?
Thanks in advance!
You can animate layers in ArcMap is the short answer. Its not as simple as using the timeline feature in Google Earth for example though. But then ArcMap is much more than just a visualization tool.
This help page on the ESRI web help looks like a good place to start.
I'm not 100% sure what you mean by the image degenerates into pixels. Are you saying that the markers were single points in the layer. Unlike Google Earth you are not confined to simply plotting points on the map. You can draw completely arbitrary shapes in ArcMap, which can be defined to cover actual areas of the map, so when you zoom-in the shape gets larger.
The way you need to load data into ArcMap to produce an animation isn't too simple. There might be other ways to do this, but the way I know of is to generate a NetCDF file. This file contains a 3D matrix of layer data, where each layer is separated through time. Because you generate a matrix, you are effectively placing a raster image over the map. Thus if you want to cover a large area, each matrix becomes large, and you multiply that by the number of time slices you wish to animate over.
Once you have a NetCDF file with your data in however, getting ArcMap to animate it and produce say a .avi file is pretty simple.
You could try just loading some of the example NetCDF datasets into ArcMap to see how/if they will work to get you started.
Hope that helps.
The upcoming v10 will have better time-aware capabilities, which will allow for animation.