Skip to content

Commit 4900624

Browse files
committed
Updated Docs
1 parent 306609f commit 4900624

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ This API utilizes a Utility library (found in `studios.vanish.utility`) that all
2323
The `EventHandler` class holds multiple `Method`s, and allows one to invoke all of them at the same time through the `InvokeAll(Object... obj)` method. Throughout the Matrix Graphics Engine, `EventHandler`s are created so that the end user can specify what to do when a specific event occurs. An example of such is the `OnPaint` method. When it is time to draw objects to the screen, every method in `OnPaint` are invoked, allowing the user to render their own objects.
2424
## GraphicsUnit
2525
All of Java-ME's rendering capabilities are handled in the `GraphicsUnit` class. A `GraphicsUnit` object is automatically created when using the `Window` class, and is sent for use through the OnPaint event. However, you can always create a `GraphicsUnit` object, in case you want to use the 3D capabilities without initializing a `Window`.
26-
```
26+
```java
2727
GraphicsUnit Graphics = new GraphicsUnit(Graphic, FieldOfView, Size, Resolution, FillMode, Camera, CalculateIntersections, RenderLights);
2828
```
2929
- `Graphic`: The underlining graphics used, a `Graphics2D` object in Java Swing.
@@ -36,34 +36,34 @@ GraphicsUnit Graphics = new GraphicsUnit(Graphic, FieldOfView, Size, Resolution,
3636
- `RenderLights`: Specify whether to enable light based rendering, or simply render based on object color.
3737

3838
Many of these parameters impact the way the 3D components are drawn. `GraphicsUnit` has the capability to perform many 3D calculations that are useful to rendering, but are sometimes useful when updating a scene. Therefore, a useful `GetNullGraphics` method can be found in the `Window` class, which creates a `GraphicsUnit` object without the rendering capabilities.
39-
```
39+
```java
4040
GraphicsUnit Graphics = window.GetNullGraphicsUnit();
4141
```
4242
## Getting Started
4343
Instead of manually creating a `JFrame` window, Java-ME handles it through the `Window` class. Thus, you can use Java-ME as the underlining framework for your application, as everything needed to render to the screen is already handled.
44-
```
44+
```java
4545
Window window = new Window("Java Matrix Engine", new Size(800, 600), true); //specify the name, size, and border style
4646
```
4747
The next lines initialize the graphical components that the window class uses by specifying the framerate, and shows the window. `Initialize3D` only needs to be called if you are going to render 3D components.
48-
```
48+
```java
4949
window.Initialize(60); //specify the framerate
5050
window.Initialize3D(new Size(800, 600), 1024, FillMode.Solid, false, false); //specify resolution, field of view, fill mode, calculate intersections (=false), automatically render all 3D objects
5151
window.Show();
5252
```
53-
```
53+
```java
5454
window.Initialize3D();
5555
```
5656
To draw to the screen, you need to handle the OnPaint event.
57-
```
57+
```java
5858
window.OnPaint.Add(this, "Render"); //specify the object, and the function's name
5959
```
6060
Don't forget to create the coinciding method. Remember that the method name must match the name you added to the `OnPaint` event handler. The method must also be public so that it can be accessed externally, and the parameters must correctly match the ones that the OnPaint method sends. In this case, `OnPaint` only sends one parameter.
61-
```
61+
```java
6262
public void Render(GraphicsUnit Graphics) //The Render method that will be called
6363
```
6464
## Sample Cube Application
6565
Here is a sample rotating cube application.
66-
```
66+
```java
6767
public class Program
6868
{
6969
Object3D cube = new Object3D();
@@ -118,13 +118,13 @@ Unfortunately, I never planned on releasing this when I first embarked on making
118118
Java-ME comes with a list of predefined colors. All of these colors were taken from [Rapid Tables](http://www.rapidtables.com/web/color/RGB_Color.htm).
119119
## Color Object
120120
You can create your own colors
121-
```
121+
```java
122122
Color color = new Color(255, 255, 255); //R, G, B
123123
Color color = new Color(255, 255, 255, 255); //R, G, B, A
124124
```
125125
## ColorLinearGradient
126126
Instead of a basic solid color, this color type represents a linear gradient. You can send `ColorLinearGradient` colors to any render method, and it will be draw as a gradient. To create a `ColorLinearGradient`, you must specify a couple of things.
127-
```
127+
```java
128128
ColorLinearGradient col = new ColorLinearGradient(2); //How many times are you going to change the color?
129129
col.Set(0, new Point(0, 0), Color.Black); //Where is the first color, and what is that color?
130130
col.Set(1, new Point(800, 500), Color.Blue); //Where is the second color, and what is that color?
@@ -156,13 +156,13 @@ Java-ME comes with an abstract `Shape` class, that specifies an `Intersects` and
156156
- Circle
157157

158158
You can render a rectangle by using the rectangle class.
159-
```
159+
```java
160160
Rectangle rectangle;
161161
rectangle.Initialize(Color.Black, new Point(0, 0), new Size(500, 500));
162162
rectangle.Render(Graphics);
163163
```
164164
You can do hit-detection by calling the `Intersects` method.
165-
```
165+
```java
166166
if (shape1.Intersects(shape2))
167167
{
168168
//do something special, because the objects have collided
@@ -178,28 +178,28 @@ All of the 3D methods in `GraphicsUnit` have the `D3D_` identifier before them.
178178
To render a 3D object effectively, use the `Object3D` class. This will ensure that any object rendered exactly as specified and that they will be rendered according to their Z axis, as this will automatically implement a Z Buffer. Transformations will also be self-contained, easy to manage, and fast. To create an `Object3D`, you need to specify the object's faces, and colors.
179179

180180
When creating an object, you need to specify every vertex that will be used. Identify these vertices within the vertices array object.
181-
```
181+
```java
182182
object.Vertices = new Vertex[]
183183
{
184184
//Include every single vertex here
185185
};
186186
```
187187
Next, you define a face through the Indices array object. An `Index` object takes as many integer values as it takes to define a face. It takes at minimum 4 vertices to define a face. Each integer value in `Index` corresponds to the index value of the vertex.
188-
```
188+
```java
189189
object.Indices = new Index[]
190190
{
191191
//Include every face here
192192
};
193193
```
194194
Finally, you need to define the color for each face. Note that the following condition must be met: `object.Colors.length = object.Indices.length`.
195-
```
195+
```java
196196
object.Colors = new Color[]
197197
{
198198
//Include the colors of each face here
199199
};
200200
```
201201
The following code will generate a 3D Cube.
202-
```
202+
```java
203203
Object3D object = new Object3D();
204204
object.Vertices = new Vertex[]
205205
{
@@ -220,23 +220,23 @@ obj1.Colors = new Color[]
220220
};
221221
```
222222
Finally, render the object by using the render method.
223-
```
223+
```java
224224
object.Render(Graphics); //where Graphics is a GraphicsUnit object
225225
```
226226
If in `Initialize3D`, you disable AutomaticRender, you need to manually render the 3D objects.
227-
```
227+
```java
228228
Graphics.Render(); //where Graphics is a GraphicsUnit object
229229
```
230230
Each `Object3D` object comes with variables that specify transformations.
231-
```
231+
```java
232232
object.Location = new Vertex(0, 0, 10); //translates the object
233233
object.Rotation = new Vertex(10, 10, 10); //rotates the object
234234
object.Scale = new Vertex(1, 1, 1); //scales the object. Values between 0 and 1 make it smaller, while values greater than 1 make it larger
235235
object.Revolution = new Vertex(10, 10, 10); //revolves the object around its location. Note that this only works when RevolutionRadius is specified
236236
object.RevolutionRadius = new Vertex(0, 4, 0); //specifies how to revolve the object
237237
```
238238
Java-ME comes with a special `Object3D` class called `Sphere`, which automatically generates the vertices and indices for a sphere or cylinder.
239-
```
239+
```java
240240
Object3D sphere = new Sphere(10, 10, false, Color.White); //generate a sphere with 10 by 10 definition
241241
Object3D cylinder = new Sphere(10, 10, true, Color.White); //generate a cylinder with 10 by 10 definition
242242
```

0 commit comments

Comments
 (0)