%%%create_object_hierarchy
HPS.
View myView = GetCanvas().GetAttachedLayout().GetAttachedView();
%%%create_subsegments
%%%include
myModelKey.IncludeSegment(subassemblySegment);
%%%segment_operations
someSegment.MoveTo(newParentSegment);
someSegment.CopyTo(anotherSegment);
childSegment.Delete();
%%%insert_shell
int[] myFaceList = { 3, 0, 1, 2 };
%%%%2d_geometry
lineSegment.GetVisibilityControl().SetLines(true);
%%%primitives
%%%setting_attributes
myModel.GetSegmentKey().GetMaterialMappingControl().SetEdgeColor(
new HPS.
RGBAColor(1, 0, 0));
cylinderSegment.GetVisibilityControl().SetFaces(false);
%%%visibility
myModel.GetSegmentKey().GetVisibilityControl().SetEdges(true);
%%%line_settings
shellSegment.GetMaterialMappingControl().SetFaceColor(
new HPS.
RGBAColor(0, 1, 0));
circleSegment.GetEdgeAttributeControl().SetWeight(3.0f);
lineSegment.GetPortfolioControl().Push(myPortfolio);
myPortfolio.DefineLinePattern("dashed_pattern", myLinePatternKitpk);
lineSegment.GetLineAttributeControl().SetPattern("dashed_pattern");
%%%circle_segment
circleSegment.MoveTo(shellSegment);
%%%file_import
in_options.SetSegment(GetModel().GetSegmentKey());
GetModel().GetSegmentKey().Flush();
try
{
notifier =
HPS.
Stream.File.Import(path_to_file, in_options);
notifier.Wait();
}
{
}
GetView().FitWorld();
GetView().Update();
%%%set_rendering_mode
%%%shadows
bool state, ignore_transparency;
uint resolution, blurring;
GetView().GetSegmentKey().GetVisualEffectsControl().ShowSimpleShadow(out state, out resolution, out blurring, out ignore_transparency);
if (state == true)
else
GetView().GetSegmentKey().SetVisualEffects(vxfkit);
GetView().Update();
%%%loading_shell
GetView().AttachModel(model);
try
{
importOptionsKit.SetSegment(model.GetSegmentKey());
notifier =
HPS.
Stream.File.Import(path_to_file, importOptionsKit);
notifier.Wait();
}
{
}
canvas.GetFrontView().FitWorld().Update();
%%%set_color
mySegmentKey.GetMaterialMappingControl()
mySegmentKey.GetVisibilityControl().SetEdges(true);
%%%set_face_texture
mySegmentKey.GetMaterialMappingControl()
.SetFaceTexture("woodDiffuse",
%%%face_level_texturing
("myPalette", materialKitArray);
model.GetSegmentKey().SetMaterialPalette("myPalette");
%%%set_face_colors
ulong[] faceIndices = { 0, 1, 2, 3, 4, 5 };
float[] materialIndices = { 0, 1, 2, 3, 4, 5 };
myShellKey.SetFaceIndexColorsByList(faceIndices, 0);
%%%search
ulong numResults = model.GetSegmentKey().Find(
HPS.
Search.
Type.Shell,
out searchResults);
while (it.IsValid())
{
{
}
it.Next();
}
%%%set_diffuse_color
materialKitArray[1].SetDiffuse(
new HPS.
RGBAColor(1.0f, 0.0f, 0.0f, 0.5f));
%%%set_bump
model.GetSegmentKey().InsertDistantLight(
new HPS.
Vector(1, 1, 1));
materialKitArray[2].SetDiffuseTexture("my_texture");
materialKitArray[2].SetBump("my_heightmap");
%%%multitexturing
textureOptionsKit.SetModulation(true);
materialKitArray[3].SetDiffuseTexture("brickDiffuse", 0);
materialKitArray[3].SetDiffuseTexture("grassDiffuse", 1);
%%%mmk
myShellKit.SetMaterialMapping(myMaterialMappingKit);
%%%import_notifier
try
{
importOptionsKit.SetSegment(mySegmentKey);
notifier =
HPS.
Stream.File.Import(filename, importOptionsKit);
notifier.Wait();
}
{
}
%%%get_model_key
HPS.
SegmentKey modelSegmentKey = GetTopView().GetAttachedModel().GetSegmentKey();
%%%reflection
modelSegmentKey.GetVisualEffectsControl().SetSimpleReflection(true, 0.5f, 1U, false, 0, 2.0f);
modelSegmentKey.GetVisualEffectsControl().SetSimpleReflectionPlane(
new HPS.
Plane(0, 1, 0, 0.375f));
%%%set_shadows
modelSegmentKey.GetVisibilityControl().SetShadows(true);
modelSegmentKey.GetVisualEffectsControl().SetShadowMaps(true, 16, 2048, true, true);
%%%shadow_attributes
modelSegmentKey.GetVisualEffectsControl().SetSimpleShadow(true);
modelSegmentKey.GetVisualEffectsControl().SetSimpleShadowPlane(
new HPS.
Plane(0, 1, 0, 0.425f));
modelSegmentKey.GetVisualEffectsControl().SetSimpleShadowColor(new RGBAColor(0.2f, 0.2f, 0.2f));
modelSegmentKey.GetVisualEffectsControl().SetSimpleShadowLightDirection(new Vector(0, 1, 0));
%%%ppe
myWindowKey.SetPostProcessEffects(ppek);
%%%create_style
mySegmentKey.GetPortfolioControl().Push(myPortfolio);
myHighlightStyle.GetSource().GetVisibilityControl().SetFaces(true).SetEdges(true);
mySegmentKey.GetStyleControl().PushNamed("myStyle");
%%%attach_operator
HPS.
View myView = GetCanvas().GetAttachedLayout().GetAttachedView();
myView.GetOperatorControl().Push(myHighlightOperator);
myHighlightOperator.SetHighlightOptions(hok);
%%%processing_selection
while (it.IsValid())
{
if (selectionItem.ShowSelectedItem(out key))
{
{
}
}
it.Next();
}
%%%basic_setup
myWindowKey.GetMaterialMappingControl().SetWindowColor(new RGBAColor(1, 1, 1)).SetWindowContrastColor(new RGBAColor(1, 1, 1))
.SetFaceColor(new RGBAColor(1, 0.75f, 0)).SetEdgeColor(new RGBAColor(0.2f, 0.2f, 0.2f)).SetLineColor(new RGBAColor(0.2f, 0.2f, 0.2f));
myWindowKey.GetVisibilityControl().SetLeaderLines(true).SetEdges(true);
myWindowKey.GetTextAttributeControl().SetBackground(true).SetSize(24, Text.SizeUnits.Points)
.SetAlignment(Text.Alignment.Center, Text.ReferenceFrame.WorldAligned, Text.Justification.Center);
myWindowKey.GetDrawingAttributeControl().SetWorldHandedness(Drawing.Handedness.Left);
myWindowKey.GetMaterialMappingControl().SetWindowColor(new RGBAColor(1.0f, 1.0f, 1.0f));
myWindowKey.GetCameraControl().SetPosition(
new HPS.
Point(8, -4, 10));
myWindowKey.GetPortfolioControl().Push(portfolio);
%%%insert_cube
cubeSegmentKey.GetPortfolioControl().Push(portfolio);
cubeSegmentKey.GetVisibilityControl().SetEdges(true);
%%%create_textbox
HPS.
ShapePoint [] textBoxRectanglePoints = { leftBottom, rightBottom, rightTop, leftTop };
%%%create_line_anchor
lineAnchor.SetIntermediatePoints(intermediatePoints);
%%%create_shapekit
HPS.
ShapeElement [] rectangle_elements = { rectangleBackgroundShape, lineAnchor };
rectangle_shape.SetElements(rectangle_elements);
portfolio.DefineShape("anchored_leader_line_rectangle", rectangle_shape);
rectangleSegmentKey.GetTextAttributeControl().SetBackground("anchored_leader_line_rectangle");
HPS.
TextKey rectangle_text = rectangleSegmentKey.InsertText(
new HPS.
Point(2, -2, 0),
"Vertex is 0.5, 0.5, -0.5\nin world space.");
rectangleSegmentKey.GetEdgeAttributeControl().SetWeight(2,
HPS.
Edge.
SizeUnits.Pixels);
rectangle_text.SetLeaderLine(leader_line_position);
%%%line_pattern
slpe.SetColor(new RGBAColor(0.2f, 0.2f, 0.2f));
lppk.SetBody(slpe);
%%%add_arrowhead
portfolio.DefineGlyph("anchored_leader_line_triangle", glyphKit);
glyph_pattern.SetSource("anchored_leader_line_triangle");
lppk.SetEndCap(glyph_pattern);
%%%wrap_up
portfolio.DefineLinePattern("myLinePattern", lpk);
rectangleSegmentKey.GetLineAttributeControl().SetPattern("myLinePattern");
rectangleSegmentKey.GetVisibilityControl().SetLines(true);
%%%full_program
myWindowKey.GetMaterialMappingControl().SetWindowColor(new RGBAColor(1, 1, 1)).SetWindowContrastColor(new RGBAColor(1, 1, 1))
.SetFaceColor(new RGBAColor(1, 0.75f, 0)).SetEdgeColor(new RGBAColor(0.2f, 0.2f, 0.2f)).SetLineColor(new RGBAColor(0.2f, 0.2f, 0.2f));
myWindowKey.GetVisibilityControl().SetLeaderLines(true).SetEdges(true);
myWindowKey.GetTextAttributeControl().SetBackground(true).SetSize(24, Text.SizeUnits.Points)
.SetAlignment(Text.Alignment.Center, Text.ReferenceFrame.WorldAligned, Text.Justification.Center);
myWindowKey.GetDrawingAttributeControl().SetWorldHandedness(Drawing.Handedness.Left);
myWindowKey.GetMaterialMappingControl().SetWindowColor(new RGBAColor(1.0f, 1.0f, 1.0f));
myWindowKey.GetCameraControl().SetPosition(
new HPS.
Point(8, -4, 10));
myWindowKey.GetPortfolioControl().Push(portfolio);
cubeSegmentKey.GetPortfolioControl().Push(portfolio);
cubeSegmentKey.GetVisibilityControl().SetEdges(true);
HPS.
ShapePoint [] textBoxRectanglePoints = { leftBottom, rightBottom, rightTop, leftTop };
lineAnchor.SetIntermediatePoints(intermediatePoints);
HPS.
ShapeElement [] rectangle_elements = { rectangleBackgroundShape, lineAnchor };
rectangle_shape.SetElements(rectangle_elements);
portfolio.DefineShape("anchored_leader_line_rectangle", rectangle_shape);
rectangleSegmentKey.GetTextAttributeControl().SetBackground("anchored_leader_line_rectangle");
HPS.
TextKey rectangle_text = rectangleSegmentKey.InsertText(
new HPS.
Point(2, -2, 0),
"Vertex is 0.5, 0.5, -0.5\nin world space.");
rectangleSegmentKey.GetEdgeAttributeControl().SetWeight(2,
HPS.
Edge.
SizeUnits.Pixels);
rectangle_text.SetLeaderLine(leader_line_position);
slpe.SetColor(new RGBAColor(0.2f, 0.2f, 0.2f));
lppk.SetBody(slpe);
portfolio.DefineGlyph("anchored_leader_line_triangle", glyphKit);
glyph_pattern.SetSource("anchored_leader_line_triangle");
lppk.SetEndCap(glyph_pattern);
portfolio.DefineLinePattern("myLinePattern", lpk);
rectangleSegmentKey.GetLineAttributeControl().SetPattern("myLinePattern");
rectangleSegmentKey.GetVisibilityControl().SetLines(true);
%%%cube_program
protected ShellKey InsertCube(SegmentKey segmentKey, Point center, float size)
{
float halflength = size / 2;
Point[] pointArray = { new Point(-halflength + center.x, -halflength + center.y, halflength + center.z),
new Point(halflength + center.x, -halflength + center.y, halflength + center.z),
new Point(halflength + center.x, halflength + center.y, halflength + center.z),
new Point(-halflength + center.x, halflength + center.y, halflength + center.z),
new Point(-halflength + center.x, -halflength + center.y, -halflength + center.z),
new Point(halflength + center.x, -halflength + center.y, -halflength + center.z),
new Point(halflength + center.x, halflength + center.y, -halflength + center.z),
new Point(-halflength + center.x, halflength + center.y, -halflength + center.z)
};
int[] faceList = { 4, 0, 1, 2, 3, 4, 1, 5, 6, 2, 4, 5, 6, 7, 4, 4, 4, 7, 3, 0, 4, 3, 2, 6, 7, 4, 0, 4, 5, 1 };
return segmentKey.InsertShell(pointArray, faceList);
}
%%%import_file
HPS.
Model myModel = Factory.CreateModel();
string filename = "C:\\myData\\bnc.hsf";
HPS.
Stream.ImportNotifier importNotifier =
new Stream.ImportNotifier();
try
{
HPS.
Stream.ImportOptionsKit myImportOptionsKit =
new Stream.ImportOptionsKit();
myImportOptionsKit.SetSegment(modelSegment);
importNotifier =
HPS.
Stream.File.Import(filename, myImportOptionsKit);
importNotifier.Wait();
}
{
}
%%%update_info_sample
WindowInfoControl windowInfo = window.GetWindowInfoControl();
int static_models_created = 0;
if (windowInfo.ShowLastUpdateInfo(out updateInfo))
{
}
%%%set_static_model
_canvas.GetFrontView().AttachModel(myModel);
modelSegment.GetPerformanceControl().SetStaticModel(Performance.StaticModel.Attribute);
window.UpdateWithNotifier(Window.UpdateType.Exhaustive).Wait();
%%%update_info_sample
WindowInfoControl windowInfo = window.GetWindowInfoControl();
int static_models_created = 0;
if (windowInfo.ShowLastUpdateInfo(out updateInfo))
{
}
%%%static_model_change
_canvas.GetFrontView().GetAttachedModel().GetSegmentKey().GetModellingMatrixControl().Scale(2.0f, 2.0f, 2.0f);
%%%set_resource_monitor
window.GetDebuggingControl().SetResourceMonitor(true);
%%%first_update
window.UpdateWithNotifier(Window.UpdateType.Default).Wait();
if (windowInfo.ShowLastUpdateInfo(out updateInfo))
static_models_created = (int)updateInfo.statics_created_count;
%%%second_update
window.UpdateWithNotifier(Window.UpdateType.Default).Wait();
if (windowInfo.ShowLastUpdateInfo(out updateInfo))
static_models_created = (int)updateInfo.statics_created_count;
%%%full_program_static_model_tutorial
HPS.
Model myModel = Factory.CreateModel();
string filename = "C:\\myData\\bnc.hsf";
HPS.
Stream.ImportNotifier importNotifier =
new Stream.ImportNotifier();
try
{
HPS.
Stream.ImportOptionsKit myImportOptionsKit =
new Stream.ImportOptionsKit();
myImportOptionsKit.SetSegment(modelSegment);
importNotifier =
HPS.
Stream.File.Import(filename, myImportOptionsKit);
importNotifier.Wait();
}
{
}
_canvas.GetFrontView().AttachModel(myModel);
modelSegment.GetPerformanceControl().SetStaticModel(Performance.StaticModel.Attribute);
window.UpdateWithNotifier(Window.UpdateType.Exhaustive).Wait();
WindowInfoControl windowInfo = window.GetWindowInfoControl();
int static_models_created = 0;
if (windowInfo.ShowLastUpdateInfo(out updateInfo))
{
}
_canvas.GetFrontView().GetAttachedModel().GetSegmentKey().GetModellingMatrixControl().Scale(2.0f, 2.0f, 2.0f);
window.GetDebuggingControl().SetResourceMonitor(true);
window.UpdateWithNotifier(Window.UpdateType.Default).Wait();
if (windowInfo.ShowLastUpdateInfo(out updateInfo))
static_models_created = (int)updateInfo.statics_created_count;
window.UpdateWithNotifier(Window.UpdateType.Default).Wait();
if (windowInfo.ShowLastUpdateInfo(out updateInfo))
static_models_created = (int)updateInfo.statics_created_count;
%%%%00700_skybox
myCanvas.AttachViewAsLayout(myView);
ImageKit frontImg =
HPS.
Image.File.Import(image_path_positive_z, iok);
ImageKit leftImg =
HPS.
Image.File.Import(image_path_negative_x, iok);
ImageKit rightImg =
HPS.
Image.File.Import(image_path_positive_x, iok);
ImageKit backImg =
HPS.
Image.File.Import(image_path_negative_z, iok);
ImageKit bottomImg =
HPS.
Image.File.Import(image_path_negative_y, iok);
ImageKit topImg =
HPS.
Image.File.Import(image_path_positive_y, iok);
HPS.
CubeMapDefinition skybox = myPortfolioKey.DefineCubeMap(
"skybox", backDef, frontDef, leftDef, rightDef, botDef, topDef);
myView.GetSegmentKey().GetSubwindowControl().SetBackground(Subwindow.Background.Cubemap, "skybox");
myView.GetNavigationCubeControl().SetVisibility(true).SetInteractivity(true);
cubeSegmentKey.GetVisibilityControl().SetEdges(false);
SmoothTransHandler myHandler = new SmoothTransHandler();
myView.Update();
myView.SmoothTransition(camkit, 2);
while (!myHandler.transitionComplete)
{
;
}
myHandler.transitionComplete = false;
myView.SmoothTransition(camkit, 2);
while (!myHandler.transitionComplete)
{
;
}
%%%%00700_skybox_import_images
ImageKit frontImg =
HPS.
Image.File.Import(image_path_positive_z, iok);
ImageKit leftImg =
HPS.
Image.File.Import(image_path_negative_x, iok);
ImageKit rightImg =
HPS.
Image.File.Import(image_path_positive_x, iok);
ImageKit backImg =
HPS.
Image.File.Import(image_path_negative_z, iok);
ImageKit bottomImg =
HPS.
Image.File.Import(image_path_negative_y, iok);
ImageKit topImg =
HPS.
Image.File.Import(image_path_positive_y, iok);
%%%%00700_skybox_smooth_transition_handler
class SmoothTransHandler :
HPS.EventHandler
{
public volatile bool transitionComplete = false;
~SmoothTransHandler() { Shutdown(); }
public override HandleResult Handle(Event in_event)
{
transitionComplete = true;
return HandleResult.Handled;
}
};
%%%%00700_skybox_cube_program
protected ShellKey InsertCube(SegmentKey segmentKey, Point center, float size)
{
float halflength = size / 2;
Point[] pointArray = { new Point(-halflength + center.x, -halflength + center.y, halflength + center.z),
new Point(halflength + center.x, -halflength + center.y, halflength + center.z),
new Point(halflength + center.x, halflength + center.y, halflength + center.z),
new Point(-halflength + center.x, halflength + center.y, halflength + center.z),
new Point(-halflength + center.x, -halflength + center.y, -halflength + center.z),
new Point(halflength + center.x, -halflength + center.y, -halflength + center.z),
new Point(halflength + center.x, halflength + center.y, -halflength + center.z),
new Point(-halflength + center.x, halflength + center.y, -halflength + center.z)
};
int[] faceList = { 4, 0, 1, 2, 3, 4, 1, 5, 6, 2, 4, 5, 6, 7, 4, 4, 4, 7, 3, 0, 4, 3, 2, 6, 7, 4, 0, 4, 5, 1 };
return segmentKey.InsertShell(pointArray, faceList);
}
%%%%00700_skybox_portfolio
HPS.
CubeMapDefinition skybox = myPortfolioKey.DefineCubeMap(
"skybox", backDef, frontDef, leftDef, rightDef, botDef, topDef);
myView.GetSegmentKey().GetSubwindowControl().SetBackground(Subwindow.Background.Cubemap, "skybox");
%%%%00700_skybox_animation
myView.GetNavigationCubeControl().SetVisibility(true).SetInteractivity(true);
cubeSegmentKey.GetVisibilityControl().SetEdges(false);
SmoothTransHandler myHandler = new SmoothTransHandler();
myView.Update();
myView.SmoothTransition(camkit, 2);
while (!myHandler.transitionComplete)
{
;
}
myHandler.transitionComplete = false;
myView.SmoothTransition(camkit, 2);
while (!myHandler.transitionComplete)
{
;
}