Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more examples #185

Open
gaocegege opened this issue Jul 24, 2017 · 5 comments
Open

Add more examples #185

gaocegege opened this issue Jul 24, 2017 · 5 comments

Comments

@gaocegege
Copy link
Member

  • R package examples I think are important for the same reason that me working through importLibrary Java examples was important
  • We need some fancy, short examples to show the capability of P.R.
@jeremydouglass
Copy link
Member

There is a long discussion of potential R packages to try on #17 Support packages (libraries) in R. The most recent suggestion list was:

@gaocegege
Copy link
Member Author

gaocegege commented Oct 31, 2017

Processing Libraries

@gaocegege
Copy link
Member Author

he_mesh generally works but there is a bug or feature in Renjin: bedatadriven/renjin#347

mesh <- 0
tree <- 0
render <- 0
rnds <- 0
randomRay <- 0
bias <- 0
growing <- 0
counter <- 0

settings <- function() {
    # Please install the peasycam before you run the example.
    importLibrary("hemesh")
    fullScreen(P3D)
    smooth(as.integer(8))
}

setup <- function() {
    render <- WB_Render$new(processing)
    rnds <- WB_RandomOnSphere$new()
    creator <- HEC_Beethoven$new()
  creator$setScale(5)$setZAngle(PI/3)
  mesh <- HE_Mesh$new(creator)
  mesh$simplify(HES_TriDec$new()$setGoal(0.5))
  tree <- WB_AABBTree$new(mesh, as.integer(10))
  
  growing <- TRUE
  counter <- 0
  bias <- rnds$nextVector()
}

createMesh <- function() {
  creator <- HEC_Beethoven$new()
  creator$setScale(5)$setZAngle(PI/3)
  mesh <- HE_Mesh$new(creator)
  mesh$simplify(HES_TriDec$new()$setGoal(0.5))
  tree <- WB_AABBTree$new(mesh, as.integer(10))
  
  growing <- TRUE
  counter <- 0
  bias <- rnds$nextVector()
}


draw <- function() {
  background(20)
  directionalLight(255, 255, 255, 1, 1, -1)
  directionalLight(127, 127, 127, -1, -1, 1)
  translate(width/2, height/2, 0)
  rotateY(map(mouseX, 0, width, -PI, PI))
  rotateX(map(mouseY, 0, height, PI, -PI))

#   hint(DISABLE_DEPTH_TEST)
  noLights()
  fill(255)
  noStroke()
  pushMatrix()
  scale(1.8)
  render$drawFaces(mesh)
  popMatrix()

#   hint(ENABLE_DEPTH_TEST)
  directionalLight(255, 255, 255, 1, 1, -1)
  directionalLight(127, 127, 127, -1, -1, 1)
  scale(1.6)
  fill(255)
  noStroke()
  render$drawFaces(mesh)
  noFill()
  stroke(0, 50)
  render$drawEdges(mesh)


  if (growing) {
    for (i in 0:5) {
        grow()
        counter <- counter + 1
    }
  }
  
  if (counter == 500) {
    mesh$subdivide(HES_CatmullClark$new())
    growing <- false
    counter <- counter + 1
  }
}

grow <- function() {
  rayOrigin <- WB_Point$new(bias)$mulSelf(-500)
  rayDirection <- bias$add(random(-0.3, 0.3), random(-0.3, 0.3), random(-0.3, 0.3))
  randomRay <- WB_Ray$new(rayOrigin, rayDirection)
  fi <- HET_MeshOp$getFurthestIntersection(tree, randomRay)
  point <- 0
  if (!is.null(fi)) {
    print(fi$point)
    point <- fi$point
    point$addMulSelf(120, randomRay$getDirection())
    HEM_TriSplit$splitFaceTri(mesh, fi$face, point)
    tree <- WB_AABBTree$new(mesh, 10)
    stroke(255,0,0)
    render$drawRay(randomRay,1500)
  }
}

mousePressed <-function() {
 createMesh()  
}

@jeremydouglass
Copy link
Member

It looks like your comment above added a list of Processing(Java) libraries that are related to graphing. We already have a fairly basic example with grafica:

but grafica also supports allows some pretty advanced output for flashy demos -- including animation.

@gaocegege
Copy link
Member Author

Cool, I will take a look

@jeremydouglass jeremydouglass modified the milestones: Beta Release, v1.0.8 Aug 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants