|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectchemaxon.marvin.space.GraphicComponent
chemaxon.marvin.space.SurfaceComponent
public class SurfaceComponent
Class that represents a surface defined by its vertices, normal vectors and
polygons.
Polygons can be triangles or any other shapes, but they are homogenous.
Colors can be defined to each vertex.
Normal vectors are not necessary to define,
they can be computed automatically with manuallySetNormals(true);
If primitives are not set, drawing is "direct drawing" of vertices as series
of the given primitive type.
Accepted draw properties:
Surface.DrawType -- Dot, Mesh, Solid, Transparent
Example of typical usage:
MarchingCubes mc; SurfaceComponent surface = mc.generate(); graphicScene.addComponent( surface );
SurfaceComponent surface = new SurfaceComponent(vertexCount, triangleCount); surface.putVertex( -5, -5, 0 ); surface.putVertex( -5, 5, 0 ); surface.putVertex( 5, -5, 0 ); surface.putVertex( 5, 5, 0 ); surface.putNormal( 0, 0, 1 ); surface.putNormal( 0, 0, 1 ); surface.putNormal( 0, 0, 1 ); surface.putNormal( 0, 0, 1 ); surface.putTriangle( 0, 1, 2 ); surface.putTriangle( 2, 1, 3 ); graphicScene.addComponent( surface );
Field Summary | |
---|---|
protected java.awt.Color |
color
|
protected byte[] |
color3
|
protected static java.awt.Color |
DEFAULT_COLOR
|
static int |
DOTTED_TYPE
|
static int |
FILLED_TYPE
|
static int |
MESH_TYPE
|
static int |
TRANSPARENT_TYPE
|
Fields inherited from class chemaxon.marvin.space.GraphicComponent |
---|
active, associatedComponents, boundingBox, COMPONENT_TYPE_ENTIRE, drawProperties, drawType, gl, glu, graphicCell, irm, modifiesOrigin, motionMode, mousex, mousey, name, pickedItem, RENDERING_QUALITY_HIGH, RENDERING_QUALITY_LOW, RENDERING_QUALITY_MEDIUM, renderingQuality, rm, uoid, visible |
Constructor Summary | |
---|---|
SurfaceComponent(int vertexCount)
Creates a new instance of SurfaceComponent, sets its draw type to FILLED_TYPE . |
|
SurfaceComponent(int vertexCount,
int primitiveCount)
Creates a new SurfaceComponent, sets its draw type to FILLED_TYPE . |
|
SurfaceComponent(int vertexCount,
int primitiveCount,
int primitiveType,
int primitiveNodeCount)
Creates a new SurfaceComponent, sets its draw type to FILLED_TYPE . |
Method Summary | |
---|---|
void |
clipSurface(BoundingBox bb)
The bounding box of the surface can be used to determine 6 clipping planes and clip (do not draw) parts lying outside of the box. |
void |
coloring(boolean c)
|
void |
draw()
Draws the surface if drawtype was DOTTED_TYPE or FILLED_TYPE . |
protected void |
drawRawSurface()
|
protected void |
drawSelection(int mode)
Draws the component in the given mode (usually in selection mode), the rendering mode is for checking. |
protected void |
drawSurface()
|
void |
drawTransparentPart()
Draws the surface if drawtype was MESH_TYPE or TRANSPARENT_TYPE . |
protected void |
generateRawDisplayList()
|
java.awt.Color |
getColor()
Returns the constant color of the surface. |
byte[] |
getColor3()
Returns the constant color of the surface. |
int |
getDrawType()
Returns the actual drawing type. |
int |
getNormal(int i)
Warning: for internal use only. |
int[] |
getPrimitives()
Returns the primitives (for example triangles) of the surface. |
int |
getVertexCount()
Returns the number of allocated vertices in the SurfaceComponent. |
float |
getVertexX(int i)
Returns the x coordinate of the ith vertex. |
float |
getVertexY(int i)
Returns the y coordinate of the ith vertex. |
float |
getVertexZ(int i)
Returns the z coordinate of the ith vertex. |
boolean |
hasTransparentPart()
Returns true if the drawing type is MESH_TYPE or TRANSPARENT_TYPE . |
boolean |
isClipped()
Returns true if there are clipping planes enabled that will clip part of the surface during drawing. |
void |
manuallySetNormals(boolean flag)
If this is set by true, we do not want to explicitly set normal vectors, but SurfaceComponent will compute them automatically. |
void |
onRemoveGraphicComponent()
|
void |
putColor(byte[] c)
Puts the given color to the next place. |
void |
putColorComponent(byte c)
Puts the given component (red-green-blue) of a color to the next place. |
void |
putNormal(float[] n)
Puts the given normal vector to the next place. |
void |
putNormal(float nx,
float ny,
float nz)
Puts the given normal vector to the next place. |
void |
putPolygon(int[] polygon)
Puts the given primitive to the next place. |
int |
putTriangle(int x,
int y,
int z)
Puts the given triangle to the next place. |
int |
putVertex(float[] v)
Puts the given vertex to the next place. |
int |
putVertex(float vx,
float vy,
float vz)
Puts the given vertex to the next place. |
void |
setColor(java.awt.Color c)
Sets the constant color of the surface. |
void |
setDrawing(boolean b)
|
void |
setDrawingPrimitiveType(int primitiveType)
Sets the type of drawn primitives. |
void |
setDrawingPrimitiveType(int primitiveType,
int primitiveNodeCount)
Sets the type of drawn primitives. |
void |
setDrawProperty(java.lang.String propertyName,
java.lang.String propertyValue)
This is the gate of draw properties from outside to the component. |
void |
setDrawType(java.lang.String type)
Sets the drawing type of the surface. |
void |
setExclusiveColor(byte[] exclusiveColor)
Vertices having the given color will not be drawn and also their neighbouring vertices belonging to the same primitive. |
void |
setExclusiveDrawing(boolean b)
Enables/disables exclusive drawing, see setExclusiveColor(byte[]) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DOTTED_TYPE
public static final int MESH_TYPE
public static final int FILLED_TYPE
public static final int TRANSPARENT_TYPE
protected static final java.awt.Color DEFAULT_COLOR
protected java.awt.Color color
protected byte[] color3
Constructor Detail |
---|
public SurfaceComponent(int vertexCount)
FILLED_TYPE
.
public SurfaceComponent(int vertexCount, int primitiveCount)
FILLED_TYPE
.
vertexCount
- SurfaceComponent will allocate memory for this number of vertices.primitiveCount
- SurfaceComponent will allocate memory for this number of primitives,
which are triangles by default.public SurfaceComponent(int vertexCount, int primitiveCount, int primitiveType, int primitiveNodeCount)
FILLED_TYPE
.
vertexCount
- SurfaceComponent will allocate memory for this number of vertices.primitiveCount
- SurfaceComponent will allocate memory for this number of primitives.primitiveType
- Type of drawn primitives, see also GL_TRIANGLES
,
GL_TRIANGLE_STRIP
, GL_TRIANGLE_FAN
,
GL_POLYGON
, glDrawArrays(int, int, int)
in the GL2 documentation.primitiveNodeCount
- Number of vertices in one primitive.Method Detail |
---|
public void onRemoveGraphicComponent()
onRemoveGraphicComponent
in class GraphicComponent
public void setDrawing(boolean b)
public void setDrawingPrimitiveType(int primitiveType)
setDrawingPrimitiveType(int, int)
.
primitiveType
- Type of drawn primitives, see also GL_TRIANGLES
,
GL_TRIANGLE_STRIP
, GL_TRIANGLE_FAN
,
GL_POLYGON
, glDrawArrays(int, int, int)
in the GL2 documentation.public void setDrawingPrimitiveType(int primitiveType, int primitiveNodeCount)
primitiveType
- Type of drawn primitives, see also GL_TRIANGLES
,
GL_TRIANGLE_STRIP
, GL_TRIANGLE_FAN
,
GL_POLYGON
, glDrawArrays(int, int, int)
in the GL2 documentation.primitiveNodeCount
- Number of vertices in one primitive.public int getVertexCount()
public float getVertexX(int i)
public float getVertexY(int i)
public float getVertexZ(int i)
public int putVertex(float vx, float vy, float vz)
public int putVertex(float[] v)
public int getNormal(int i)
public void putNormal(float nx, float ny, float nz)
public void putNormal(float[] n)
public void putColorComponent(byte c)
public void putColor(byte[] c)
c
- should be a byte[3]
containing red-green-blue color components.
Alpha value will be set to (byte)63
by default.public int[] getPrimitives()
public int putTriangle(int x, int y, int z)
x
- Index of the first vertex of the triangle in the vertex array.y
- Index of the second vertex of the triangle in the vertex array.z
- Index of the third vertex of the triangle in the vertex array.public void putPolygon(int[] polygon)
polygon
- Elements of the array are indices in the vertex array.public void manuallySetNormals(boolean flag)
public byte[] getColor3()
public java.awt.Color getColor()
getColor
in interface chemaxon.marvin.space.UsableObject
getColor
in class GraphicComponent
public void setColor(java.awt.Color c)
setColor
in interface chemaxon.marvin.space.UsableObject
setColor
in class GraphicComponent
public void setExclusiveColor(byte[] exclusiveColor)
exclusiveColor
- rgb components of the forbidden colorpublic void setExclusiveDrawing(boolean b)
setExclusiveColor(byte[])
.
b
- public void drawTransparentPart()
MESH_TYPE
or TRANSPARENT_TYPE
.
drawTransparentPart
in class GraphicComponent
public void draw()
DOTTED_TYPE
or FILLED_TYPE
.
draw
in class GraphicComponent
protected void drawSurface()
protected void drawRawSurface()
protected void generateRawDisplayList()
protected void drawSelection(int mode)
GraphicComponent
drawSelection
in class GraphicComponent
mode
- GL_RENDER
or GL_SELECT
public void coloring(boolean c)
public void setDrawType(java.lang.String type)
type
- can be "Dot", "Mesh", "Solid", "Transparent".public void setDrawProperty(java.lang.String propertyName, java.lang.String propertyValue)
GraphicComponent.setDrawProperty(String, String)
.
Accepts "Surface.DrawType" -- "Dot", "Mesh", "Solid", "Transparent"
setDrawProperty
in interface chemaxon.marvin.space.UsableObject
setDrawProperty
in class GraphicComponent
propertyName
- identifier of the draw propertypropertyValue
- value of the draw property as a String
public boolean hasTransparentPart()
MESH_TYPE
or TRANSPARENT_TYPE
.
hasTransparentPart
in class GraphicComponent
public int getDrawType()
DOTTED_TYPE
, MESH_TYPE
,
FILLED_TYPE
, TRANSPARENT_TYPE
.
public boolean isClipped()
public void clipSurface(BoundingBox bb)
bb
- clipping planes to be used given by one BoundingBox
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |