/** * @param in * @return * @throws IOException */ private PrototypeReference readPrototypeReference( DataInputStream in ) throws IOException { String id = in.readUTF(); float width = in.readFloat(); float height = in.readFloat(); float depth = in.readFloat(); float angle = in.readFloat(); float[] location = new float[3]; location[0] = in.readFloat(); location[1] = in.readFloat(); location[2] = in.readFloat(); return new PrototypeReference( id, angle, location, width, height, depth ); }
/** * @param prototypeReference * @param out * @throws IOException */ private void write( PrototypeReference prototypeReference, DataOutputStream out ) throws IOException { out.writeUTF( prototypeReference.getPrototypeID() ); out.writeFloat( prototypeReference.getWidth() ); out.writeFloat( prototypeReference.getHeight() ); out.writeFloat( prototypeReference.getDepth() ); out.writeFloat( prototypeReference.getAngle() ); float[] location = prototypeReference.getLocation(); out.writeFloat( location[0] ); out.writeFloat( location[1] ); out.writeFloat( location[2] ); }
/** * @return approximate size in bytes */ public long sizeOf() { long localSize = AllocatedHeapMemory.INSTANCE_SIZE; localSize += AllocatedHeapMemory.sizeOfList( qualityModelParts, true ); if ( qualityModelParts != null ) { for ( T part : qualityModelParts ) { localSize += part.sizeOf(); } } else { if ( prototype != null ) { localSize += AllocatedHeapMemory.REF_SIZE + prototype.getApproximateSizeInBytes(); } } return localSize; }
/** * @param glRenderContext * @param prototype * @param buffer * to be used for rendering. */ public synchronized static void render( RenderContext glRenderContext, PrototypeReference prototype, DirectGeometryBuffer buffer ) { if ( prototype == null || prototype.getPrototypeID() == null ) { return; } RenderablePrototype model = prototypes.get( prototype.getPrototypeID() ); if ( model == null ) { LOG.warn( "No model found for prototype: " + prototype.getPrototypeID() ); return; } GL context = glRenderContext.getContext(); context.glPushMatrix(); float[] loc = prototype.getLocation(); context.glTranslatef( loc[0], loc[1], loc[2] ); context.glRotatef( prototype.getAngle(), 0, 0, 1 ); context.glScalef( prototype.getWidth(), prototype.getDepth(), prototype.getHeight() ); if ( buffer == null ) { model.render( null ); } else { model.renderPrepared( glRenderContext, buffer ); } context.glPopMatrix(); }
/** * @param rqm * @param bbox * @return */ private RenderableQualityModel createPrototypeReference( RegressionForm form ) { // get 2D projection of 3D object required for calculating convex hull // Coordinate[] coordinates = projectToPlane( rqm ); float angle = form.getRotationAngle(); float width = form.getWidth(); float depth = form.getDepth(); float height = form.getHeight(); return new RenderableQualityModel( new PrototypeReference( "box", angle, form.getCentroid(), width, height, depth ) ); }
/** * @param mappedColumns * @param values * @return */ private WorldRenderableObject createWRO( Map<Column, Integer> mappedColumns, String[] values ) { float height = parseFloatingPoint( values[mappedColumns.get( Column.HEIGHT )], Column.HEIGHT ); float width = 1; float depth = 1; float northing = parseFloatingPoint( values[mappedColumns.get( Column.NORTHING )], Column.NORTHING ); northing += wpvsTranslationVector[1]; float easting = parseFloatingPoint( values[mappedColumns.get( Column.EASTING )], Column.EASTING ); easting += wpvsTranslationVector[0]; float groundLevel = parseFloatingPoint( values[mappedColumns.get( Column.GROUND_LEVEL )], Column.GROUND_LEVEL ); String protoTypeRef = values[mappedColumns.get( Column.PROTOTYPE )]; float[] location = new float[] { easting, northing, groundLevel }; PrototypeReference reference = new PrototypeReference( protoTypeRef, 0, location, width, height, depth ); RenderableQualityModel[] qualityLevels = new RenderableQualityModel[numberOfLevels]; Envelope env = getEnvelope( location, width, height, depth ); qualityLevels[qualityLevel] = new RenderableQualityModel( reference ); WorldRenderableObject result = new WorldRenderableObject( values[mappedColumns.get( Column.ID )], null, env, qualityLevels ); return result; }
if ( building != null ) { PrototypeReference pr = new PrototypeReference( prototypeID, rotation, new float[] { (float) translation[0], (float) translation[1] }, width, height, depth );