|
struct Test_HairFromMeshStripsObject
|
|
(
|
|
-- Tests that hair from mesh strips can be used with another Ornatrix modifier and the hair goes through the pipeline
|
|
function Test_HairFromMeshStripsWithModifier =
|
|
(
|
|
-- Create a plane with 2x2 segments so we have 9 vertices all together
|
|
distributionObject = Plane lengthsegs:1 widthsegs:1
|
|
|
|
hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.AddStripObject distributionObject
|
|
|
|
-- Add frizz modifier on top and ensure that all the hairs make it out frizzed
|
|
select hairObjectInstance
|
|
max modify mode
|
|
modPanel.addModToSelection (Ox_Strand_Frizz())
|
|
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreNotEqual 0 (myHair.NumRoots())
|
|
delete hairCopy
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete distributionObject
|
|
),
|
|
|
|
function Test_AddRemoveStrips =
|
|
(
|
|
stripObject1 = Plane lengthsegs:1 widthsegs:1
|
|
stripObject2 = Plane lengthsegs:1 widthsegs:3
|
|
stripObject3 = Plane lengthsegs:5 widthsegs:3
|
|
|
|
hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.hairsPerStrip = 5
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.pointsPerStrand = 10
|
|
|
|
-- No hairs by default
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 0 (myHair.NumRoots())
|
|
delete hairCopy
|
|
|
|
hairObjectInstance.AddStripObject stripObject1
|
|
|
|
-- Hairs on first strip
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 5 (myHair.NumRoots())
|
|
EAssert.AreEqual 50 (myHair.NumVerts())
|
|
delete hairCopy
|
|
|
|
hairObjectInstance.AddStripObject stripObject2
|
|
hairObjectInstance.AddStripObject stripObject3
|
|
|
|
-- More hairs as strips are added
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 15 (myHair.NumRoots())
|
|
EAssert.AreEqual 150 (myHair.NumVerts())
|
|
delete hairCopy
|
|
|
|
hairObjectInstance.RemoveStripObject 1
|
|
|
|
-- Less hairs as strips are removed
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 10 (myHair.NumRoots())
|
|
EAssert.AreEqual 100 (myHair.NumVerts())
|
|
delete hairCopy
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete stripObject1
|
|
delete stripObject2
|
|
delete stripObject3
|
|
),
|
|
|
|
function Test_ChangeHairsPerStripCount =
|
|
(
|
|
stripObject1 = Plane lengthsegs:1 widthsegs:1
|
|
|
|
hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.hairsPerStrip = 5
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.AddStripObject stripObject1
|
|
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 5 (myHair.NumRoots())
|
|
delete hairCopy
|
|
|
|
hairObjectInstance.hairsPerStrip = 7
|
|
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 7 (myHair.NumRoots())
|
|
delete hairCopy
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete stripObject1
|
|
),
|
|
|
|
function Test_ViewPercentage =
|
|
(
|
|
stripObject1 = Plane lengthsegs:1 widthsegs:1
|
|
|
|
hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.hairsPerStrip = 500
|
|
hairObjectInstance.viewPercentage = 10
|
|
hairObjectInstance.AddStripObject stripObject1
|
|
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 50 (myHair.NumRoots())
|
|
delete hairCopy
|
|
|
|
hairObjectInstance.viewPercentage = 1
|
|
|
|
hairCopy = instance hairObjectInstance
|
|
convertTo hairCopy HairObject
|
|
myHair = hairCopy.GetHair()
|
|
EAssert.AreEqual 5 (myHair.NumRoots())
|
|
delete hairCopy
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete stripObject1
|
|
),
|
|
|
|
-- Tests for a bug where mesh from strands guide export generated from mesh from strips object produces an error
|
|
function Test_MeshFromStrandsWithGuideExport =
|
|
(
|
|
local stripObject1 = Plane lengthsegs:1 widthsegs:1
|
|
local hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.hairsPerStrip = 1
|
|
hairObjectInstance.AddStripObject stripObject1
|
|
|
|
select hairObjectInstance
|
|
max modify mode
|
|
local meshFromStrandsModifierInstance = Ox_Mesh_From_Strands()
|
|
modPanel.addModToSelection meshFromStrandsModifierInstance
|
|
|
|
-- This line should not cause an error
|
|
meshFromStrandsModifierInstance.guideMeshExp = on
|
|
|
|
-- Cleanup
|
|
delete stripObject1
|
|
delete hairObjectInstance
|
|
),
|
|
|
|
function Test_StripObjectWithMultipleMeshElements =
|
|
(
|
|
-- Create two planes/strips and attach one to another
|
|
local mainStripObject = Plane lengthsegs:1 widthsegs:1
|
|
local extraStripObject = Plane lengthsegs:1 widthsegs:1
|
|
|
|
select mainStripObject
|
|
max modify mode
|
|
local editPolyModifierInstance = Edit_Poly()
|
|
modPanel.addModToSelection editPolyModifierInstance
|
|
editPolyModifierInstance.Attach extraStripObject editPolyNode:mainStripObject
|
|
|
|
-- Create a hair from strips object and select the strips we attached into it
|
|
local hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.hairsPerStrip = 1
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.AddStripObject mainStripObject
|
|
|
|
-- The strip object should generate 2 strips: one for each element
|
|
myHair = hairObjectInstance.GetHair()
|
|
EAssert.AreEqual 2 (myHair.NumRoots())
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete mainStripObject
|
|
),
|
|
|
|
function Test_AddAndRemoveStripMeshTurbosmooth =
|
|
(
|
|
local stripObject = Plane lengthsegs:1 widthsegs:1
|
|
|
|
select stripObject
|
|
max modify mode
|
|
local turboSmoothInstance = TurboSmooth()
|
|
modPanel.addModToSelection turboSmoothInstance
|
|
|
|
local hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.hairsPerStrip = 1
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.AddStripObject stripObject
|
|
|
|
-- Mark the current hair's tip
|
|
local myHair = hairObjectInstance.GetHair()
|
|
local tipPositon = myHair.GetPointT 0 1
|
|
|
|
-- Delete turbosmooth modifier and check that vartices are in the same place
|
|
select stripObject
|
|
deleteModifier stripObject 1
|
|
|
|
-- Check the tip position again, it should be about the same
|
|
myHair = hairObjectInstance.GetHair()
|
|
EAssert.ArePointsNearEqual tipPositon (myHair.GetPointT 0 1)
|
|
|
|
-- Undo the turbosmooth deletion, it should not cause a crash
|
|
-- NOTE: This will undo whole action so it isn't good
|
|
--actionMan.executeAction 0 "40015"
|
|
select stripObject
|
|
modPanel.addModToSelection turboSmoothInstance
|
|
|
|
-- Turn isoline display on in turbosmooth. This should not make hair generation hang.
|
|
turboSmoothInstance.isolineDisplay = on
|
|
stripObject.widthsegs = 2
|
|
stripObject.lengthsegs = 2
|
|
|
|
delete stripObject
|
|
delete hairObjectInstance
|
|
),
|
|
|
|
function Test_InheritMeshStripTextureCoordinates =
|
|
(
|
|
local stripObject = Plane lengthsegs:1 widthsegs:1
|
|
|
|
select stripObject
|
|
max modify mode
|
|
|
|
local hairObjectInstance = HairFromMeshStripsObject()
|
|
hairObjectInstance.hairsPerStrip = 1
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.AddStripObject stripObject
|
|
|
|
-- Disable texture coordinate inheritance at first
|
|
hairObjectInstance.inheritUvsFromStrips = off
|
|
|
|
-- Hair texture coordiantes should be auto-generated and produce world coordinates as UVW since we don't have a distribution mesh
|
|
local myHair = hairObjectInstance.GetHair()
|
|
EAssert.AreEqual [-12.5,0,0] ( myHair.GetPointUVW 0 0 )
|
|
|
|
-- Enable texture coordinate inheritance and make sure texture coordinates are inherited
|
|
hairObjectInstance.inheritUvsFromStrips = on
|
|
myHair = hairObjectInstance.GetHair()
|
|
EAssert.AreEqual [0,0.5,0] ( myHair.GetPointUVW 0 0 )
|
|
|
|
-- Cleanup
|
|
delete stripObject
|
|
delete hairObjectInstance
|
|
),
|
|
|
|
-- Checks for a bug which made Max crash when point count is changed after a modifier is applied when Nitrous hair is used
|
|
function Test_ChangePointCountAfterApplyingAModifier =
|
|
(
|
|
local stripObject = Plane lengthsegs:1 widthsegs:1
|
|
local hairObjectInstance = HairFromMeshStripsObject()
|
|
select hairObjectInstance
|
|
max modify mode
|
|
hairObjectInstance.hairsPerStrip = 10
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.pointsPerStrand = 10
|
|
hairObjectInstance.AddStripObject stripObject
|
|
completeRedraw()
|
|
|
|
select hairObjectInstance
|
|
local renderSettingsModifierInstance = Ox_Render_Settings()
|
|
modPanel.addModToSelection renderSettingsModifierInstance
|
|
modPanel.setCurrentObject hairObjectInstance
|
|
hairObjectInstance.pointsPerStrand = 60
|
|
completeRedraw()
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete stripObject
|
|
),
|
|
|
|
-- Makes sure that hair can be added to editable poly modifier without crashing the Nitrous viewport
|
|
function Test_AddStripsToEditablePolyAndSelect =
|
|
(
|
|
local stripObject = Plane lengthsegs:1 widthsegs:1
|
|
select stripObject
|
|
macros.run "Modifier Stack" "Convert_to_Poly"
|
|
|
|
local hairObjectInstance = HairFromMeshStripsObject()
|
|
select hairObjectInstance
|
|
max modify mode
|
|
hairObjectInstance.AddStripObject stripObject
|
|
completeRedraw()
|
|
|
|
select hairObjectInstance
|
|
local renderSettingsModifierInstance = Ox_Render_Settings()
|
|
modPanel.addModToSelection renderSettingsModifierInstance
|
|
completeRedraw()
|
|
|
|
-- This shouldn't crash Max
|
|
select stripObject
|
|
completeRedraw()
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete stripObject
|
|
),
|
|
|
|
function Test_HairFromStripsFromMeshFromStrands =
|
|
(
|
|
local stripObject = Plane lengthsegs:1 widthsegs:1
|
|
select stripObject
|
|
max modify mode
|
|
local guidesFromSurfaceModifierInstance = Ox_Guides_From_Surface()
|
|
TestUtilities.SetGuidesFromMeshDefaults guidesFromSurfaceModifierInstance
|
|
guidesFromSurfaceModifierInstance.method = 4
|
|
modPanel.addModToSelection guidesFromSurfaceModifierInstance
|
|
|
|
local hairFromGuidesInstance = Ox_Hair_from_Guides ()
|
|
hairFromGuidesInstance.method = 4 --4
|
|
hairFromGuidesInstance.count = 4
|
|
modPanel.addModToSelection hairFromGuidesInstance
|
|
|
|
local meshFromStrandsInstance = Ox_Mesh_From_Strands()
|
|
meshFromStrandsInstance.type = 1
|
|
modPanel.addModToSelection meshFromStrandsInstance
|
|
|
|
local hairObjectInstance = HairFromMeshStripsObject()
|
|
select hairObjectInstance
|
|
max modify mode
|
|
hairObjectInstance.hairsPerStrip = 2
|
|
hairObjectInstance.viewPercentage = 100
|
|
hairObjectInstance.AddStripObject stripObject
|
|
|
|
local myHair = hairObjectInstance.GetHair()
|
|
EAssert.AreEqual 8 ( myHair.NumRoots() )
|
|
|
|
-- Cleanup
|
|
delete hairObjectInstance
|
|
delete stripObject
|
|
)
|
|
)
|
|
|
|
EUnit.AddTestClass Test_HairFromMeshStripsObject
|
|
ok
|