Merge pull request #770 from teyrana/fix/758/mass-comp-render
Fix #758 -- Rocket Figure should correctly display mass components with radius offsets.
This commit is contained in:
commit
0289d36fb3
@ -1456,7 +1456,7 @@ FreeformFinSet.FreeformFinSet = Freeform fin set
|
|||||||
! TubeFinSEt
|
! TubeFinSEt
|
||||||
TubeFinSet.TubeFinSet = Tube fin set
|
TubeFinSet.TubeFinSet = Tube fin set
|
||||||
!MassComponent
|
!MassComponent
|
||||||
MassComponent.MassComponent = Unspecified
|
MassComponent.MassComponent = Mass Component
|
||||||
MassComponent.Altimeter = Altimeter
|
MassComponent.Altimeter = Altimeter
|
||||||
MassComponent.FlightComputer = Flight computer
|
MassComponent.FlightComputer = Flight computer
|
||||||
MassComponent.DeploymentCharge = Deployment charge
|
MassComponent.DeploymentCharge = Deployment charge
|
||||||
|
@ -19,19 +19,23 @@ import net.sf.openrocket.util.Transformation;
|
|||||||
public class MassComponentShapes extends RocketComponentShape {
|
public class MassComponentShapes extends RocketComponentShape {
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassComponent massObj = (MassComponent)component;
|
||||||
|
|
||||||
MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
final double length = massObj.getLength();
|
||||||
|
final double radius = massObj.getRadius(); // radius of the object, itself
|
||||||
|
// magic number, but it's only cosmetic -- it just has to look pretty
|
||||||
|
final double arc = Math.min(length, 2*radius) * 0.7;
|
||||||
|
final double radialDistance = massObj.getRadialPosition();
|
||||||
|
final double radialAngleRadians = massObj.getRadialDirection();
|
||||||
|
|
||||||
MassComponent.MassComponentType type = ((MassComponent)component).getMassComponentType();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
double length = tube.getLength();
|
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
|
||||||
double radius = tube.getRadius();
|
|
||||||
double arc = Math.min(length, 2*radius) * 0.7;
|
|
||||||
|
|
||||||
final Coordinate start = transformation.transform(Coordinate.ZERO);
|
|
||||||
|
|
||||||
Shape[] s = {new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc)};
|
|
||||||
|
|
||||||
|
final MassComponent.MassComponentType type = ((MassComponent)component).getMassComponentType();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ALTIMETER:
|
case ALTIMETER:
|
||||||
s = addAltimeterSymbol(s);
|
s = addAltimeterSymbol(s);
|
||||||
@ -62,14 +66,19 @@ public class MassComponentShapes extends RocketComponentShape {
|
|||||||
|
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassObject massObj = (MassObject)component;
|
||||||
|
|
||||||
net.sf.openrocket.rocketcomponent.MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
final double radius = massObj.getRadius(); // radius of the object, itself
|
||||||
|
final double diameter = 2*radius;
|
||||||
|
final double radialDistance = massObj.getRadialPosition();
|
||||||
|
final double radialAngleRadians = massObj.getRadialDirection();
|
||||||
|
|
||||||
double or = tube.getRadius();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
final Coordinate start = transformation.transform(Coordinate.ZERO);
|
final Shape[] s = {new Ellipse2D.Double(renderPosition.z - radius, renderPosition.y - radius, diameter, diameter)};
|
||||||
|
|
||||||
Shape[] s = {new Ellipse2D.Double((start.z-or),(start.y-or),2*or,2*or)};
|
|
||||||
|
|
||||||
return RocketComponentShape.toArray(s, component);
|
return RocketComponentShape.toArray(s, component);
|
||||||
}
|
}
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
package net.sf.openrocket.gui.rocketfigure;
|
|
||||||
|
|
||||||
import java.awt.Shape;
|
|
||||||
import java.awt.geom.Ellipse2D;
|
|
||||||
import java.awt.geom.RoundRectangle2D;
|
|
||||||
|
|
||||||
import net.sf.openrocket.rocketcomponent.MassObject;
|
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
|
||||||
import net.sf.openrocket.util.Coordinate;
|
|
||||||
import net.sf.openrocket.util.Transformation;
|
|
||||||
|
|
||||||
|
|
||||||
public class MassObjectShapes extends RocketComponentShape {
|
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
|
||||||
|
|
||||||
MassObject tube = (MassObject)component;
|
|
||||||
|
|
||||||
double length = tube.getLength();
|
|
||||||
double radius = tube.getRadius();
|
|
||||||
double arc = Math.min(length, 2*radius) * 0.7;
|
|
||||||
|
|
||||||
Coordinate start = transformation.transform(Coordinate.ZERO);
|
|
||||||
|
|
||||||
Shape[] s = {new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc)};
|
|
||||||
|
|
||||||
return RocketComponentShape.toArray(s, component);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
|
||||||
|
|
||||||
MassObject tube = (MassObject)component;
|
|
||||||
|
|
||||||
double or = tube.getRadius();
|
|
||||||
|
|
||||||
final Coordinate start = transformation.transform(Coordinate.ZERO);
|
|
||||||
|
|
||||||
Shape[] s = {new Ellipse2D.Double((start.z-or), (start.y-or), 2*or, 2*or)};
|
|
||||||
|
|
||||||
return RocketComponentShape.toArray(s, component);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.rocketfigure;
|
package net.sf.openrocket.gui.rocketfigure;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.Transformation;
|
import net.sf.openrocket.util.Transformation;
|
||||||
@ -14,35 +15,41 @@ import java.awt.geom.RoundRectangle2D;
|
|||||||
public class ParachuteShapes extends RocketComponentShape {
|
public class ParachuteShapes extends RocketComponentShape {
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassObject massObj = (MassObject)component;
|
||||||
|
|
||||||
net.sf.openrocket.rocketcomponent.MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
final double length = massObj.getLength();
|
||||||
|
final double radius = massObj.getRadius(); // radius of the object, itself
|
||||||
|
// magic number, but it's only cosmetic -- it just has to look pretty
|
||||||
|
final double arc = Math.min(length, 2*radius) * 0.7;
|
||||||
|
final double radialDistance = massObj.getRadialPosition();
|
||||||
|
final double radialAngleRadians = massObj.getRadialDirection();
|
||||||
|
|
||||||
double length = tube.getLength();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
double radius = tube.getRadius();
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
double arc = Math.min(length, 2*radius) * 0.7;
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
Coordinate start = transformation.transform( Coordinate.ZERO);
|
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
|
||||||
|
|
||||||
Shape[] s = new Shape[1];
|
|
||||||
|
|
||||||
s[0] = new RoundRectangle2D.Double(start.x, (start.y-radius), length, 2*radius, arc, arc);
|
|
||||||
|
|
||||||
return RocketComponentShape.toArray( addSymbol(s), component);
|
return RocketComponentShape.toArray( addSymbol(s), component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassObject massObj = (MassObject)component;
|
||||||
|
|
||||||
net.sf.openrocket.rocketcomponent.MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
final double radius = massObj.getRadius(); // radius of the object, itself
|
||||||
|
final double diameter = 2*radius;
|
||||||
|
final double radialDistance = massObj.getRadialPosition();
|
||||||
|
final double radialAngleRadians = massObj.getRadialDirection();
|
||||||
|
|
||||||
double or = tube.getRadius();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
Coordinate[] start = transformation.transform(tube.toAbsolute(Coordinate.ZERO));
|
final Shape[] s = {new Ellipse2D.Double(renderPosition.z - radius, renderPosition.y - radius, diameter, diameter)};
|
||||||
|
|
||||||
Shape[] s = new Shape[start.length];
|
|
||||||
for (int i=0; i < start.length; i++) {
|
|
||||||
s[i] = new Ellipse2D.Double((start[i].z-or),(start[i].y-or),2*or,2*or);
|
|
||||||
}
|
|
||||||
return RocketComponentShape.toArray( s, component);
|
return RocketComponentShape.toArray( s, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.sf.openrocket.gui.rocketfigure;
|
package net.sf.openrocket.gui.rocketfigure;
|
||||||
|
|
||||||
|
import net.sf.openrocket.rocketcomponent.MassObject;
|
||||||
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
import net.sf.openrocket.rocketcomponent.RocketComponent;
|
||||||
import net.sf.openrocket.util.Coordinate;
|
import net.sf.openrocket.util.Coordinate;
|
||||||
import net.sf.openrocket.util.Transformation;
|
import net.sf.openrocket.util.Transformation;
|
||||||
@ -13,44 +14,41 @@ import java.awt.geom.RoundRectangle2D;
|
|||||||
public class StreamerShapes extends RocketComponentShape {
|
public class StreamerShapes extends RocketComponentShape {
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesSide( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassObject massObj = (MassObject)component;
|
||||||
|
|
||||||
net.sf.openrocket.rocketcomponent.MassObject massObj = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
final double length = massObj.getLength();
|
||||||
|
final double radius = massObj.getRadius(); // radius of the object, itself
|
||||||
|
// magic number, but it's only cosmetic -- it just has to look pretty
|
||||||
|
final double arc = Math.min(length, 2*radius) * 0.7;
|
||||||
|
final double radialDistance = massObj.getRadialPosition();
|
||||||
|
final double radialAngleRadians = massObj.getRadialDirection();
|
||||||
|
|
||||||
double length = massObj.getLength();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
double radius = massObj.getRadius();
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
double arc = Math.min(length, 2*radius) * 0.7;
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
Shape[] s = new Shape[1];
|
Shape[] s = {new RoundRectangle2D.Double(renderPosition.x - radius, renderPosition.y - radius, length, 2*radius, arc, arc)};
|
||||||
Coordinate frontCenter = transformation.transform(Coordinate.ZERO);
|
|
||||||
s[0] = new RoundRectangle2D.Double((frontCenter.x),(frontCenter.y-radius),
|
|
||||||
length,2*radius,arc,arc);
|
|
||||||
|
|
||||||
// Coordinate[] start = transformation.transform(tube.toAbsolute(instanceOffset));
|
|
||||||
// Shape[] s = new Shape[start.length];
|
|
||||||
// for (int i=0; i < start.length; i++) {
|
|
||||||
// s[i] = new RoundRectangle2D.Double(start[i].x,(start[i].y-radius),
|
|
||||||
// length,2*radius,arc,arc);
|
|
||||||
// }
|
|
||||||
return RocketComponentShape.toArray(addSymbol(s), component);
|
return RocketComponentShape.toArray(addSymbol(s), component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
public static RocketComponentShape[] getShapesBack( final RocketComponent component, final Transformation transformation) {
|
||||||
|
final MassObject massObj = (MassObject)component;
|
||||||
|
|
||||||
net.sf.openrocket.rocketcomponent.MassObject tube = (net.sf.openrocket.rocketcomponent.MassObject)component;
|
final double radius = massObj.getRadius(); // radius of the object, itself
|
||||||
|
final double diameter = 2*radius;
|
||||||
|
final double radialDistance = massObj.getRadialPosition();
|
||||||
|
final double radialAngleRadians = massObj.getRadialDirection();
|
||||||
|
|
||||||
double or = tube.getRadius();
|
final Coordinate localPosition = new Coordinate(0,
|
||||||
Shape[] s = new Shape[1];
|
radialDistance * Math.cos(radialAngleRadians),
|
||||||
Coordinate center = transformation.transform(Coordinate.ZERO);
|
radialDistance * Math.sin(radialAngleRadians));
|
||||||
|
final Coordinate renderPosition = transformation.transform(localPosition);
|
||||||
|
|
||||||
s[0] = new Ellipse2D.Double((center.z-or),(center.y-or),2*or,2*or);
|
final Shape[] s = {new Ellipse2D.Double(renderPosition.z - radius, renderPosition.y - radius, diameter, diameter)};
|
||||||
|
|
||||||
// Coordinate[] start = transformation.transform(tube.toAbsolute(instanceOffset));
|
|
||||||
//
|
|
||||||
// Shape[] s = new Shape[start.length];
|
|
||||||
// for (int i=0; i < start.length; i++) {
|
|
||||||
// s[i] = new Ellipse2D.Double((start[i].z-or),(start[i].y-or),2*or,2*or);
|
|
||||||
// }
|
|
||||||
return RocketComponentShape.toArray(s, component);
|
return RocketComponentShape.toArray(s, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user