3d objects in actionscript 3 without plugins - actionscript-3

I am fairly new to actionscript and was wondering is it possible to create 3d shapes (cones, spheres, cubes) using actionscript.
I would like not to have to use a plugin.
The shapes must be 3d as I need to rotate them.

Here you will find Adobes documentation for what you are looking for:
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS7D38179D-58B9-409c-9E5C-257DDECB1A02.html
Is there any specific reason that you don't want to use 3D libraries like away3D?

I think Matej's answer does not fully cover the topic as the link he gave only describes a classic display list approach to drawing 3D objects. Depending on your needs, drawing things using classic display list can be slow, as it is not GPU accelerated. If you want to utilize your GPU you can use Stage3D APIs - that does not require any external frameworks. Here's an excellent article for starters.
And even though you can render 3D content using 'raw' Context3D, I`d recommend using a framework like Away3D or Alternativa3D. Both are open source, by the way.

Related

Is AS 3 capable of supporting a game with 600 + rotating images?

I made a simple game where squares collect crystals and bring them to a base and replicate. They are just .png images that rotate and move and yet when their number becomes greater than 500, the game starts to lag out. In Java I'm able to do a similar thing with 30,000 units. Could I be doing something wrong or is Flash just not that capable?
I'm using Flash Builder.
I get the image like this:
[Embed(source="../lib/red.png")]
public var redImgClass:Class;
public var redImg = new redImgClass();
Then I pass redImg to a "unit" class which takes an instance of "Bitmap"
I change its "rotation" and x,y members every frame.
Am I doing something wrong here?
you're not using Stage3D. If you use Starling, ND2D or write your own Stage3D wrapper you'll be able to get better performance.
You can also take a look at Jackson Dunstan's blog, this post is especially helpful: http://jacksondunstan.com/articles/2279
Another possible answer is to use blitting, that is, use a single Bitmap object to draw everything on via copyPixels(). This requires that your rotating crystal PNG be replicated into a sequence of rotated images, which you then use instead of directly changing rotation property. This approach is more performance-friendly, and does not depend on video card performance like Stage3D does.
Adobe's manual on blitting
Some discussion on blitting done by game devs
Daniel's answer is correct in that you should use the Stage3D APIs for greater performance. He didn't however mention that you should seriously consider using Starling, which wraps the Stage3D API with much easier to use classes:
Learn more about Starling here.
Example of the level of performance you could expect from Stage3D.
Starling is what you`re looking for (http://gamua.com/starling/)

Emulating Photoshop color levels in AS3

I'm making an app in which I need to make some photo effects similar to Instagram's effects. I was wondering if it's possible to somehow emulate the work of Photoshop's color levels in AS3.
I've tried using AdjustColor, ColorMatrixFilter and ColorTransform classes but desired image is very hard to achieve using those.
So does anyone have a solution easier than that? or maybe someone knows a library that I couldn't find on Google?
You should have a look at Joa's image processing library.
Have a look on this library:
http://peternitsch.net/bitmapdata.js/
This is actually implemented in Javascript, but it's based on the Flash API. All You need is there. Or i can recommend Foundation ActionScript 3.0 Image Effects by Todd Yard.
Flash API reference is another good resource for inspiration.
There is another good resource for pixel manipulation found here: http://evanw.github.com/webgl-filter/. This is done in WebGL but if your target API is still Flash, then you can easily transposed the GLSL language into Pixelbender and inject the shader
into the Flash by making reference to the pbj file.
Check Grant Skinner's TweenMax plugins, especially ColorMatrixFilter.

ActionScript 3 - Can you manipulate a 3d object using AS

I have seen tutorials on creating a 3d character in flash. Is there a way to manipulate (animate and move) this 3d character with actionscript 3? If so, could you guide me with some links?
Thanks
You will need to do a bit of reading up on a 3rd party library to help you to achieve this. One such library is Away 3D which can be used to manipulate 3d characters in Flash.
The process goes like:
Build a model in a 3D package
Load it in to away3d
I am not certain but I think animations are supported in a Collada file but its moving so fast that maybe other formats are supported. I know they were working on their own format.
Anyway if you head over there and maybe post on their forums or look at some of the examples, you should get the idea.

Is Interfacing both java.awt.Graphics2D and Html5 Canvas Context in GWT feasible?

I have a java library which heavily uses java.awt.Graphics2d.
I want to port my library to html5 canvas by using gwt.
So I'm planning to write an interface (or just a class), say common.Graphics2d,
an adapter class, say com.test.awt.Graphics2d, implements common.Graphics2d and uses java.awt.Graphics2d
and another adapter class, say com.test.gwt.Graphics2d, implements common.Graphics2d and uses com.google.gwt.canvas.dom.client.Context2d.
Then I will replace all java.awt.Graphics2d with common.Graphics2d.
So after that, my library will work on both gwt and java.
The problem here is to implement graphics2d methods, and configuration by canvas context 2d. Is it feasible to implement same functionality with canvas?
I have done a similar thing. I have an interface which represents aview and two implementations of said interface. One for Android using its android.graphics classes and a second implementations in GWT using com.google.gwt.canvas.client.Canvas.
The GWT canvas stuff seems pretty full-featured to me. You can draw shapes, display text and images, move, rotate, scale...
It probably depends on the functions you use (for instance color gradient may not be easy). for basic drawing functions, the number of methods you really need to implement is very small.
You can have a look (and reuse) classes from my jvect-clipboard package for instance (on sourceforge). Basically, all geometric methods can use the general path drawing commmand, and you are left with storing colors and the like.
Have a look for instance at the implementation for SVG or WMF output, you will see that the code is pretty simple, especially for SVG (although it doesn't cover all possibilities, in particular gradients).

Can you suggest a canvas library capable of SIMPLE 3d

What I need to do is create a simple preview of a minecraft "dude" with the correct texture applied.
I'm not concerned with complex animations (yet) or detailed lighting (yet) but I'd like to make it using canvas and not rely on WebGL(not really that widely supported yet).
What technologies would you recommend for this set of limitations?
Ah, also, I don't need to edit or save the skin or whatever, just a simple display.
THREE.js is a popular javascript 3D library, it supports both canvas and WebGL