public class CCModel extends java.lang.Object implements CCRenderState.IVertexSource, Copyable<CCModel>
| Modifier and Type | Field and Description |
|---|---|
java.util.ArrayList<java.lang.Object> |
attributes |
static java.util.regex.Matcher |
normalMatcher |
static java.util.regex.Matcher |
polyMatcher |
static java.util.regex.Matcher |
uvwMatcher |
int |
vertexMode |
static java.util.regex.Matcher |
vertMatcher |
Vertex5[] |
verts |
int |
vp |
| Modifier | Constructor and Description |
|---|---|
protected |
CCModel(int vertexMode) |
| Modifier and Type | Method and Description |
|---|---|
CCModel |
apply(Transformation t) |
CCModel |
apply(Transformation t,
int srcpos,
int destpos,
int length)
Generates a rotated copy of verts into this model
|
CCModel |
apply(UVTransformation uvt) |
static void |
assertMatch(java.util.regex.Matcher m,
java.lang.String s) |
CCModel |
backfacedCopy() |
Cuboid6 |
bounds() |
Vector3 |
collapse() |
static CCModel |
combine(java.util.Collection<CCModel> models) |
CCModel |
computeLightCoords()
Computes the minecraft lighting coordinates for use with a LightMatrix
|
CCModel |
computeLighting(LightModel light)
Computes lighting using the normals add a light model
If the model is rotated, the lighting will no longer be valid
|
CCModel |
computeNormals() |
CCModel |
computeNormals(int start,
int length)
Computes the normals of all faces in the model.
|
CCModel |
copy() |
static void |
copy(CCModel src,
int srcpos,
CCModel dst,
int destpos,
int length)
Copies length vertices and normals
|
static CCModel |
createModel(java.util.List<Vector3> verts,
java.util.List<Vector3> uvs,
java.util.List<Vector3> normals,
int vertexMode,
java.util.List<int[]> polys) |
CCModel |
expand(int extraVerts) |
static void |
exportObj(java.util.Map<java.lang.String,CCModel> models,
java.io.PrintWriter p) |
static int |
findSide(Vector3 normal) |
static CCModel |
generateBackface(CCModel src,
int srcpos,
CCModel dst,
int destpos,
int length)
Generates copies of faces with clockwise vertices
|
CCModel |
generateBlock(int i,
Cuboid6 bounds)
Generates a box, uv mapped to be the same as a minecraft block with the same bounds
|
CCModel |
generateBlock(int i,
Cuboid6 bounds,
int mask) |
CCModel |
generateBlock(int i,
double x1,
double y1,
double z1,
double x2,
double y2,
double z2) |
CCModel |
generateBlock(int i,
double x1,
double y1,
double z1,
double x2,
double y2,
double z2,
int mask)
Generates a box, uv mapped to be the same as a minecraft block with the same bounds
|
CCModel |
generateBox(int i,
double x1,
double y1,
double z1,
double w,
double h,
double d,
double tx,
double ty,
double tw,
double th,
double f)
Each pixel corresponds to one unit of position when generating the model
|
static void |
generateSidedModels(CCModel[] models,
int side,
Vector3 point)
Generate models rotated to the other 5 sides of the block
|
static void |
generateSidedModelsH(CCModel[] models,
int side,
Vector3 point)
Generate models rotated to the other 3 horizontal of the block
|
CCModel |
generateSidedPart(int side1,
int side2,
Vector3 point,
int srcpos,
int destpos,
int length)
Generates a sided copy of verts into this model
|
CCModel |
generateSidedParts(int side,
Vector3 point)
Generates sided copies of vertices into this model.
|
CCModel |
generateSidedPartsH(int side,
Vector3 point)
Generates sided copies of vertices into this model.
|
<T> T |
getAttributes(CCRenderState.VertexAttribute<T> attr)
Gets an array of vertex attrutes
|
<T> T |
getOrAllocate(CCRenderState.VertexAttribute<T> attrib) |
Vertex5[] |
getVertices() |
boolean |
hasAttribute(CCRenderState.VertexAttribute<?> attrib) |
static void |
illegalAssert(boolean b,
java.lang.String err) |
static CCModel |
newModel(int vertexMode) |
static CCModel |
newModel(int vertexMode,
int numVerts) |
Vector3[] |
normals() |
static double[] |
parseDoubles(java.lang.String s,
java.lang.String token) |
static java.util.Map<java.lang.String,CCModel> |
parseObjModels(java.io.InputStream input,
int vertexMode,
Transformation coordSystem)
Parses vertices, texture coords, normals and polygons from a WaveFront Obj file
|
static java.util.Map<java.lang.String,CCModel> |
parseObjModels(ResourceLocation res)
Parses vertices, texture coords, normals and polygons from a WaveFront Obj file
|
static java.util.Map<java.lang.String,CCModel> |
parseObjModels(ResourceLocation res,
int vertexMode,
Transformation coordSystem)
Parses vertices, texture coords, normals and polygons from a WaveFront Obj file
|
static java.util.Map<java.lang.String,CCModel> |
parseObjModels(ResourceLocation res,
Transformation coordSystem)
Parses vertices, texture coords, normals and polygons from a WaveFront Obj file
|
void |
prepareVertex()
Callback to set CCRenderState for a vertex before the pipeline runs
|
static CCModel |
quadModel(int numVerts) |
static void |
quadulate(java.util.List<int[]> polys,
int[][] polyVerts) |
void |
render(CCRenderState.IVertexOperation... ops) |
void |
render(double x,
double y,
double z,
double u,
double v) |
void |
render(double x,
double y,
double z,
UVTransformation u) |
void |
render(int start,
int end,
CCRenderState.IVertexOperation... ops)
Renders vertices start through start+length-1 of the model
|
void |
render(Transformation t,
double u,
double v) |
CCModel |
setColour(int c) |
CCModel |
shrinkUVs(double d)
Brings the UV coordinates of each face closer to the center UV by d.
|
CCModel |
sidedCopy(int side1,
int side2,
Vector3 point) |
CCModel |
smoothNormals()
Averages all normals at the same position to produce a smooth lighting effect.
|
static void |
triangulate(java.util.List<int[]> polys,
int[][] polyVerts) |
static CCModel |
triModel(int numVerts) |
CCModel |
twoFacedCopy() |
CCModel |
zOffset(Cuboid6 offsets) |
public final int vertexMode
public final int vp
public Vertex5[] verts
public java.util.ArrayList<java.lang.Object> attributes
public static final java.util.regex.Matcher vertMatcher
public static final java.util.regex.Matcher uvwMatcher
public static final java.util.regex.Matcher normalMatcher
public static final java.util.regex.Matcher polyMatcher
public Vector3[] normals()
public Vertex5[] getVertices()
getVertices in interface CCRenderState.IVertexSourcepublic <T> T getAttributes(CCRenderState.VertexAttribute<T> attr)
CCRenderState.IVertexSourcegetAttributes in interface CCRenderState.IVertexSourceT - The attrute array typeattr - The vertex attrute to getpublic boolean hasAttribute(CCRenderState.VertexAttribute<?> attrib)
hasAttribute in interface CCRenderState.IVertexSourcepublic void prepareVertex()
CCRenderState.IVertexSourceprepareVertex in interface CCRenderState.IVertexSourcepublic <T> T getOrAllocate(CCRenderState.VertexAttribute<T> attrib)
public CCModel generateBox(int i, double x1, double y1, double z1, double w, double h, double d, double tx, double ty, double tw, double th, double f)
i - Vertex index to start generating atx1 - The minX bound of the boxy1 - The minY bound of the boxz1 - The minZ bound of the boxw - The width of the boxh - The height of the boxd - The depth of the boxtx - The distance of the top left corner of the texture map from the left in pixelsty - The distance of the top left corner of the texture map from the top in pixelstw - The width of the texture in pixelsth - The height of the texture in pixelsf - The scale of the model, pixels per block, normally 16public CCModel generateBlock(int i, Cuboid6 bounds)
i - The vertex index to start generating atbounds - The bounds of the block, 0 to 1public CCModel generateBlock(int i, double x1, double y1, double z1, double x2, double y2, double z2)
public CCModel generateBlock(int i, double x1, double y1, double z1, double x2, double y2, double z2, int mask)
i - The vertex index to start generating atx1 - minXy1 - minYz1 - minZx2 - maxXy2 - maxYz2 - maxZmask - A bitmask of sides NOT to generate. I high bit at index s means side s will not be generatedpublic CCModel computeNormals()
public CCModel computeNormals(int start, int length)
start - The first vertex to generate normals forlength - The number of vertices to generate normals for. Note this must be a multiple of 3 for triangles or 4 for quadspublic CCModel computeLighting(LightModel light)
public CCModel setColour(int c)
public CCModel computeLightCoords()
public CCModel smoothNormals()
public CCModel apply(Transformation t)
public CCModel apply(UVTransformation uvt)
public CCModel expand(int extraVerts)
public void render(double x,
double y,
double z,
double u,
double v)
public void render(double x,
double y,
double z,
UVTransformation u)
public void render(Transformation t, double u, double v)
public void render(CCRenderState.IVertexOperation... ops)
public void render(int start,
int end,
CCRenderState.IVertexOperation... ops)
start - The first vertex index to renderend - The vertex index to render untilops - Operations to applypublic static CCModel quadModel(int numVerts)
public static CCModel triModel(int numVerts)
public static CCModel newModel(int vertexMode, int numVerts)
public static CCModel newModel(int vertexMode)
public static double[] parseDoubles(java.lang.String s,
java.lang.String token)
public static void illegalAssert(boolean b,
java.lang.String err)
public static void assertMatch(java.util.regex.Matcher m,
java.lang.String s)
public static java.util.Map<java.lang.String,CCModel> parseObjModels(java.io.InputStream input, int vertexMode, Transformation coordSystem) throws java.io.IOException
input - An input stream to a obj filevertexMode - The vertex mode to create the model for (GL_TRIANGLES or GL_QUADS)coordSystem - The cooridnate system transformation to applyjava.io.IOExceptionpublic static void triangulate(java.util.List<int[]> polys,
int[][] polyVerts)
public static void quadulate(java.util.List<int[]> polys,
int[][] polyVerts)
public static java.util.Map<java.lang.String,CCModel> parseObjModels(ResourceLocation res)
res - The resource for the obj filepublic static java.util.Map<java.lang.String,CCModel> parseObjModels(ResourceLocation res, Transformation coordSystem)
res - The resource for the obj filecoordSystem - The cooridnate system transformation to applypublic static java.util.Map<java.lang.String,CCModel> parseObjModels(ResourceLocation res, int vertexMode, Transformation coordSystem)
res - The resource for the obj filevertexMode - The vertex mode to create the model for (GL_TRIANGLES or GL_QUADS)coordSystem - The cooridnate system transformation to applypublic static CCModel createModel(java.util.List<Vector3> verts, java.util.List<Vector3> uvs, java.util.List<Vector3> normals, int vertexMode, java.util.List<int[]> polys)
public static void exportObj(java.util.Map<java.lang.String,CCModel> models, java.io.PrintWriter p)
public CCModel shrinkUVs(double d)
public CCModel sidedCopy(int side1, int side2, Vector3 point)
side1 - The side of this modelside2 - The side of the new modelpoint - The point to rotate aroundpublic static void copy(CCModel src, int srcpos, CCModel dst, int destpos, int length)
public static void generateSidedModels(CCModel[] models, int side, Vector3 point)
models - An array of 6 modelsside - The side of this modelpoint - The rotation pointpublic static void generateSidedModelsH(CCModel[] models, int side, Vector3 point)
models - An array of 4 modelsside - The side of this modelpoint - The rotation pointpublic CCModel backfacedCopy()
public static CCModel generateBackface(CCModel src, int srcpos, CCModel dst, int destpos, int length)
public CCModel generateSidedParts(int side, Vector3 point)
public CCModel generateSidedPartsH(int side, Vector3 point)
public CCModel generateSidedPart(int side1, int side2, Vector3 point, int srcpos, int destpos, int length)
public CCModel apply(Transformation t, int srcpos, int destpos, int length)
public CCModel twoFacedCopy()
public Vector3 collapse()
public static int findSide(Vector3 normal)
public Cuboid6 bounds()